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 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_IMPL_H_ | 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_IMPL_H_ |
6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_IMPL_H_ | 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 } // namespace metrics | 33 } // namespace metrics |
34 | 34 |
35 namespace translate { | 35 namespace translate { |
36 | 36 |
37 class TranslatePrefs; | 37 class TranslatePrefs; |
38 | 38 |
39 // Features used to enable ranker query, enforcement and logging. Note that | 39 // Features used to enable ranker query, enforcement and logging. Note that |
40 // enabling enforcement implies (forces) enabling queries. | 40 // enabling enforcement implies (forces) enabling queries. |
41 extern const base::Feature kTranslateRankerQuery; | 41 extern const base::Feature kTranslateRankerQuery; |
42 extern const base::Feature kTranslateRankerEnforcement; | 42 extern const base::Feature kTranslateRankerEnforcement; |
43 extern const base::Feature kTranslateRankerLogging; | |
44 extern const base::Feature kTranslateRankerDecisionOverride; | 43 extern const base::Feature kTranslateRankerDecisionOverride; |
45 | 44 |
46 struct TranslateRankerFeatures { | 45 struct TranslateRankerFeatures { |
47 TranslateRankerFeatures(); | 46 TranslateRankerFeatures(); |
48 | 47 |
49 TranslateRankerFeatures(int accepted, | 48 TranslateRankerFeatures(int accepted, |
50 int denied, | 49 int denied, |
51 int ignored, | 50 int ignored, |
52 const std::string& src, | 51 const std::string& src, |
53 const std::string& dst, | 52 const std::string& dst, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 ~TranslateRankerImpl() override; | 88 ~TranslateRankerImpl() override; |
90 | 89 |
91 // Get the file path of the translate ranker model, by default with a fixed | 90 // Get the file path of the translate ranker model, by default with a fixed |
92 // name within |data_dir|. | 91 // name within |data_dir|. |
93 static base::FilePath GetModelPath(const base::FilePath& data_dir); | 92 static base::FilePath GetModelPath(const base::FilePath& data_dir); |
94 | 93 |
95 // Get the URL from which the download the translate ranker model, by default | 94 // Get the URL from which the download the translate ranker model, by default |
96 // from Finch. | 95 // from Finch. |
97 static GURL GetModelURL(); | 96 static GURL GetModelURL(); |
98 | 97 |
99 // Over-ride the default enabled/disabled state of translate event logging. | 98 // Override the default enabled/disabled state of translate event logging. |
100 void EnableLogging(bool value); | 99 void EnableLogging(bool value); |
101 | 100 |
102 // TranslateRanker... | 101 // TranslateRanker... |
103 uint32_t GetModelVersion() const override; | 102 uint32_t GetModelVersion() const override; |
104 bool ShouldOfferTranslation( | 103 bool ShouldOfferTranslation( |
105 const TranslatePrefs& translate_prefs, | 104 const TranslatePrefs& translate_prefs, |
106 const std::string& src_lang, | 105 const std::string& src_lang, |
107 const std::string& dst_lang, | 106 const std::string& dst_lang, |
108 metrics::TranslateEventProto* translate_event) override; | 107 metrics::TranslateEventProto* translate_event) override; |
109 void FlushTranslateEvents( | 108 void FlushTranslateEvents( |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 169 |
171 DISALLOW_COPY_AND_ASSIGN(TranslateRankerImpl); | 170 DISALLOW_COPY_AND_ASSIGN(TranslateRankerImpl); |
172 }; | 171 }; |
173 | 172 |
174 } // namespace translate | 173 } // namespace translate |
175 | 174 |
176 std::ostream& operator<<(std::ostream& stream, | 175 std::ostream& operator<<(std::ostream& stream, |
177 const translate::TranslateRankerFeatures& features); | 176 const translate::TranslateRankerFeatures& features); |
178 | 177 |
179 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_IMPL_H_ | 178 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_IMPL_H_ |
OLD | NEW |