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

Unified Diff: chrome/browser/android/logo_bridge.h

Issue 2838833005: Move NewTabPage.LogoShownTime metrics recording into LogoBridge (Closed)
Patch Set: Remove state from LoadTimeMetricsRecorder Created 3 years, 8 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: chrome/browser/android/logo_bridge.h
diff --git a/chrome/browser/android/logo_bridge.h b/chrome/browser/android/logo_bridge.h
index 89f5f48b12a3ecf1dbc0e09e08098b45d4aee407..1c0f5b1e04bf285202f9c2de7cae6790b4a601e2 100644
--- a/chrome/browser/android/logo_bridge.h
+++ b/chrome/browser/android/logo_bridge.h
@@ -35,6 +35,18 @@ struct RequestMetadata;
// default search provider's logo.
class LogoBridge : public doodle::DoodleService::Observer {
public:
+ // Stores its creation time and writes it to a UMA histogram. Each instance
+ // writes the metric once or never.
+ class LoadTimeMetricRecorder {
+ public:
+ // Writes the diff between |Now| and the recorders creation time to a UMA
+ // metric. If the recorder was aborted/finished before, nothing happens.
+ virtual void Finish() = 0;
+
+ // The recorder instance immediately stops to record.
+ virtual void Cancel() = 0;
+ };
+
explicit LogoBridge(jobject j_profile);
void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
@@ -63,7 +75,9 @@ class LogoBridge : public doodle::DoodleService::Observer {
void OnDoodleConfigUpdated(
const base::Optional<doodle::DoodleConfig>& maybe_doodle_config) override;
- void DoodleConfigReceived(
+ // Takes a config and loads the image for it. Returns true if the image is
+ // loading.
+ bool DoodleConfigReceived(
const base::Optional<doodle::DoodleConfig>& maybe_doodle_config,
bool from_cache);
@@ -75,6 +89,10 @@ class LogoBridge : public doodle::DoodleService::Observer {
const gfx::Image& image,
const image_fetcher::RequestMetadata& metadata);
+ // Returns the currently running LoadTimeRecorder. If there is none, a null
+ // object is returned.
+ LoadTimeMetricRecorder* load_time_recorder();
+
// Only valid if UseNewDoodleApi is disabled.
LogoService* logo_service_;
@@ -87,6 +105,8 @@ class LogoBridge : public doodle::DoodleService::Observer {
std::unique_ptr<AnimatedLogoFetcher> animated_logo_fetcher_;
+ std::unique_ptr<LoadTimeMetricRecorder> load_time_recorder_;
+
base::WeakPtrFactory<LogoBridge> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(LogoBridge);
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/ntp/LogoDelegateImpl.java ('k') | chrome/browser/android/logo_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698