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

Side by Side Diff: chrome/browser/android/logo_bridge.h

Issue 2838833005: Move NewTabPage.LogoShownTime metrics recording into LogoBridge (Closed)
Patch Set: Remove file without real changes Created 3 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ 5 #ifndef CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_
6 #define CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ 6 #define CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 17 matching lines...) Expand all
28 28
29 namespace image_fetcher { 29 namespace image_fetcher {
30 class ImageFetcher; 30 class ImageFetcher;
31 struct RequestMetadata; 31 struct RequestMetadata;
32 } // namespace image_fetcher 32 } // namespace image_fetcher
33 33
34 // The C++ counterpart to LogoBridge.java. Enables Java code to access the 34 // The C++ counterpart to LogoBridge.java. Enables Java code to access the
35 // default search provider's logo. 35 // default search provider's logo.
36 class LogoBridge : public doodle::DoodleService::Observer { 36 class LogoBridge : public doodle::DoodleService::Observer {
37 public: 37 public:
38 // Stores its creation time and writes it to a UMA histogram. Each instance
39 // writes the metric once or never.
40 class LoadTimeMetricRecorder {
tschumann 2017/04/27 06:09:17 this seems overly complicated to me. Why do we nee
fhorschig 2017/04/27 11:16:13 I moved the state out of the class. Although this
41 public:
42 // Writes the diff between |Now| and the recorders creation time to a UMA
43 // metric. If the recorder was aborted/finished before, nothing happens.
44 virtual void Finish() = 0;
45
46 // The recorder instance immediately stops to record.
47 virtual void Abort() = 0;
48
49 // The recorder waits for a pending result.
50 virtual void WaitForResult() = 0;
51
52 // Unless the recorder is waiting for a result, |Abort| will be called.
53 virtual void AbortIfNotWaiting() = 0;
54 };
55
38 explicit LogoBridge(jobject j_profile); 56 explicit LogoBridge(jobject j_profile);
39 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); 57 void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj);
40 58
41 // Gets the current non-animated logo (downloading it if necessary) and passes 59 // Gets the current non-animated logo (downloading it if necessary) and passes
42 // it to the observer. 60 // it to the observer.
43 void GetCurrentLogo( 61 void GetCurrentLogo(
44 JNIEnv* env, 62 JNIEnv* env,
45 const base::android::JavaParamRef<jobject>& obj, 63 const base::android::JavaParamRef<jobject>& obj,
46 const base::android::JavaParamRef<jobject>& j_logo_observer); 64 const base::android::JavaParamRef<jobject>& j_logo_observer);
47 65
(...skipping 20 matching lines...) Expand all
68 bool from_cache); 86 bool from_cache);
69 87
70 void DoodleImageFetched(bool config_from_cache, 88 void DoodleImageFetched(bool config_from_cache,
71 const GURL& on_click_url, 89 const GURL& on_click_url,
72 const std::string& alt_text, 90 const std::string& alt_text,
73 const GURL& animated_image_url, 91 const GURL& animated_image_url,
74 const std::string& image_fetch_id, 92 const std::string& image_fetch_id,
75 const gfx::Image& image, 93 const gfx::Image& image,
76 const image_fetcher::RequestMetadata& metadata); 94 const image_fetcher::RequestMetadata& metadata);
77 95
96 // Returns the currently running LoadTimeRecorder. If there is none, a null
97 // object is returned.
98 LoadTimeMetricRecorder* load_time_recorder();
99
78 // Only valid if UseNewDoodleApi is disabled. 100 // Only valid if UseNewDoodleApi is disabled.
79 LogoService* logo_service_; 101 LogoService* logo_service_;
80 102
81 // Only valid if UseNewDoodleApi is enabled. 103 // Only valid if UseNewDoodleApi is enabled.
82 doodle::DoodleService* doodle_service_; 104 doodle::DoodleService* doodle_service_;
83 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_; 105 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher_;
84 base::android::ScopedJavaGlobalRef<jobject> j_logo_observer_; 106 base::android::ScopedJavaGlobalRef<jobject> j_logo_observer_;
85 ScopedObserver<doodle::DoodleService, doodle::DoodleService::Observer> 107 ScopedObserver<doodle::DoodleService, doodle::DoodleService::Observer>
86 doodle_observer_; 108 doodle_observer_;
87 109
88 std::unique_ptr<AnimatedLogoFetcher> animated_logo_fetcher_; 110 std::unique_ptr<AnimatedLogoFetcher> animated_logo_fetcher_;
89 111
112 std::unique_ptr<LoadTimeMetricRecorder> load_time_recorder_;
113
90 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_; 114 base::WeakPtrFactory<LogoBridge> weak_ptr_factory_;
91 115
92 DISALLOW_COPY_AND_ASSIGN(LogoBridge); 116 DISALLOW_COPY_AND_ASSIGN(LogoBridge);
93 }; 117 };
94 118
95 bool RegisterLogoBridge(JNIEnv* env); 119 bool RegisterLogoBridge(JNIEnv* env);
96 120
97 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_ 121 #endif // CHROME_BROWSER_ANDROID_LOGO_BRIDGE_H_
OLDNEW
« 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