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

Side by Side Diff: components/translate/core/browser/translate_ranker_impl.cc

Issue 2839433002: [translate] Fix shutdown race for translate ranker model loader. (Closed)
Patch Set: fdoray part deux Created 3 years, 8 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 unified diff | Download patch
OLDNEW
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
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 model_loader_->Start(); 159 // Kick off the initial load from cache.
160 model_loader_->NotifyOfRankerActivity();
160 } 161 }
161 } 162 }
162 163
163 TranslateRankerImpl::~TranslateRankerImpl() {} 164 TranslateRankerImpl::~TranslateRankerImpl() {}
164 165
165 // static 166 // static
166 base::FilePath TranslateRankerImpl::GetModelPath( 167 base::FilePath TranslateRankerImpl::GetModelPath(
167 const base::FilePath& data_dir) { 168 const base::FilePath& data_dir) {
168 if (data_dir.empty()) 169 if (data_dir.empty())
169 return base::FilePath(); 170 return base::FilePath();
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 374 }
374 } 375 }
375 376
376 } // namespace translate 377 } // namespace translate
377 378
378 std::ostream& operator<<(std::ostream& stream, 379 std::ostream& operator<<(std::ostream& stream,
379 const translate::TranslateRankerFeatures& features) { 380 const translate::TranslateRankerFeatures& features) {
380 features.WriteTo(stream); 381 features.WriteTo(stream);
381 return stream; 382 return stream;
382 } 383 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698