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

Side by Side Diff: components/precache/content/precache_manager.h

Issue 2146023003: Add UMA Precache.Freshness.Prefetch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed the histogram summary Created 4 years, 5 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 COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ 5 #ifndef COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_
6 #define COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ 6 #define COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <list> 11 #include <list>
12 #include <memory> 12 #include <memory>
13 #include <string> 13 #include <string>
14 #include <utility> 14 #include <utility>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/compiler_specific.h" 18 #include "base/compiler_specific.h"
19 #include "base/macros.h" 19 #include "base/macros.h"
20 #include "base/memory/weak_ptr.h" 20 #include "base/memory/weak_ptr.h"
21 #include "components/history/core/browser/history_types.h" 21 #include "components/history/core/browser/history_types.h"
22 #include "components/keyed_service/core/keyed_service.h" 22 #include "components/keyed_service/core/keyed_service.h"
23 #include "components/precache/core/precache_fetcher.h" 23 #include "components/precache/core/precache_fetcher.h"
24 #include "net/http/http_response_info.h"
bengr 2016/07/21 00:03:27 Forward declare instead.
jamartin 2016/07/25 23:23:07 Done. Nice! This should get rid of the change in
24 #include "url/gurl.h" 25 #include "url/gurl.h"
25 26
26 namespace base { 27 namespace base {
27 class FilePath; 28 class FilePath;
28 class Time; 29 class Time;
29 class TimeDelta; 30 class TimeDelta;
30 } 31 }
31 32
32 namespace content { 33 namespace content {
33 class BrowserContext; 34 class BrowserContext;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // database. Does not wait for completion of this task. 102 // database. Does not wait for completion of this task.
102 void ClearHistory(); 103 void ClearHistory();
103 104
104 // Update precache about an URL being fetched. Metrics related to precache are 105 // Update precache about an URL being fetched. Metrics related to precache are
105 // updated and any ongoing precache will be cancelled if this is an user 106 // updated and any ongoing precache will be cancelled if this is an user
106 // initiated request. Should be called on UI thread. 107 // initiated request. Should be called on UI thread.
107 void UpdatePrecacheMetricsAndState(const GURL& url, 108 void UpdatePrecacheMetricsAndState(const GURL& url,
108 const GURL& referrer, 109 const GURL& referrer,
109 const base::TimeDelta& latency, 110 const base::TimeDelta& latency,
110 const base::Time& fetch_time, 111 const base::Time& fetch_time,
112 const net::HttpResponseInfo& info,
111 int64_t size, 113 int64_t size,
112 bool was_cached,
113 bool is_user_traffic); 114 bool is_user_traffic);
114 115
115 private: 116 private:
116 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, DeleteExpiredPrecacheHistory); 117 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, DeleteExpiredPrecacheHistory);
117 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, 118 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest,
118 RecordStatsForFetchDuringPrecaching); 119 RecordStatsForFetchDuringPrecaching);
119 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, RecordStatsForFetchHTTP); 120 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, RecordStatsForFetchHTTP);
120 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, RecordStatsForFetchHTTPS); 121 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, RecordStatsForFetchHTTPS);
121 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, RecordStatsForFetchInTopHosts); 122 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, RecordStatsForFetchInTopHosts);
122 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest, 123 FRIEND_TEST_ALL_PREFIXES(PrecacheManagerTest,
(...skipping 29 matching lines...) Expand all
152 void OnHostsReceivedThenDone(const history::TopHostsList& host_counts); 153 void OnHostsReceivedThenDone(const history::TopHostsList& host_counts);
153 154
154 // Returns true if precaching is allowed for the browser context. 155 // Returns true if precaching is allowed for the browser context.
155 AllowedType PrecachingAllowed() const; 156 AllowedType PrecachingAllowed() const;
156 157
157 // Update precache-related metrics in response to a URL being fetched. 158 // Update precache-related metrics in response to a URL being fetched.
158 void RecordStatsForFetch(const GURL& url, 159 void RecordStatsForFetch(const GURL& url,
159 const GURL& referrer, 160 const GURL& referrer,
160 const base::TimeDelta& latency, 161 const base::TimeDelta& latency,
161 const base::Time& fetch_time, 162 const base::Time& fetch_time,
162 int64_t size, 163 const net::HttpResponseInfo& info,
163 bool was_cached); 164 int64_t size);
164 165
165 // Update precache-related metrics in response to a URL being fetched. Called 166 // Update precache-related metrics in response to a URL being fetched. Called
166 // by RecordStatsForFetch() by way of an asynchronous HistoryService callback. 167 // by RecordStatsForFetch() by way of an asynchronous HistoryService callback.
167 void RecordStatsForFetchInternal(const GURL& url, 168 void RecordStatsForFetchInternal(const GURL& url,
168 const base::TimeDelta& latency, 169 const base::TimeDelta& latency,
169 const base::Time& fetch_time, 170 const base::Time& fetch_time,
171 const net::HttpResponseInfo& info,
170 int64_t size, 172 int64_t size,
171 bool was_cached,
172 int host_rank); 173 int host_rank);
173 174
174 // The browser context that owns this PrecacheManager. 175 // The browser context that owns this PrecacheManager.
175 content::BrowserContext* const browser_context_; 176 content::BrowserContext* const browser_context_;
176 177
177 // The sync service corresponding to the browser context. Used to determine 178 // The sync service corresponding to the browser context. Used to determine
178 // whether precache can run. May be null. 179 // whether precache can run. May be null.
179 const sync_driver::SyncService* const sync_service_; 180 const sync_driver::SyncService* const sync_service_;
180 181
181 // The history service corresponding to the browser context. Used to determine 182 // The history service corresponding to the browser context. Used to determine
(...skipping 17 matching lines...) Expand all
199 200
200 // Work that hasn't yet finished. 201 // Work that hasn't yet finished.
201 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_; 202 std::unique_ptr<PrecacheUnfinishedWork> unfinished_work_;
202 203
203 DISALLOW_COPY_AND_ASSIGN(PrecacheManager); 204 DISALLOW_COPY_AND_ASSIGN(PrecacheManager);
204 }; 205 };
205 206
206 } // namespace precache 207 } // namespace precache
207 208
208 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_ 209 #endif // COMPONENTS_PRECACHE_CONTENT_PRECACHE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698