| 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 <list> | 10 #include <list> |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 namespace content { | 50 namespace content { |
| 51 class WebContents; | 51 class WebContents; |
| 52 } | 52 } |
| 53 | 53 |
| 54 namespace gfx { | 54 namespace gfx { |
| 55 class Size; | 55 class Size; |
| 56 } | 56 } |
| 57 | 57 |
| 58 namespace offline_pages { |
| 59 class PrerenderAdapterTest; |
| 60 } |
| 61 |
| 58 namespace prerender { | 62 namespace prerender { |
| 59 | 63 |
| 60 class PrerenderHandle; | 64 class PrerenderHandle; |
| 61 class PrerenderHistory; | 65 class PrerenderHistory; |
| 62 class PrerenderLocalPredictor; | 66 class PrerenderLocalPredictor; |
| 63 | 67 |
| 64 // PrerenderManager is responsible for initiating and keeping prerendered | 68 // PrerenderManager is responsible for initiating and keeping prerendered |
| 65 // views of web pages. All methods must be called on the UI thread unless | 69 // views of web pages. All methods must be called on the UI thread unless |
| 66 // indicated otherwise. | 70 // indicated otherwise. |
| 67 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, | 71 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 void AddPrerenderProcessHost(content::RenderProcessHost* process_host); | 316 void AddPrerenderProcessHost(content::RenderProcessHost* process_host); |
| 313 | 317 |
| 314 // Returns whether or not |process_host| may be reused for new navigations | 318 // Returns whether or not |process_host| may be reused for new navigations |
| 315 // from a prerendering perspective. Currently, if Prerender Cookie Stores are | 319 // from a prerendering perspective. Currently, if Prerender Cookie Stores are |
| 316 // enabled, prerenders must be in their own processes that may not be shared. | 320 // enabled, prerenders must be in their own processes that may not be shared. |
| 317 bool MayReuseProcessHost(content::RenderProcessHost* process_host); | 321 bool MayReuseProcessHost(content::RenderProcessHost* process_host); |
| 318 | 322 |
| 319 // content::RenderProcessHostObserver implementation. | 323 // content::RenderProcessHostObserver implementation. |
| 320 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; | 324 void RenderProcessHostDestroyed(content::RenderProcessHost* host) override; |
| 321 | 325 |
| 326 void SetPrerenderContentsFactoryForTest( |
| 327 PrerenderContents::Factory* prerender_contents_factory); |
| 328 |
| 322 protected: | 329 protected: |
| 323 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { | 330 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { |
| 324 public: | 331 public: |
| 325 struct OrderByExpiryTime; | 332 struct OrderByExpiryTime; |
| 326 | 333 |
| 327 PrerenderData(PrerenderManager* manager, | 334 PrerenderData(PrerenderManager* manager, |
| 328 PrerenderContents* contents, | 335 PrerenderContents* contents, |
| 329 base::TimeTicks expiry_time); | 336 base::TimeTicks expiry_time); |
| 330 | 337 |
| 331 ~PrerenderData(); | 338 ~PrerenderData(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 // The time when OnHandleNavigatedAway was called. | 378 // The time when OnHandleNavigatedAway was called. |
| 372 base::TimeTicks abandon_time_; | 379 base::TimeTicks abandon_time_; |
| 373 | 380 |
| 374 // After this time, this prerender is no longer fresh, and should be | 381 // After this time, this prerender is no longer fresh, and should be |
| 375 // removed. | 382 // removed. |
| 376 base::TimeTicks expiry_time_; | 383 base::TimeTicks expiry_time_; |
| 377 | 384 |
| 378 DISALLOW_COPY_AND_ASSIGN(PrerenderData); | 385 DISALLOW_COPY_AND_ASSIGN(PrerenderData); |
| 379 }; | 386 }; |
| 380 | 387 |
| 381 void SetPrerenderContentsFactory( | |
| 382 PrerenderContents::Factory* prerender_contents_factory); | |
| 383 | |
| 384 // Called by a PrerenderData to signal that the launcher has navigated away | 388 // Called by a PrerenderData to signal that the launcher has navigated away |
| 385 // from the context that launched the prerender. A user may have clicked | 389 // from the context that launched the prerender. A user may have clicked |
| 386 // a link in a page containing a <link rel=prerender> element, or the user | 390 // a link in a page containing a <link rel=prerender> element, or the user |
| 387 // might have committed an omnibox navigation. This is used to possibly | 391 // might have committed an omnibox navigation. This is used to possibly |
| 388 // shorten the TTL of the prerendered page. | 392 // shorten the TTL of the prerendered page. |
| 389 void SourceNavigatedAway(PrerenderData* prerender_data); | 393 void SourceNavigatedAway(PrerenderData* prerender_data); |
| 390 | 394 |
| 391 private: | 395 private: |
| 392 friend class ::InstantSearchPrerendererTest; | |
| 393 friend class PrerenderBrowserTest; | 396 friend class PrerenderBrowserTest; |
| 394 friend class PrerenderContents; | 397 friend class PrerenderContents; |
| 395 friend class PrerenderHandle; | 398 friend class PrerenderHandle; |
| 396 friend class UnitTestPrerenderManager; | 399 friend class UnitTestPrerenderManager; |
| 397 | 400 |
| 398 class OnCloseWebContentsDeleter; | 401 class OnCloseWebContentsDeleter; |
| 399 struct NavigationRecord; | 402 struct NavigationRecord; |
| 400 | 403 |
| 401 // Time interval before a new prerender is allowed. | 404 // Time interval before a new prerender is allowed. |
| 402 static const int kMinTimeBetweenPrerendersMs = 500; | 405 static const int kMinTimeBetweenPrerendersMs = 500; |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 // Set of process hosts being prerendered. | 561 // Set of process hosts being prerendered. |
| 559 typedef std::set<content::RenderProcessHost*> PrerenderProcessSet; | 562 typedef std::set<content::RenderProcessHost*> PrerenderProcessSet; |
| 560 PrerenderProcessSet prerender_process_hosts_; | 563 PrerenderProcessSet prerender_process_hosts_; |
| 561 | 564 |
| 562 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 565 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
| 563 }; | 566 }; |
| 564 | 567 |
| 565 } // namespace prerender | 568 } // namespace prerender |
| 566 | 569 |
| 567 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 570 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
| OLD | NEW |