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

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

Issue 2400503002: [Translate] Integrate TranslateEventProto UMA logging into TranslateManager. (Closed)
Patch Set: review candidate 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
Index: components/translate/core/browser/translate_manager.h
diff --git a/components/translate/core/browser/translate_manager.h b/components/translate/core/browser/translate_manager.h
index 502474f101c0eb24279b7e0edab45881f8e22f44..69618947943a46b06a2226ea047d030944a3b817 100644
--- a/components/translate/core/browser/translate_manager.h
+++ b/components/translate/core/browser/translate_manager.h
@@ -15,6 +15,7 @@
#include "base/gtest_prod_util.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "components/metrics/proto/translate_event.pb.h"
#include "components/translate/core/browser/language_state.h"
#include "components/translate/core/common/translate_errors.h"
@@ -58,6 +59,10 @@ class TranslateManager {
// messages to the renderer.
void set_current_seq_no(int page_seq_no) { page_seq_no_ = page_seq_no; }
+ metrics::TranslateEventProto* mutable_translate_event() {
+ return &translate_event_;
+ }
+
// Returns the language to translate to. The language returned is the
// first language found in the following list that is supported by the
// translation service:
@@ -108,6 +113,10 @@ class TranslateManager {
// Gets the LanguageState associated with the TranslateManager
LanguageState& GetLanguageState();
+ // Record an event of the given |event_type| using the currently saved
+ // |translate_event_| as context.
+ void RecordTranslateEvent(metrics::TranslateEventProto::EventType event_type);
+
// By default, don't offer to translate in builds lacking an API key. For
// testing, set to true to offer anyway.
static void SetIgnoreMissingKeyForTesting(bool ignore);
@@ -138,6 +147,11 @@ class TranslateManager {
bool success,
const std::string& data);
+ // Helper function to initialize a translate event metric proto.
+ void InitTranslateEvent(const std::string& src_lang,
+ const std::string& dst_lang,
+ const TranslatePrefs& translate_prefs);
+
// Sequence number of the current page.
int page_seq_no_;
@@ -149,6 +163,8 @@ class TranslateManager {
LanguageState language_state_;
+ metrics::TranslateEventProto translate_event_;
+
base::WeakPtrFactory<TranslateManager> weak_method_factory_;
// By default, don't offer to translate in builds lacking an API key. For

Powered by Google App Engine
This is Rietveld 408576698