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

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

Issue 2893943004: Refactor UKM interface for mojo-ification (Closed)
Patch Set: Fixed contextualsearch Created 3 years, 7 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 #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
11 #include "base/feature_list.h" 11 #include "base/feature_list.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/sequence_checker.h" 14 #include "base/sequence_checker.h"
15 #include "base/sequenced_task_runner.h" 15 #include "base/sequenced_task_runner.h"
16 #include "components/keyed_service/core/keyed_service.h" 16 #include "components/keyed_service/core/keyed_service.h"
17 #include "components/translate/core/browser/ranker_model_loader.h" 17 #include "components/translate/core/browser/ranker_model_loader.h"
18 #include "components/translate/core/browser/translate_ranker.h" 18 #include "components/translate/core/browser/translate_ranker.h"
19 #include "url/gurl.h" 19 #include "url/gurl.h"
20 20
21 class GURL; 21 class GURL;
22 22
23 namespace chrome_intelligence { 23 namespace chrome_intelligence {
24 class RankerModel; 24 class RankerModel;
25 } // namespace chrome_intelligence 25 } // namespace chrome_intelligence
26 26
27 namespace ukm { 27 namespace ukm {
28 class UkmService; 28 class UkmRecorder;
29 } // namespace ukm 29 } // namespace ukm
30 30
31 namespace metrics { 31 namespace metrics {
32 class TranslateEventProto; 32 class TranslateEventProto;
33 } // namespace metrics 33 } // namespace metrics
34 34
35 namespace translate { 35 namespace translate {
36 36
37 class TranslatePrefs; 37 class TranslatePrefs;
38 38
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 double denied_ratio; 77 double denied_ratio;
78 double ignored_ratio; 78 double ignored_ratio;
79 }; 79 };
80 80
81 // If enabled, downloads a translate ranker model and uses it to determine 81 // If enabled, downloads a translate ranker model and uses it to determine
82 // whether the user should be given a translation prompt or not. 82 // whether the user should be given a translation prompt or not.
83 class TranslateRankerImpl : public TranslateRanker { 83 class TranslateRankerImpl : public TranslateRanker {
84 public: 84 public:
85 TranslateRankerImpl(const base::FilePath& model_path, 85 TranslateRankerImpl(const base::FilePath& model_path,
86 const GURL& model_url, 86 const GURL& model_url,
87 ukm::UkmService* ukm_service); 87 ukm::UkmRecorder* ukm_recorder);
88 ~TranslateRankerImpl() override; 88 ~TranslateRankerImpl() override;
89 89
90 // 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
91 // name within |data_dir|. 91 // name within |data_dir|.
92 static base::FilePath GetModelPath(const base::FilePath& data_dir); 92 static base::FilePath GetModelPath(const base::FilePath& data_dir);
93 93
94 // 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
95 // from Finch. 95 // from Finch.
96 static GURL GetModelURL(); 96 static GURL GetModelURL();
97 97
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 129
130 private: 130 private:
131 void SendEventToUKM(const metrics::TranslateEventProto& translate_event, 131 void SendEventToUKM(const metrics::TranslateEventProto& translate_event,
132 const GURL& url); 132 const GURL& url);
133 133
134 // Caches the translate event. 134 // Caches the translate event.
135 void AddTranslateEvent(const metrics::TranslateEventProto& translate_event, 135 void AddTranslateEvent(const metrics::TranslateEventProto& translate_event,
136 const GURL& url); 136 const GURL& url);
137 137
138 // Used to log URL-keyed metrics. This pointer will outlive |this|. 138 // Used to log URL-keyed metrics. This pointer will outlive |this|.
139 ukm::UkmService* ukm_service_; 139 ukm::UkmRecorder* ukm_recorder_;
140 140
141 // Used to sanity check the threading of this ranker. 141 // Used to sanity check the threading of this ranker.
142 base::SequenceChecker sequence_checker_; 142 base::SequenceChecker sequence_checker_;
143 143
144 // A helper to load the translate ranker model from disk cache or a URL. 144 // A helper to load the translate ranker model from disk cache or a URL.
145 std::unique_ptr<RankerModelLoader> model_loader_; 145 std::unique_ptr<RankerModelLoader> model_loader_;
146 146
147 // The translation ranker model. 147 // The translation ranker model.
148 std::unique_ptr<chrome_intelligence::RankerModel> model_; 148 std::unique_ptr<chrome_intelligence::RankerModel> model_;
149 149
(...skipping 20 matching lines...) Expand all
170 170
171 DISALLOW_COPY_AND_ASSIGN(TranslateRankerImpl); 171 DISALLOW_COPY_AND_ASSIGN(TranslateRankerImpl);
172 }; 172 };
173 173
174 } // namespace translate 174 } // namespace translate
175 175
176 std::ostream& operator<<(std::ostream& stream, 176 std::ostream& operator<<(std::ostream& stream,
177 const translate::TranslateRankerFeatures& features); 177 const translate::TranslateRankerFeatures& features);
178 178
179 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_IMPL_H_ 179 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_IMPL_H_
OLDNEW
« no previous file with comments | « components/payments/core/test_payment_request_delegate.cc ('k') | components/translate/core/browser/translate_ranker_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698