Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_PRERENDER_PRERENDER_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
| 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 209 bool is_main_resource, | 209 bool is_main_resource, |
| 210 bool is_redirect, | 210 bool is_redirect, |
| 211 bool is_no_store); | 211 bool is_no_store); |
| 212 | 212 |
| 213 // Called when a NoStatePrefetch resource has been loaded. This is called only | 213 // Called when a NoStatePrefetch resource has been loaded. This is called only |
| 214 // once per resource, when all redirects have been resolved. | 214 // once per resource, when all redirects have been resolved. |
| 215 void RecordPrefetchRedirectCount(Origin origin, | 215 void RecordPrefetchRedirectCount(Origin origin, |
| 216 bool is_main_resource, | 216 bool is_main_resource, |
| 217 int redirect_count); | 217 int redirect_count); |
| 218 | 218 |
| 219 // Records the time to first contentful paint. | |
| 220 // |is_no_store| must be true if the main resource has a "no-store" cache | |
| 221 // control HTTP header. | |
| 222 void RecordFirstContentfulPaint(const GURL& url, | |
| 223 bool is_no_store, | |
| 224 base::TimeDelta time); | |
|
mmenke
2016/09/16 16:53:48
Oh, this does something completely different from
droger
2016/09/19 09:55:23
Note that prefetched pages are not rendered at all
| |
| 225 | |
| 219 static PrerenderManagerMode GetMode(); | 226 static PrerenderManagerMode GetMode(); |
| 220 static void SetMode(PrerenderManagerMode mode); | 227 static void SetMode(PrerenderManagerMode mode); |
| 221 static bool IsPrerenderingPossible(); | 228 static bool IsPrerenderingPossible(); |
| 222 static bool ActuallyPrerendering(); | 229 static bool ActuallyPrerendering(); |
| 223 static bool IsControlGroup(); | 230 static bool IsControlGroup(); |
| 224 static bool IsNoUseGroup(); | 231 static bool IsNoUseGroup(); |
| 225 static bool IsNoStatePrefetch(); | 232 static bool IsNoStatePrefetch(); |
| 226 | 233 |
| 227 // Query the list of current prerender pages to see if the given web contents | 234 // Query the list of current prerender pages to see if the given web contents |
| 228 // is prerendering a page. The optional parameter |origin| is an output | 235 // is prerendering a page. The optional parameter |origin| is an output |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 PrerenderContents* prerender_contents); | 501 PrerenderContents* prerender_contents); |
| 495 | 502 |
| 496 bool DoesRateLimitAllowPrerender(Origin origin) const; | 503 bool DoesRateLimitAllowPrerender(Origin origin) const; |
| 497 | 504 |
| 498 // Deletes old WebContents that have been replaced by prerendered ones. This | 505 // Deletes old WebContents that have been replaced by prerendered ones. This |
| 499 // is needed because they're replaced in a callback from the old WebContents, | 506 // is needed because they're replaced in a callback from the old WebContents, |
| 500 // so cannot immediately be deleted. | 507 // so cannot immediately be deleted. |
| 501 void DeleteOldWebContents(); | 508 void DeleteOldWebContents(); |
| 502 | 509 |
| 503 // Cleans up old NavigationRecord's. | 510 // Cleans up old NavigationRecord's. |
| 504 void CleanUpOldNavigations(); | 511 void CleanUpOldNavigations(std::vector<NavigationRecord>* navigations, |
| 512 base::TimeDelta max_age); | |
| 505 | 513 |
| 506 // Arrange for the given WebContents to be deleted asap. Delete |deleter| as | 514 // Arrange for the given WebContents to be deleted asap. Delete |deleter| as |
| 507 // well. | 515 // well. |
| 508 void ScheduleDeleteOldWebContents(std::unique_ptr<content::WebContents> tab, | 516 void ScheduleDeleteOldWebContents(std::unique_ptr<content::WebContents> tab, |
| 509 OnCloseWebContentsDeleter* deleter); | 517 OnCloseWebContentsDeleter* deleter); |
| 510 | 518 |
| 511 // Adds to the history list. | 519 // Adds to the history list. |
| 512 void AddToHistory(PrerenderContents* contents); | 520 void AddToHistory(PrerenderContents* contents); |
| 513 | 521 |
| 514 // Returns a new Value representing the pages currently being prerendered. | 522 // Returns a new Value representing the pages currently being prerendered. |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 544 // All running prerenders. Sorted by expiry time, in ascending order. | 552 // All running prerenders. Sorted by expiry time, in ascending order. |
| 545 PrerenderDataVector active_prerenders_; | 553 PrerenderDataVector active_prerenders_; |
| 546 | 554 |
| 547 // Prerenders awaiting deletion. | 555 // Prerenders awaiting deletion. |
| 548 PrerenderDataVector to_delete_prerenders_; | 556 PrerenderDataVector to_delete_prerenders_; |
| 549 | 557 |
| 550 // List of recent navigations in this profile, sorted by ascending | 558 // List of recent navigations in this profile, sorted by ascending |
| 551 // |navigate_time_|. | 559 // |navigate_time_|. |
| 552 std::vector<NavigationRecord> navigations_; | 560 std::vector<NavigationRecord> navigations_; |
| 553 | 561 |
| 562 // List of recent prefetches, sorted by ascending navigate time. | |
| 563 std::vector<NavigationRecord> prefetches_; | |
| 564 | |
| 554 std::unique_ptr<PrerenderContents::Factory> prerender_contents_factory_; | 565 std::unique_ptr<PrerenderContents::Factory> prerender_contents_factory_; |
| 555 | 566 |
| 556 static PrerenderManagerMode mode_; | 567 static PrerenderManagerMode mode_; |
| 557 | 568 |
| 558 // A count of how many prerenders we do per session. Initialized to 0 then | 569 // A count of how many prerenders we do per session. Initialized to 0 then |
| 559 // incremented and emitted to a histogram on each successful prerender. | 570 // incremented and emitted to a histogram on each successful prerender. |
| 560 static int prerenders_per_session_count_; | 571 static int prerenders_per_session_count_; |
| 561 | 572 |
| 562 // RepeatingTimer to perform periodic cleanups of pending prerendered | 573 // RepeatingTimer to perform periodic cleanups of pending prerendered |
| 563 // pages. | 574 // pages. |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 587 // Set of process hosts being prerendered. | 598 // Set of process hosts being prerendered. |
| 588 using PrerenderProcessSet = std::set<content::RenderProcessHost*>; | 599 using PrerenderProcessSet = std::set<content::RenderProcessHost*>; |
| 589 PrerenderProcessSet prerender_process_hosts_; | 600 PrerenderProcessSet prerender_process_hosts_; |
| 590 | 601 |
| 591 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 602 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
| 592 }; | 603 }; |
| 593 | 604 |
| 594 } // namespace prerender | 605 } // namespace prerender |
| 595 | 606 |
| 596 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 607 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
| OLD | NEW |