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

Unified Diff: components/translate/core/browser/translate_ranker.h

Issue 2395253002: Send TranslateEventProtos to UMA. (Closed)
Patch Set: Remove Record interface from client. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/translate/core/browser/BUILD.gn ('k') | components/translate/core/browser/translate_ranker.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/translate/core/browser/translate_ranker.h
diff --git a/components/translate/core/browser/translate_ranker.h b/components/translate/core/browser/translate_ranker.h
index 6444b9b62d9ed25c0fcb7ff19643d1d40129401b..8687c80ca1dfc26ac80d7fd54d88d5ca4f42a2a2 100644
--- a/components/translate/core/browser/translate_ranker.h
+++ b/components/translate/core/browser/translate_ranker.h
@@ -16,16 +16,21 @@ namespace chrome_intelligence {
class TranslateRankerModel;
}
+namespace metrics {
+class TranslateEventProto;
+}
+
namespace translate {
class TranslatePrefs;
class TranslateRankerMetricsProvider;
class TranslateURLFetcher;
-// Features used to enable ranker query and enforcement. Note that enabling
-// enforcement implies (forces) enabling queries.
+// Features used to enable ranker query, enforcement and logging. Note that
+// enabling enforcement implies (forces) enabling queries.
extern const base::Feature kTranslateRankerQuery;
extern const base::Feature kTranslateRankerEnforcement;
+extern const base::Feature kTranslateRankerLogging;
// If enabled, downloads a translate ranker model and uses it to determine
// whether the user should be given a translation prompt or not.
@@ -36,6 +41,9 @@ class TranslateRanker {
// Returns true if query or enforcement is enabled.
static bool IsEnabled();
+ // Returns true if translate events logging is enabled.
+ static bool IsLoggingEnabled();
+
// Returns the singleton TranslateRanker instance.
static TranslateRanker* GetInstance();
@@ -59,6 +67,15 @@ class TranslateRanker {
// Returns the model version (a date stamp) or 0 if there is no valid model.
int GetModelVersion() const;
+ // Caches the translate event.
+ void RecordTranslateEvent(
+ const metrics::TranslateEventProto& translate_event);
+
+ // Transfers cached translate events to the given vector pointer and clears
+ // the cache.
+ void FlushTranslateEvents(
+ std::vector<metrics::TranslateEventProto>* translate_events);
+
private:
// The ID which is assigned to the underlying URLFetcher.
static constexpr int kFetcherId = 2;
@@ -91,6 +108,9 @@ class TranslateRanker {
// Used for UMA reporting of timing.
base::Time download_start_time_;
+ // Saved cache of translate event protos.
+ std::vector<metrics::TranslateEventProto> translate_events_cache_;
+
FRIEND_TEST_ALL_PREFIXES(TranslateRankerTest, CalculateScore);
friend struct base::DefaultSingletonTraits<TranslateRanker>;
« no previous file with comments | « components/translate/core/browser/BUILD.gn ('k') | components/translate/core/browser/translate_ranker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698