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

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

Issue 2400503002: [Translate] Integrate TranslateEventProto UMA logging into TranslateManager. (Closed)
Patch Set: fix trybots Created 4 years, 1 month 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..41fc7ff5865dbba2cbc08805885ff091f37a55a4 100644
--- a/components/translate/core/browser/translate_manager.h
+++ b/components/translate/core/browser/translate_manager.h
@@ -21,6 +21,10 @@
class GURL;
class PrefService;
+namespace metrics {
+class TranslateEventProto;
+}
+
namespace translate {
extern const base::Feature kTranslateLanguageByULP;
@@ -58,6 +62,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_.get();
+ }
+
// 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 +116,11 @@ 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. |event_type| must be one of the values
+ // defined by metrics::TranslateEventProto::EventType.
+ void RecordTranslateEvent(int 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 +151,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 +167,8 @@ class TranslateManager {
LanguageState language_state_;
+ std::unique_ptr<metrics::TranslateEventProto> translate_event_;
+
base::WeakPtrFactory<TranslateManager> weak_method_factory_;
// By default, don't offer to translate in builds lacking an API key. For
« no previous file with comments | « components/metrics/proto/translate_event.proto ('k') | components/translate/core/browser/translate_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698