Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(865)

Unified Diff: components/translate/core/browser/ranker_model.cc

Issue 2925733002: Move ranker_model_loader to a new component. (Closed)
Patch Set: Adressing sdefresne's comments. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/translate/core/browser/ranker_model.cc
diff --git a/components/translate/core/browser/ranker_model.cc b/components/translate/core/browser/ranker_model.cc
deleted file mode 100644
index cd12d62820c6dcad37dce7cd479f489d165a5124..0000000000000000000000000000000000000000
--- a/components/translate/core/browser/ranker_model.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright 2017 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "components/translate/core/browser/ranker_model.h"
-
-#include "base/memory/ptr_util.h"
-#include "base/time/time.h"
-#include "components/translate/core/browser/proto/ranker_model.pb.h"
-
-namespace chrome_intelligence {
-
-RankerModel::RankerModel() : proto_(base::MakeUnique<RankerModelProto>()) {}
-
-RankerModel::~RankerModel() {}
-
-// static
-std::unique_ptr<RankerModel> RankerModel::FromString(const std::string& data) {
- auto model = base::MakeUnique<RankerModel>();
- if (!model->mutable_proto()->ParseFromString(data))
- return nullptr;
- return model;
-}
-
-bool RankerModel::IsExpired() const {
- if (!proto().has_metadata())
- return true;
-
- const auto& metadata = proto().metadata();
-
- // If the age of the model cannot be determined, presume it to be expired.
- if (!metadata.has_last_modified_sec())
- return true;
-
- // If the model has no set cache duration, then it never expires.
- if (!metadata.has_cache_duration_sec() || metadata.cache_duration_sec() == 0)
- return false;
-
- // Otherwise, a model is expired if its age exceeds the cache duration.
- base::Time last_modified =
- base::Time() + base::TimeDelta::FromSeconds(metadata.last_modified_sec());
- base::TimeDelta age = base::Time::Now() - last_modified;
- return age > base::TimeDelta::FromSeconds(metadata.cache_duration_sec());
-}
-
-const std::string& RankerModel::GetSourceURL() const {
- return proto_->metadata().source();
-}
-
-std::string RankerModel::SerializeAsString() const {
- return proto_->SerializeAsString();
-}
-
-} // namespace chrome_intelligence
« no previous file with comments | « components/translate/core/browser/ranker_model.h ('k') | components/translate/core/browser/ranker_model_loader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698