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 <list> | 8 #include <list> |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 // Whether the PrerenderManager has an active prerender with the given url and | 223 // Whether the PrerenderManager has an active prerender with the given url and |
224 // SessionStorageNamespace associated with the given WebContens. | 224 // SessionStorageNamespace associated with the given WebContens. |
225 bool HasPrerenderedUrl(GURL url, content::WebContents* web_contents) const; | 225 bool HasPrerenderedUrl(GURL url, content::WebContents* web_contents) const; |
226 | 226 |
227 // Returns the PrerenderContents object for the given web_contents, otherwise | 227 // Returns the PrerenderContents object for the given web_contents, otherwise |
228 // returns NULL. Note that the PrerenderContents may have been Destroy()ed, | 228 // returns NULL. Note that the PrerenderContents may have been Destroy()ed, |
229 // but not yet deleted. | 229 // but not yet deleted. |
230 PrerenderContents* GetPrerenderContents( | 230 PrerenderContents* GetPrerenderContents( |
231 const content::WebContents* web_contents) const; | 231 const content::WebContents* web_contents) const; |
232 | 232 |
233 // Same as above, but returns it for a given child_id, route_id pair. | |
gavinp
2014/01/30 19:58:49
Nit: don't reference another comment. Duplicating
davidben
2014/01/30 21:01:51
Done.
| |
234 virtual PrerenderContents* GetPrerenderContentsForRoute( | |
235 int child_id, int route_id) const; | |
236 | |
233 // Returns a list of all WebContents being prerendered. | 237 // Returns a list of all WebContents being prerendered. |
234 const std::vector<content::WebContents*> GetAllPrerenderingContents() const; | 238 const std::vector<content::WebContents*> GetAllPrerenderingContents() const; |
235 | 239 |
236 // Maintaining and querying the set of WebContents belonging to this | 240 // Maintaining and querying the set of WebContents belonging to this |
237 // PrerenderManager that are currently showing prerendered pages. | 241 // PrerenderManager that are currently showing prerendered pages. |
238 void MarkWebContentsAsPrerendered(content::WebContents* web_contents, | 242 void MarkWebContentsAsPrerendered(content::WebContents* web_contents, |
239 Origin origin); | 243 Origin origin); |
240 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents, | 244 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents, |
241 Origin origin); | 245 Origin origin); |
242 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); | 246 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
492 std::vector<PrerenderTracker::ChildRouteIdPair> main_rfh_ids_; | 496 std::vector<PrerenderTracker::ChildRouteIdPair> main_rfh_ids_; |
493 base::OneShotTimer<PendingSwap> merge_timeout_; | 497 base::OneShotTimer<PendingSwap> merge_timeout_; |
494 bool swap_successful_; | 498 bool swap_successful_; |
495 | 499 |
496 base::WeakPtrFactory<PendingSwap> weak_factory_; | 500 base::WeakPtrFactory<PendingSwap> weak_factory_; |
497 }; | 501 }; |
498 | 502 |
499 void SetPrerenderContentsFactory( | 503 void SetPrerenderContentsFactory( |
500 PrerenderContents::Factory* prerender_contents_factory); | 504 PrerenderContents::Factory* prerender_contents_factory); |
501 | 505 |
502 // Adds prerenders from the pending Prerenders, called by | |
503 // PrerenderContents::StartPendingPrerenders. | |
504 void StartPendingPrerenders( | |
505 int process_id, | |
506 ScopedVector<PrerenderContents::PendingPrerenderInfo>* pending_prerenders, | |
507 content::SessionStorageNamespace* session_storage_namespace); | |
508 | |
509 // Called by a PrerenderData to signal that the launcher has navigated away | 506 // Called by a PrerenderData to signal that the launcher has navigated away |
510 // from the context that launched the prerender. A user may have clicked | 507 // from the context that launched the prerender. A user may have clicked |
511 // a link in a page containing a <link rel=prerender> element, or the user | 508 // a link in a page containing a <link rel=prerender> element, or the user |
512 // might have committed an omnibox navigation. This is used to possibly | 509 // might have committed an omnibox navigation. This is used to possibly |
513 // shorten the TTL of the prerendered page. | 510 // shorten the TTL of the prerendered page. |
514 void SourceNavigatedAway(PrerenderData* prerender_data); | 511 void SourceNavigatedAway(PrerenderData* prerender_data); |
515 | 512 |
516 private: | 513 private: |
517 friend class ::InstantSearchPrerendererTest; | 514 friend class ::InstantSearchPrerendererTest; |
518 friend class PrerenderBrowserTest; | 515 friend class PrerenderBrowserTest; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
605 // after every mutation of active_prerenders_ that can possibly make it | 602 // after every mutation of active_prerenders_ that can possibly make it |
606 // unsorted (e.g. an insert, or changing an expiry time). | 603 // unsorted (e.g. an insert, or changing an expiry time). |
607 void SortActivePrerenders(); | 604 void SortActivePrerenders(); |
608 | 605 |
609 // Finds the active PrerenderData object for a running prerender matching | 606 // Finds the active PrerenderData object for a running prerender matching |
610 // |url| and |session_storage_namespace|. | 607 // |url| and |session_storage_namespace|. |
611 PrerenderData* FindPrerenderData( | 608 PrerenderData* FindPrerenderData( |
612 const GURL& url, | 609 const GURL& url, |
613 const content::SessionStorageNamespace* session_storage_namespace); | 610 const content::SessionStorageNamespace* session_storage_namespace); |
614 | 611 |
615 // If |child_id| and |route_id| correspond to a RenderView that is an active | |
616 // prerender, returns the PrerenderData object for that prerender. Otherwise, | |
617 // returns NULL. | |
618 PrerenderData* FindPrerenderDataForChildAndRoute(int child_id, int route_id); | |
619 | |
620 // Given the |prerender_contents|, find the iterator in active_prerenders_ | 612 // Given the |prerender_contents|, find the iterator in active_prerenders_ |
621 // correponding to the given prerender. | 613 // correponding to the given prerender. |
622 ScopedVector<PrerenderData>::iterator | 614 ScopedVector<PrerenderData>::iterator |
623 FindIteratorForPrerenderContents(PrerenderContents* prerender_contents); | 615 FindIteratorForPrerenderContents(PrerenderContents* prerender_contents); |
624 | 616 |
625 bool DoesRateLimitAllowPrerender(Origin origin) const; | 617 bool DoesRateLimitAllowPrerender(Origin origin) const; |
626 | 618 |
627 // Deletes old WebContents that have been replaced by prerendered ones. This | 619 // Deletes old WebContents that have been replaced by prerendered ones. This |
628 // is needed because they're replaced in a callback from the old WebContents, | 620 // is needed because they're replaced in a callback from the old WebContents, |
629 // so cannot immediately be deleted. | 621 // so cannot immediately be deleted. |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
767 | 759 |
768 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 760 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
769 }; | 761 }; |
770 | 762 |
771 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 763 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
772 int render_process_id); | 764 int render_process_id); |
773 | 765 |
774 } // namespace prerender | 766 } // namespace prerender |
775 | 767 |
776 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 768 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |