OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/translate/core/browser/translate_ranker_impl.h" | 5 #include "components/translate/core/browser/translate_ranker_impl.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 is_decision_override_enabled_(base::FeatureList::IsEnabled( | 149 is_decision_override_enabled_(base::FeatureList::IsEnabled( |
150 translate::kTranslateRankerDecisionOverride)), | 150 translate::kTranslateRankerDecisionOverride)), |
151 weak_ptr_factory_(this) { | 151 weak_ptr_factory_(this) { |
152 if (is_query_enabled_ || is_enforcement_enabled_ || | 152 if (is_query_enabled_ || is_enforcement_enabled_ || |
153 is_decision_override_enabled_) { | 153 is_decision_override_enabled_) { |
154 model_loader_ = base::MakeUnique<RankerModelLoader>( | 154 model_loader_ = base::MakeUnique<RankerModelLoader>( |
155 base::Bind(&ValidateModel), | 155 base::Bind(&ValidateModel), |
156 base::Bind(&TranslateRankerImpl::OnModelAvailable, | 156 base::Bind(&TranslateRankerImpl::OnModelAvailable, |
157 weak_ptr_factory_.GetWeakPtr()), | 157 weak_ptr_factory_.GetWeakPtr()), |
158 model_path, model_url, kUmaPrefix); | 158 model_path, model_url, kUmaPrefix); |
| 159 // Kick off the initial load from cache. |
| 160 model_loader_->NotifyOfRankerActivity(); |
159 } | 161 } |
160 } | 162 } |
161 | 163 |
162 TranslateRankerImpl::~TranslateRankerImpl() {} | 164 TranslateRankerImpl::~TranslateRankerImpl() {} |
163 | 165 |
164 // static | 166 // static |
165 base::FilePath TranslateRankerImpl::GetModelPath( | 167 base::FilePath TranslateRankerImpl::GetModelPath( |
166 const base::FilePath& data_dir) { | 168 const base::FilePath& data_dir) { |
167 if (data_dir.empty()) | 169 if (data_dir.empty()) |
168 return base::FilePath(); | 170 return base::FilePath(); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 } | 374 } |
373 } | 375 } |
374 | 376 |
375 } // namespace translate | 377 } // namespace translate |
376 | 378 |
377 std::ostream& operator<<(std::ostream& stream, | 379 std::ostream& operator<<(std::ostream& stream, |
378 const translate::TranslateRankerFeatures& features) { | 380 const translate::TranslateRankerFeatures& features) { |
379 features.WriteTo(stream); | 381 features.WriteTo(stream); |
380 return stream; | 382 return stream; |
381 } | 383 } |
OLD | NEW |