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

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

Issue 1302363002: Popular sites on the NTP: Extend UMA histograms that track clicks and impressions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@filename_from_finch
Patch Set: . Created 5 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_MOST_VISITED_SITES_H_ 5 #ifndef CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_
6 #define CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ 6 #define CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_
7 7
8 #include <jni.h> 8 #include <jni.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Callback for when data is available from TopSites. 72 // Callback for when data is available from TopSites.
73 void OnMostVisitedURLsAvailable( 73 void OnMostVisitedURLsAvailable(
74 const history::MostVisitedURLList& visited_list); 74 const history::MostVisitedURLList& visited_list);
75 75
76 // Callback for when data is available from the SuggestionsService. 76 // Callback for when data is available from the SuggestionsService.
77 void OnSuggestionsProfileAvailable( 77 void OnSuggestionsProfileAvailable(
78 const suggestions::SuggestionsProfile& suggestions_profile); 78 const suggestions::SuggestionsProfile& suggestions_profile);
79 79
80 // Adds the suggestions from |popular_sites_| into |titles| and |urls|. This 80 // Adds the suggestions from |popular_sites_| into |titles| and |urls|. This
81 // might reorder |titles| and |urls| to retain the absolute positions of the 81 // might reorder |titles| and |urls| to retain the absolute positions of the
82 // popular suggestions. 82 // popular suggestions. Also updates |tile_sources_| accordingly.
83 void AddPopularSites(std::vector<base::string16>* titles, 83 void AddPopularSites(std::vector<base::string16>* titles,
84 std::vector<std::string>* urls) const; 84 std::vector<std::string>* urls);
85 85
86 // Workhorse for AddPopularSites above. Implemented as a separate static 86 // Workhorse for AddPopularSites above. Implemented as a separate static
87 // method for ease of testing. 87 // method for ease of testing.
88 static void AddPopularSitesImpl( 88 static void AddPopularSitesImpl(
89 int num_sites, 89 int num_sites,
90 std::vector<base::string16>* titles, 90 std::vector<base::string16>* titles,
91 std::vector<std::string>* urls, 91 std::vector<std::string>* urls,
92 std::vector<std::string>* tile_sources,
92 const std::vector<base::string16>& popular_titles, 93 const std::vector<base::string16>& popular_titles,
93 const std::vector<std::string>& popular_urls); 94 const std::vector<std::string>& popular_urls);
94 95
95 // Notify the Java side observer about the availability of Most Visited Urls. 96 // Notify the Java side observer about the availability of Most Visited Urls.
96 void NotifyMostVisitedURLsObserver(const std::vector<base::string16>& titles, 97 void NotifyMostVisitedURLsObserver(const std::vector<base::string16>& titles,
97 const std::vector<std::string>& urls); 98 const std::vector<std::string>& urls);
98 99
99 void OnPopularSitesAvailable(bool success); 100 void OnPopularSitesAvailable(bool success);
100 101
101 // Runs on the UI Thread. 102 // Runs on the UI Thread.
102 void OnLocalThumbnailFetched( 103 void OnLocalThumbnailFetched(
103 const GURL& url, 104 const GURL& url,
104 scoped_ptr<base::android::ScopedJavaGlobalRef<jobject>> j_callback, 105 scoped_ptr<base::android::ScopedJavaGlobalRef<jobject>> j_callback,
105 scoped_ptr<SkBitmap> bitmap); 106 scoped_ptr<SkBitmap> bitmap);
106 107
107 // Callback for when the thumbnail lookup is complete. 108 // Callback for when the thumbnail lookup is complete.
108 // Runs on the UI Thread. 109 // Runs on the UI Thread.
109 void OnObtainedThumbnail( 110 void OnObtainedThumbnail(
110 bool is_local_thumbnail, 111 bool is_local_thumbnail,
111 scoped_ptr<base::android::ScopedJavaGlobalRef<jobject>> j_callback, 112 scoped_ptr<base::android::ScopedJavaGlobalRef<jobject>> j_callback,
112 const GURL& url, 113 const GURL& url,
113 const SkBitmap* bitmap); 114 const SkBitmap* bitmap);
114 115
115 // Records specific UMA histogram metrics. 116 // Records thumbnail-related UMA histogram metrics.
116 void RecordUMAMetrics(); 117 void RecordThumbnailUMAMetrics();
118
119 // Records UMA histogram metrics related to the number of impressions.
120 void RecordImpressionUMAMetrics();
117 121
118 // history::TopSitesObserver implementation. 122 // history::TopSitesObserver implementation.
119 void TopSitesLoaded(history::TopSites* top_sites) override; 123 void TopSitesLoaded(history::TopSites* top_sites) override;
120 void TopSitesChanged(history::TopSites* top_sites, 124 void TopSitesChanged(history::TopSites* top_sites,
121 ChangeReason change_reason) override; 125 ChangeReason change_reason) override;
122 126
123 // The profile whose most visited sites will be queried. 127 // The profile whose most visited sites will be queried.
124 Profile* profile_; 128 Profile* profile_;
125 129
126 // The observer to be notified when the list of most visited sites changes. 130 // The observer to be notified when the list of most visited sites changes.
127 base::android::ScopedJavaGlobalRef<jobject> observer_; 131 base::android::ScopedJavaGlobalRef<jobject> observer_;
128 132
129 // The maximum number of most visited sites to return. 133 // The maximum number of most visited sites to return.
130 int num_sites_; 134 int num_sites_;
131 135
132 // Keeps track of whether the initial NTP load has been done. 136 // Whether we have received an initial set of most visited sites (from either
133 bool initial_load_done_; 137 // TopSites or the SuggestionsService).
138 bool received_most_visited_sites_;
Bernhard Bauer 2015/08/25 13:55:10 Can you add an empty line before each comment?
Marc Treib 2015/08/25 14:13:23 Done.
139 // Whether we have received the set of popular sites. Immediately set to true
140 // if popular sites are disabled.
141 bool received_popular_sites_;
142 // Whether we have recorded one-shot UMA metrics such as impressions. They are
143 // recorded once both the previous flags are true.
144 bool recorded_uma_;
134 145
135 // Counters for UMA metrics. 146 // Counters for UMA metrics.
136 147
137 // Number of tiles using a local thumbnail image for this NTP session. 148 // Number of tiles using a local thumbnail image for this NTP session.
138 int num_local_thumbs_; 149 int num_local_thumbs_;
139 // Number of tiles for which a server thumbnail is provided. 150 // Number of tiles for which a server thumbnail is provided.
140 int num_server_thumbs_; 151 int num_server_thumbs_;
141 // Number of tiles for which no thumbnail is found/specified. 152 // Number of tiles for which no thumbnail is found/specified.
142 // In this case a gray tile is used as the main tile. 153 // In this case a gray tile is used as the main tile.
143 int num_empty_thumbs_; 154 int num_empty_thumbs_;
144 155
145 // Copy of the server suggestions (if enabled). Used for logging. 156 // Identifier for where each tile came from (client, server, popular). Used
146 suggestions::SuggestionsProfile server_suggestions_; 157 // for logging.
158 std::vector<std::string> tile_sources_;
147 159
148 ScopedObserver<history::TopSites, history::TopSitesObserver> scoped_observer_; 160 ScopedObserver<history::TopSites, history::TopSitesObserver> scoped_observer_;
149 161
150 MostVisitedSource mv_source_; 162 MostVisitedSource mv_source_;
151 163
152 scoped_ptr<PopularSites> popular_sites_; 164 scoped_ptr<PopularSites> popular_sites_;
153 165
154 // For callbacks may be run after destruction. 166 // For callbacks may be run after destruction.
155 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_; 167 base::WeakPtrFactory<MostVisitedSites> weak_ptr_factory_;
156 168
157 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites); 169 DISALLOW_COPY_AND_ASSIGN(MostVisitedSites);
158 }; 170 };
159 171
160 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_ 172 #endif // CHROME_BROWSER_ANDROID_MOST_VISITED_SITES_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/android/most_visited_sites.cc » ('j') | chrome/browser/android/most_visited_sites.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698