Chromium Code Reviews| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 176 kTranslateRankerQuery, switches::kTranslateRankerModelURL); | 176 kTranslateRankerQuery, switches::kTranslateRankerModelURL); |
| 177 } | 177 } |
| 178 | 178 |
| 179 DVLOG(3) << switches::kTranslateRankerModelURL << " = " << raw_url; | 179 DVLOG(3) << switches::kTranslateRankerModelURL << " = " << raw_url; |
| 180 | 180 |
| 181 return GURL(raw_url); | 181 return GURL(raw_url); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void TranslateRankerImpl::EnableLogging(bool value) { | 184 void TranslateRankerImpl::EnableLogging(bool value) { |
| 185 is_logging_enabled_ = value; | 185 is_logging_enabled_ = value; |
| 186 if (!is_logging_enabled_) | |
|
groby-ooo-7-16
2017/06/07 16:27:21
Don't you want to clear on every edge transition?
hamelphi
2017/06/08 20:27:58
Good point. Done.
| |
| 187 event_cache_.clear(); | |
| 186 } | 188 } |
| 187 | 189 |
| 188 uint32_t TranslateRankerImpl::GetModelVersion() const { | 190 uint32_t TranslateRankerImpl::GetModelVersion() const { |
| 189 return model_ ? model_->proto().translate().version() : 0; | 191 return model_ ? model_->proto().translate().version() : 0; |
| 190 } | 192 } |
| 191 | 193 |
| 192 bool TranslateRankerImpl::ShouldOfferTranslation( | 194 bool TranslateRankerImpl::ShouldOfferTranslation( |
| 193 metrics::TranslateEventProto* translate_event) { | 195 metrics::TranslateEventProto* translate_event) { |
| 194 DCHECK(sequence_checker_.CalledOnValidSequence()); | 196 DCHECK(sequence_checker_.CalledOnValidSequence()); |
| 195 // The ranker is a gate in the "show a translation prompt" flow. To retain | 197 // The ranker is a gate in the "show a translation prompt" flow. To retain |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 } | 367 } |
| 366 } | 368 } |
| 367 | 369 |
| 368 } // namespace translate | 370 } // namespace translate |
| 369 | 371 |
| 370 std::ostream& operator<<(std::ostream& stream, | 372 std::ostream& operator<<(std::ostream& stream, |
| 371 const translate::TranslateRankerFeatures& features) { | 373 const translate::TranslateRankerFeatures& features) { |
| 372 features.WriteTo(stream); | 374 features.WriteTo(stream); |
| 373 return stream; | 375 return stream; |
| 374 } | 376 } |
| OLD | NEW |