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

Side by Side Diff: chrome/browser/predictors/resource_prefetch_predictor.h

Issue 2632503005: predictors: Collect page load metrics for ResourcePrefetchPredictor. (Closed)
Patch Set: Created 3 years, 11 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_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 5 #ifndef CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 6 #define CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin); 158 void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin);
159 159
160 // Stops prefetching that may be in progress corresponding to 160 // Stops prefetching that may be in progress corresponding to
161 // |main_frame_url|. 161 // |main_frame_url|.
162 void StopPrefetching(const GURL& main_frame_url); 162 void StopPrefetching(const GURL& main_frame_url);
163 163
164 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending 164 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending
165 // in flight. 165 // in flight.
166 void OnPrefetchingFinished(const GURL& main_frame_url); 166 void OnPrefetchingFinished(const GURL& main_frame_url);
167 167
168 // Returns true if prefetching data exists for the |main_frame_url|.
169 virtual bool IsUrlPrefetchable(const GURL& main_frame_url);
170
168 // Sets the |observer| to be notified when the resource prefetch predictor 171 // Sets the |observer| to be notified when the resource prefetch predictor
169 // data changes. Previously registered observer will be discarded. Call 172 // data changes. Previously registered observer will be discarded. Call
170 // this with nullptr parameter to de-register observer. 173 // this with nullptr parameter to de-register observer.
171 void SetObserverForTesting(TestObserver* observer); 174 void SetObserverForTesting(TestObserver* observer);
172 175
173 private: 176 private:
174 friend class ::PredictorsHandler; 177 friend class ::PredictorsHandler;
175 friend class ResourcePrefetchPredictorTest; 178 friend class ResourcePrefetchPredictorTest;
176 friend class ResourcePrefetchPredictorBrowserTest; 179 friend class ResourcePrefetchPredictorBrowserTest;
177 180
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 void OnMainFrameRedirect(const URLRequestSummary& response); 244 void OnMainFrameRedirect(const URLRequestSummary& response);
242 void OnSubresourceResponse(const URLRequestSummary& response); 245 void OnSubresourceResponse(const URLRequestSummary& response);
243 246
244 // Called when onload completes for a navigation. We treat this point as the 247 // Called when onload completes for a navigation. We treat this point as the
245 // "completion" of the navigation. The resources requested by the page up to 248 // "completion" of the navigation. The resources requested by the page up to
246 // this point are the only ones considered for prefetching. 249 // this point are the only ones considered for prefetching.
247 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info); 250 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info);
248 251
249 // Returns true iff there is PrefetchData that can be used for a 252 // Returns true iff there is PrefetchData that can be used for a
250 // |main_frame_url| and fills |urls| with resources that need to be 253 // |main_frame_url| and fills |urls| with resources that need to be
251 // prefetched. 254 // prefetched. |urls| pointer may be equal nullptr to get return value only.
252 bool GetPrefetchData(const GURL& main_frame_url, std::vector<GURL>* urls); 255 bool GetPrefetchData(const GURL& main_frame_url,
256 std::vector<GURL>* urls) const;
253 257
254 // Returns true iff the |data_map| contains PrefetchData that can be used 258 // Returns true iff the |data_map| contains PrefetchData that can be used
255 // for a |main_frame_key| and fills |urls| with resources that need to be 259 // for a |main_frame_key| and fills |urls| with resources that need to be
256 // prefetched. 260 // prefetched. |urls| pointer may be equal nullptr to get return value only.
257 bool PopulatePrefetcherRequest(const std::string& main_frame_key, 261 bool PopulatePrefetcherRequest(const std::string& main_frame_key,
258 const PrefetchDataMap& data_map, 262 const PrefetchDataMap& data_map,
259 std::vector<GURL>* urls); 263 std::vector<GURL>* urls) const;
260 264
261 // Callback for task to read predictor database. Takes ownership of 265 // Callback for task to read predictor database. Takes ownership of
262 // all arguments. 266 // all arguments.
263 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, 267 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map,
264 std::unique_ptr<PrefetchDataMap> host_data_map, 268 std::unique_ptr<PrefetchDataMap> host_data_map,
265 std::unique_ptr<RedirectDataMap> url_redirect_data_map, 269 std::unique_ptr<RedirectDataMap> url_redirect_data_map,
266 std::unique_ptr<RedirectDataMap> host_redirect_data_map); 270 std::unique_ptr<RedirectDataMap> host_redirect_data_map);
267 271
268 // Called during initialization when history is read and the predictor 272 // Called during initialization when history is read and the predictor
269 // database has been read. 273 // database has been read.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 RedirectDataMap* redirect_map); 308 RedirectDataMap* redirect_map);
305 309
306 // Updates information about final redirect destination for |key| in 310 // Updates information about final redirect destination for |key| in
307 // |redirect_map| and correspondingly updates the predictor database. 311 // |redirect_map| and correspondingly updates the predictor database.
308 void LearnRedirect(const std::string& key, 312 void LearnRedirect(const std::string& key,
309 PrefetchKeyType key_type, 313 PrefetchKeyType key_type,
310 const std::string& final_redirect, 314 const std::string& final_redirect,
311 size_t max_redirect_map_size, 315 size_t max_redirect_map_size,
312 RedirectDataMap* redirect_map); 316 RedirectDataMap* redirect_map);
313 317
314 // Returns true iff the |data_map| contains PrefetchData that can be used
315 // for |main_frame_key| prefetching.
316 bool IsDataPrefetchable(const std::string& main_frame_key,
317 const PrefetchDataMap& data_map) const;
318
319 // Returns true iff |resource| has sufficient confidence level and required 318 // Returns true iff |resource| has sufficient confidence level and required
320 // number of hits. 319 // number of hits.
321 bool IsResourcePrefetchable(const ResourceData& resource) const; 320 bool IsResourcePrefetchable(const ResourceData& resource) const;
322 321
323 // Reports database readiness metric defined as percentage of navigated hosts 322 // Reports database readiness metric defined as percentage of navigated hosts
324 // found in DB for last X entries in history. 323 // found in DB for last X entries in history.
325 void ReportDatabaseReadiness(const history::TopHostsList& top_hosts) const; 324 void ReportDatabaseReadiness(const history::TopHostsList& top_hosts) const;
326 325
327 // history::HistoryServiceObserver: 326 // history::HistoryServiceObserver:
328 void OnURLsDeleted(history::HistoryService* history_service, 327 void OnURLsDeleted(history::HistoryService* history_service,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 385
387 private: 386 private:
388 ResourcePrefetchPredictor* predictor_; 387 ResourcePrefetchPredictor* predictor_;
389 388
390 DISALLOW_COPY_AND_ASSIGN(TestObserver); 389 DISALLOW_COPY_AND_ASSIGN(TestObserver);
391 }; 390 };
392 391
393 } // namespace predictors 392 } // namespace predictors
394 393
395 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 394 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698