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(); | |
161 } | 159 } |
162 } | 160 } |
163 | 161 |
164 TranslateRankerImpl::~TranslateRankerImpl() {} | 162 TranslateRankerImpl::~TranslateRankerImpl() {} |
165 | 163 |
166 // static | 164 // static |
167 base::FilePath TranslateRankerImpl::GetModelPath( | 165 base::FilePath TranslateRankerImpl::GetModelPath( |
168 const base::FilePath& data_dir) { | 166 const base::FilePath& data_dir) { |
169 if (data_dir.empty()) | 167 if (data_dir.empty()) |
170 return base::FilePath(); | 168 return base::FilePath(); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 } | 372 } |
375 } | 373 } |
376 | 374 |
377 } // namespace translate | 375 } // namespace translate |
378 | 376 |
379 std::ostream& operator<<(std::ostream& stream, | 377 std::ostream& operator<<(std::ostream& stream, |
380 const translate::TranslateRankerFeatures& features) { | 378 const translate::TranslateRankerFeatures& features) { |
381 features.WriteTo(stream); | 379 features.WriteTo(stream); |
382 return stream; | 380 return stream; |
383 } | 381 } |
OLD | NEW |