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 |