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

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

Issue 2890843003: Simplify TranslateRanker API. (Closed)
Patch Set: Rebase Created 3 years, 6 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_H_ 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_
6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_ 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "components/keyed_service/core/keyed_service.h" 13 #include "components/keyed_service/core/keyed_service.h"
14 14
15 class GURL; 15 class GURL;
16 16
17 namespace metrics { 17 namespace metrics {
18 class TranslateEventProto; 18 class TranslateEventProto;
19 } // namespace metrics 19 } // namespace metrics
20 20
21 namespace translate { 21 namespace translate {
22 22
23 class TranslatePrefs;
24
25 // If enabled, downloads a translate ranker model and uses it to determine 23 // If enabled, downloads a translate ranker model and uses it to determine
26 // whether the user should be given a translation prompt or not. 24 // whether the user should be given a translation prompt or not.
27 class TranslateRanker : public KeyedService { 25 class TranslateRanker : public KeyedService {
28 public: 26 public:
29 TranslateRanker() = default; 27 TranslateRanker() = default;
30 28
31 // Returns the version id for the ranker model. 29 // Returns the version id for the ranker model.
32 virtual uint32_t GetModelVersion() const = 0; 30 virtual uint32_t GetModelVersion() const = 0;
33 31
34 // Returns true if executing the ranker model in the translation prompt 32 // Returns true if executing the ranker model in the translation prompt
35 // context described by |translate_prefs|, |src_lang|, |dst_lang| and possibly 33 // context described by |translate_event| and possibly
36 // other global browser context attributes suggests that the user should be 34 // other global browser context attributes suggests that the user should be
37 // prompted as to whether translation should be performed. 35 // prompted as to whether translation should be performed.
38 // TODO(hamelphi): Take only the proto as input and extract features from it.
39 virtual bool ShouldOfferTranslation( 36 virtual bool ShouldOfferTranslation(
40 const TranslatePrefs& translate_prefs,
41 const std::string& src_lang,
42 const std::string& dst_lang,
43 metrics::TranslateEventProto* translate_event) = 0; 37 metrics::TranslateEventProto* translate_event) = 0;
44 38
45 // Transfers cached translate events to the given vector pointer and clears 39 // Transfers cached translate events to the given vector pointer and clears
46 // the cache. 40 // the cache.
47 virtual void FlushTranslateEvents( 41 virtual void FlushTranslateEvents(
48 std::vector<metrics::TranslateEventProto>* events) = 0; 42 std::vector<metrics::TranslateEventProto>* events) = 0;
49 43
50 // Record |translate_event| with the given |event_type| and |url|. 44 // Record |translate_event| with the given |event_type| and |url|.
51 // |event_type| must be one of the values defined by 45 // |event_type| must be one of the values defined by
52 // metrics::TranslateEventProto::EventType. 46 // metrics::TranslateEventProto::EventType.
(...skipping 13 matching lines...) Expand all
66 const GURL& url, 60 const GURL& url,
67 metrics::TranslateEventProto* translate_event) = 0; 61 metrics::TranslateEventProto* translate_event) = 0;
68 62
69 private: 63 private:
70 DISALLOW_COPY_AND_ASSIGN(TranslateRanker); 64 DISALLOW_COPY_AND_ASSIGN(TranslateRanker);
71 }; 65 };
72 66
73 } // namespace translate 67 } // namespace translate
74 68
75 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_ 69 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_
OLDNEW
« no previous file with comments | « components/translate/core/browser/translate_manager.cc ('k') | components/translate/core/browser/translate_ranker_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698