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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // from a source without a RenderViewHost (i.e., the omnibox) we don't have a | 133 // from a source without a RenderViewHost (i.e., the omnibox) we don't have a |
134 // child or route id, or a referrer. This method uses sensible values for | 134 // child or route id, or a referrer. This method uses sensible values for |
135 // those. The |session_storage_namespace| matches the namespace of the active | 135 // those. The |session_storage_namespace| matches the namespace of the active |
136 // tab at the time the prerender is generated from the omnibox. Returns a | 136 // tab at the time the prerender is generated from the omnibox. Returns a |
137 // caller-owned PrerenderHandle*, or NULL. | 137 // caller-owned PrerenderHandle*, or NULL. |
138 PrerenderHandle* AddPrerenderFromOmnibox( | 138 PrerenderHandle* AddPrerenderFromOmnibox( |
139 const GURL& url, | 139 const GURL& url, |
140 content::SessionStorageNamespace* session_storage_namespace, | 140 content::SessionStorageNamespace* session_storage_namespace, |
141 const gfx::Size& size); | 141 const gfx::Size& size); |
142 | 142 |
| 143 PrerenderHandle* AddPrerenderFromLocalPredictor( |
| 144 const GURL& url, |
| 145 content::SessionStorageNamespace* session_storage_namespace, |
| 146 const gfx::Size& size); |
| 147 |
143 // If |process_id| and |view_id| refer to a running prerender, destroy | 148 // If |process_id| and |view_id| refer to a running prerender, destroy |
144 // it with |final_status|. | 149 // it with |final_status|. |
145 virtual void DestroyPrerenderForRenderView(int process_id, | 150 virtual void DestroyPrerenderForRenderView(int process_id, |
146 int view_id, | 151 int view_id, |
147 FinalStatus final_status); | 152 FinalStatus final_status); |
148 | 153 |
149 // Cancels all active prerenders. | 154 // Cancels all active prerenders. |
150 void CancelAllPrerenders(); | 155 void CancelAllPrerenders(); |
151 | 156 |
152 // If |url| matches a valid prerendered page, try to swap it into | 157 // If |url| matches a valid prerendered page, try to swap it into |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 const base::Closure& result_cb); | 298 const base::Closure& result_cb); |
294 | 299 |
295 Profile* profile() const { return profile_; } | 300 Profile* profile() const { return profile_; } |
296 | 301 |
297 // Classes which will be tested in prerender unit browser tests should use | 302 // Classes which will be tested in prerender unit browser tests should use |
298 // these methods to get times for comparison, so that the test framework can | 303 // these methods to get times for comparison, so that the test framework can |
299 // mock advancing/retarding time. | 304 // mock advancing/retarding time. |
300 virtual base::Time GetCurrentTime() const; | 305 virtual base::Time GetCurrentTime() const; |
301 virtual base::TimeTicks GetCurrentTimeTicks() const; | 306 virtual base::TimeTicks GetCurrentTimeTicks() const; |
302 | 307 |
| 308 scoped_refptr<predictors::LoggedInPredictorTable> |
| 309 logged_in_predictor_table() { |
| 310 return logged_in_predictor_table_; |
| 311 } |
| 312 |
303 protected: | 313 protected: |
304 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { | 314 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { |
305 public: | 315 public: |
306 struct OrderByExpiryTime; | 316 struct OrderByExpiryTime; |
307 | 317 |
308 PrerenderData(PrerenderManager* manager, | 318 PrerenderData(PrerenderManager* manager, |
309 PrerenderContents* contents, | 319 PrerenderContents* contents, |
310 base::TimeTicks expiry_time); | 320 base::TimeTicks expiry_time); |
311 | 321 |
312 ~PrerenderData(); | 322 ~PrerenderData(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 // WebContents that have been replaced by prerendered WebContents. | 455 // WebContents that have been replaced by prerendered WebContents. |
446 // Also identifies and kills PrerenderContents that use too much | 456 // Also identifies and kills PrerenderContents that use too much |
447 // resources. | 457 // resources. |
448 void PeriodicCleanup(); | 458 void PeriodicCleanup(); |
449 | 459 |
450 // Posts a task to call PeriodicCleanup. Results in quicker destruction of | 460 // Posts a task to call PeriodicCleanup. Results in quicker destruction of |
451 // objects. If |this| is deleted before the task is run, the task will | 461 // objects. If |this| is deleted before the task is run, the task will |
452 // automatically be cancelled. | 462 // automatically be cancelled. |
453 void PostCleanupTask(); | 463 void PostCleanupTask(); |
454 | 464 |
455 base::TimeTicks GetExpiryTimeForNewPrerender() const; | 465 base::TimeTicks GetExpiryTimeForNewPrerender(Origin origin) const; |
456 base::TimeTicks GetExpiryTimeForNavigatedAwayPrerender() const; | 466 base::TimeTicks GetExpiryTimeForNavigatedAwayPrerender() const; |
457 | 467 |
458 void DeleteOldEntries(); | 468 void DeleteOldEntries(); |
459 virtual PrerenderContents* CreatePrerenderContents( | 469 virtual PrerenderContents* CreatePrerenderContents( |
460 const GURL& url, | 470 const GURL& url, |
461 const content::Referrer& referrer, | 471 const content::Referrer& referrer, |
462 Origin origin, | 472 Origin origin, |
463 uint8 experiment_id); | 473 uint8 experiment_id); |
464 | 474 |
465 // Insures the |active_prerenders_| are sorted by increasing expiry time. Call | 475 // Insures the |active_prerenders_| are sorted by increasing expiry time. Call |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 | 627 |
618 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 628 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
619 }; | 629 }; |
620 | 630 |
621 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 631 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
622 int render_process_id); | 632 int render_process_id); |
623 | 633 |
624 } // namespace prerender | 634 } // namespace prerender |
625 | 635 |
626 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 636 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |