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 // Returns the PrerenderContents object for a given child_id, route_id pair, |
| 234 // otherwise returns NULL. Note that the PrerenderContents may have been |
| 235 // Destroy()ed, but not yet deleted. |
| 236 virtual PrerenderContents* GetPrerenderContentsForRoute( |
| 237 int child_id, int route_id) const; |
| 238 |
233 // Returns a list of all WebContents being prerendered. | 239 // Returns a list of all WebContents being prerendered. |
234 const std::vector<content::WebContents*> GetAllPrerenderingContents() const; | 240 const std::vector<content::WebContents*> GetAllPrerenderingContents() const; |
235 | 241 |
236 // Maintaining and querying the set of WebContents belonging to this | 242 // Maintaining and querying the set of WebContents belonging to this |
237 // PrerenderManager that are currently showing prerendered pages. | 243 // PrerenderManager that are currently showing prerendered pages. |
238 void MarkWebContentsAsPrerendered(content::WebContents* web_contents, | 244 void MarkWebContentsAsPrerendered(content::WebContents* web_contents, |
239 Origin origin); | 245 Origin origin); |
240 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents, | 246 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents, |
241 Origin origin); | 247 Origin origin); |
242 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); | 248 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 bool seen_target_route_id_; | 503 bool seen_target_route_id_; |
498 base::OneShotTimer<PendingSwap> merge_timeout_; | 504 base::OneShotTimer<PendingSwap> merge_timeout_; |
499 bool swap_successful_; | 505 bool swap_successful_; |
500 | 506 |
501 base::WeakPtrFactory<PendingSwap> weak_factory_; | 507 base::WeakPtrFactory<PendingSwap> weak_factory_; |
502 }; | 508 }; |
503 | 509 |
504 void SetPrerenderContentsFactory( | 510 void SetPrerenderContentsFactory( |
505 PrerenderContents::Factory* prerender_contents_factory); | 511 PrerenderContents::Factory* prerender_contents_factory); |
506 | 512 |
507 // Adds prerenders from the pending Prerenders, called by | |
508 // PrerenderContents::StartPendingPrerenders. | |
509 void StartPendingPrerenders( | |
510 int process_id, | |
511 ScopedVector<PrerenderContents::PendingPrerenderInfo>* pending_prerenders, | |
512 content::SessionStorageNamespace* session_storage_namespace); | |
513 | |
514 // Called by a PrerenderData to signal that the launcher has navigated away | 513 // Called by a PrerenderData to signal that the launcher has navigated away |
515 // from the context that launched the prerender. A user may have clicked | 514 // from the context that launched the prerender. A user may have clicked |
516 // a link in a page containing a <link rel=prerender> element, or the user | 515 // a link in a page containing a <link rel=prerender> element, or the user |
517 // might have committed an omnibox navigation. This is used to possibly | 516 // might have committed an omnibox navigation. This is used to possibly |
518 // shorten the TTL of the prerendered page. | 517 // shorten the TTL of the prerendered page. |
519 void SourceNavigatedAway(PrerenderData* prerender_data); | 518 void SourceNavigatedAway(PrerenderData* prerender_data); |
520 | 519 |
521 private: | 520 private: |
522 friend class ::InstantSearchPrerendererTest; | 521 friend class ::InstantSearchPrerendererTest; |
523 friend class PrerenderBrowserTest; | 522 friend class PrerenderBrowserTest; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 // after every mutation of active_prerenders_ that can possibly make it | 609 // after every mutation of active_prerenders_ that can possibly make it |
611 // unsorted (e.g. an insert, or changing an expiry time). | 610 // unsorted (e.g. an insert, or changing an expiry time). |
612 void SortActivePrerenders(); | 611 void SortActivePrerenders(); |
613 | 612 |
614 // Finds the active PrerenderData object for a running prerender matching | 613 // Finds the active PrerenderData object for a running prerender matching |
615 // |url| and |session_storage_namespace|. | 614 // |url| and |session_storage_namespace|. |
616 PrerenderData* FindPrerenderData( | 615 PrerenderData* FindPrerenderData( |
617 const GURL& url, | 616 const GURL& url, |
618 const content::SessionStorageNamespace* session_storage_namespace); | 617 const content::SessionStorageNamespace* session_storage_namespace); |
619 | 618 |
620 // If |child_id| and |route_id| correspond to a RenderView that is an active | |
621 // prerender, returns the PrerenderData object for that prerender. Otherwise, | |
622 // returns NULL. | |
623 PrerenderData* FindPrerenderDataForChildAndRoute(int child_id, int route_id); | |
624 | |
625 // Finds the active PrerenderData object currently in a PendingSwap for | 619 // Finds the active PrerenderData object currently in a PendingSwap for |
626 // |target_contents|. Otherwise, returns NULL. | 620 // |target_contents|. Otherwise, returns NULL. |
627 PrerenderData* FindPrerenderDataForTargetContents( | 621 PrerenderData* FindPrerenderDataForTargetContents( |
628 content::WebContents* target_contents); | 622 content::WebContents* target_contents); |
629 | 623 |
630 // Given the |prerender_contents|, find the iterator in active_prerenders_ | 624 // Given the |prerender_contents|, find the iterator in active_prerenders_ |
631 // correponding to the given prerender. | 625 // correponding to the given prerender. |
632 ScopedVector<PrerenderData>::iterator | 626 ScopedVector<PrerenderData>::iterator |
633 FindIteratorForPrerenderContents(PrerenderContents* prerender_contents); | 627 FindIteratorForPrerenderContents(PrerenderContents* prerender_contents); |
634 | 628 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 | 771 |
778 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 772 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
779 }; | 773 }; |
780 | 774 |
781 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 775 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
782 int render_process_id); | 776 int render_process_id); |
783 | 777 |
784 } // namespace prerender | 778 } // namespace prerender |
785 | 779 |
786 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 780 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |