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

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

Issue 2632503005: predictors: Collect page load metrics for ResourcePrefetchPredictor. (Closed)
Patch Set: Mark suffix as base. 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin); 165 void StartPrefetching(const GURL& main_frame_url, PrefetchOrigin origin);
166 166
167 // Stops prefetching that may be in progress corresponding to 167 // Stops prefetching that may be in progress corresponding to
168 // |main_frame_url|. 168 // |main_frame_url|.
169 void StopPrefetching(const GURL& main_frame_url); 169 void StopPrefetching(const GURL& main_frame_url);
170 170
171 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending 171 // Called when ResourcePrefetcher is finished, i.e. there is nothing pending
172 // in flight. 172 // in flight.
173 void OnPrefetchingFinished(const GURL& main_frame_url); 173 void OnPrefetchingFinished(const GURL& main_frame_url);
174 174
175 // Returns true if prefetching data exists for the |main_frame_url|.
176 virtual bool IsUrlPrefetchable(const GURL& main_frame_url);
177
175 // Sets the |observer| to be notified when the resource prefetch predictor 178 // Sets the |observer| to be notified when the resource prefetch predictor
176 // data changes. Previously registered observer will be discarded. Call 179 // data changes. Previously registered observer will be discarded. Call
177 // this with nullptr parameter to de-register observer. 180 // this with nullptr parameter to de-register observer.
178 void SetObserverForTesting(TestObserver* observer); 181 void SetObserverForTesting(TestObserver* observer);
179 182
180 private: 183 private:
181 friend class ::PredictorsHandler; 184 friend class ::PredictorsHandler;
182 friend class ResourcePrefetchPredictorTest; 185 friend class ResourcePrefetchPredictorTest;
183 friend class ResourcePrefetchPredictorBrowserTest; 186 friend class ResourcePrefetchPredictorBrowserTest;
184 187
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 void OnMainFrameRedirect(const URLRequestSummary& response); 253 void OnMainFrameRedirect(const URLRequestSummary& response);
251 void OnSubresourceResponse(const URLRequestSummary& response); 254 void OnSubresourceResponse(const URLRequestSummary& response);
252 255
253 // Called when onload completes for a navigation. We treat this point as the 256 // Called when onload completes for a navigation. We treat this point as the
254 // "completion" of the navigation. The resources requested by the page up to 257 // "completion" of the navigation. The resources requested by the page up to
255 // this point are the only ones considered for prefetching. 258 // this point are the only ones considered for prefetching.
256 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info); 259 void OnNavigationComplete(const NavigationID& nav_id_without_timing_info);
257 260
258 // Returns true iff there is PrefetchData that can be used for a 261 // Returns true iff there is PrefetchData that can be used for a
259 // |main_frame_url| and fills |urls| with resources that need to be 262 // |main_frame_url| and fills |urls| with resources that need to be
260 // prefetched. 263 // prefetched. |urls| pointer may be equal nullptr to get return value only.
261 bool GetPrefetchData(const GURL& main_frame_url, std::vector<GURL>* urls); 264 bool GetPrefetchData(const GURL& main_frame_url,
265 std::vector<GURL>* urls) const;
262 266
263 // Returns true iff the |data_map| contains PrefetchData that can be used 267 // Returns true iff the |data_map| contains PrefetchData that can be used
264 // for a |main_frame_key| and fills |urls| with resources that need to be 268 // for a |main_frame_key| and fills |urls| with resources that need to be
265 // prefetched. 269 // prefetched. |urls| pointer may be equal nullptr to get return value only.
266 bool PopulatePrefetcherRequest(const std::string& main_frame_key, 270 bool PopulatePrefetcherRequest(const std::string& main_frame_key,
267 const PrefetchDataMap& data_map, 271 const PrefetchDataMap& data_map,
268 std::vector<GURL>* urls); 272 std::vector<GURL>* urls) const;
269 273
270 // Callback for task to read predictor database. Takes ownership of 274 // Callback for task to read predictor database. Takes ownership of
271 // all arguments. 275 // all arguments.
272 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map, 276 void CreateCaches(std::unique_ptr<PrefetchDataMap> url_data_map,
273 std::unique_ptr<PrefetchDataMap> host_data_map, 277 std::unique_ptr<PrefetchDataMap> host_data_map,
274 std::unique_ptr<RedirectDataMap> url_redirect_data_map, 278 std::unique_ptr<RedirectDataMap> url_redirect_data_map,
275 std::unique_ptr<RedirectDataMap> host_redirect_data_map); 279 std::unique_ptr<RedirectDataMap> host_redirect_data_map);
276 280
277 // Called during initialization when history is read and the predictor 281 // Called during initialization when history is read and the predictor
278 // database has been read. 282 // database has been read.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 RedirectDataMap* redirect_map); 317 RedirectDataMap* redirect_map);
314 318
315 // Updates information about final redirect destination for |key| in 319 // Updates information about final redirect destination for |key| in
316 // |redirect_map| and correspondingly updates the predictor database. 320 // |redirect_map| and correspondingly updates the predictor database.
317 void LearnRedirect(const std::string& key, 321 void LearnRedirect(const std::string& key,
318 PrefetchKeyType key_type, 322 PrefetchKeyType key_type,
319 const std::string& final_redirect, 323 const std::string& final_redirect,
320 size_t max_redirect_map_size, 324 size_t max_redirect_map_size,
321 RedirectDataMap* redirect_map); 325 RedirectDataMap* redirect_map);
322 326
323 // Returns true iff the |data_map| contains PrefetchData that can be used
324 // for |main_frame_key| prefetching.
325 bool IsDataPrefetchable(const std::string& main_frame_key,
326 const PrefetchDataMap& data_map) const;
327
328 // Returns true iff |resource| has sufficient confidence level and required 327 // Returns true iff |resource| has sufficient confidence level and required
329 // number of hits. 328 // number of hits.
330 bool IsResourcePrefetchable(const ResourceData& resource) const; 329 bool IsResourcePrefetchable(const ResourceData& resource) const;
331 330
332 // Reports database readiness metric defined as percentage of navigated hosts 331 // Reports database readiness metric defined as percentage of navigated hosts
333 // found in DB for last X entries in history. 332 // found in DB for last X entries in history.
334 void ReportDatabaseReadiness(const history::TopHostsList& top_hosts) const; 333 void ReportDatabaseReadiness(const history::TopHostsList& top_hosts) const;
335 334
336 // history::HistoryServiceObserver: 335 // history::HistoryServiceObserver:
337 void OnURLsDeleted(history::HistoryService* history_service, 336 void OnURLsDeleted(history::HistoryService* history_service,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 394
396 private: 395 private:
397 ResourcePrefetchPredictor* predictor_; 396 ResourcePrefetchPredictor* predictor_;
398 397
399 DISALLOW_COPY_AND_ASSIGN(TestObserver); 398 DISALLOW_COPY_AND_ASSIGN(TestObserver);
400 }; 399 };
401 400
402 } // namespace predictors 401 } // namespace predictors
403 402
404 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_ 403 #endif // CHROME_BROWSER_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698