OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 // Entry points for adding prerenders. | 92 // Entry points for adding prerenders. |
93 | 93 |
94 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify | 94 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify |
95 // the RenderViewHost that the prerender request came from and are used to | 95 // the RenderViewHost that the prerender request came from and are used to |
96 // set the initial window size of the RenderViewHost used for prerendering. | 96 // set the initial window size of the RenderViewHost used for prerendering. |
97 // Returns true if the URL was added, false if it was not. | 97 // Returns true if the URL was added, false if it was not. |
98 // If the RenderViewHost source is itself prerendering, the prerender is added | 98 // If the RenderViewHost source is itself prerendering, the prerender is added |
99 // as a pending prerender. | 99 // as a pending prerender. |
100 bool AddPrerenderFromLinkRelPrerender(int process_id, int route_id, | 100 bool AddPrerenderFromLinkRelPrerender(int process_id, int route_id, |
101 const GURL& url, const GURL& referrer); | 101 const GURL& url, |
| 102 const content::Referrer& referrer); |
102 | 103 |
103 // Adds a prerender for |url| if valid. As the prerender request is coming | 104 // Adds a prerender for |url| if valid. As the prerender request is coming |
104 // from a source without a RenderViewHost (i.e., the omnibox) we don't have a | 105 // from a source without a RenderViewHost (i.e., the omnibox) we don't have a |
105 // child or route id, or a referrer. This method uses sensible values for | 106 // child or route id, or a referrer. This method uses sensible values for |
106 // those. The |session_storage_namespace| matches the namespace of the active | 107 // those. The |session_storage_namespace| matches the namespace of the active |
107 // tab at the time the prerender is generated from the omnibox. | 108 // tab at the time the prerender is generated from the omnibox. |
108 bool AddPrerenderFromOmnibox( | 109 bool AddPrerenderFromOmnibox( |
109 const GURL& url, | 110 const GURL& url, |
110 SessionStorageNamespace* session_storage_namespace); | 111 SessionStorageNamespace* session_storage_namespace); |
111 | 112 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 254 |
254 // Adds a prerender for |url| from referrer |referrer| initiated from the | 255 // Adds a prerender for |url| from referrer |referrer| initiated from the |
255 // RenderViewHost specified by |child_route_id_pair|. The |origin| specifies | 256 // RenderViewHost specified by |child_route_id_pair|. The |origin| specifies |
256 // how the prerender was added. If the |session_storage_namespace| is NULL, | 257 // how the prerender was added. If the |session_storage_namespace| is NULL, |
257 // it is discovered using the RenderViewHost specified by | 258 // it is discovered using the RenderViewHost specified by |
258 // |child_route_id_pair|. | 259 // |child_route_id_pair|. |
259 bool AddPrerender( | 260 bool AddPrerender( |
260 Origin origin, | 261 Origin origin, |
261 const std::pair<int, int>& child_route_id_pair, | 262 const std::pair<int, int>& child_route_id_pair, |
262 const GURL& url, | 263 const GURL& url, |
263 const GURL& referrer, | 264 const content::Referrer& referrer, |
264 SessionStorageNamespace* session_storage_namespace); | 265 SessionStorageNamespace* session_storage_namespace); |
265 | 266 |
266 // Adds a pending preload issued by the prerendering RenderView identified by | 267 // Adds a pending preload issued by the prerendering RenderView identified by |
267 // |child_route_id_pair|. If and when that prerendering RenderView is used, | 268 // |child_route_id_pair|. If and when that prerendering RenderView is used, |
268 // the specified prerender will start. | 269 // the specified prerender will start. |
269 void AddPendingPrerender(Origin origin, | 270 void AddPendingPrerender(Origin origin, |
270 const std::pair<int, int>& child_route_id_pair, | 271 const std::pair<int, int>& child_route_id_pair, |
271 const GURL& url, | 272 const GURL& url, |
272 const GURL& referrer); | 273 const content::Referrer& referrer); |
273 | 274 |
274 // Retrieves the PrerenderContents object for the specified URL, if it | 275 // Retrieves the PrerenderContents object for the specified URL, if it |
275 // has been prerendered. The caller will then have ownership of the | 276 // has been prerendered. The caller will then have ownership of the |
276 // PrerenderContents object and is responsible for freeing it. | 277 // PrerenderContents object and is responsible for freeing it. |
277 // Returns NULL if the specified URL has not been prerendered. | 278 // Returns NULL if the specified URL has not been prerendered. |
278 PrerenderContents* GetEntry(const GURL& url); | 279 PrerenderContents* GetEntry(const GURL& url); |
279 | 280 |
280 // Identical to GetEntry, with one exception: | 281 // Identical to GetEntry, with one exception: |
281 // The TabContents specified indicates the TC in which to swap the | 282 // The TabContents specified indicates the TC in which to swap the |
282 // prerendering into. If the TabContents specified is the one | 283 // prerendering into. If the TabContents specified is the one |
(...skipping 16 matching lines...) Expand all Loading... |
299 // objects. If |this| is deleted before the task is run, the task will | 300 // objects. If |this| is deleted before the task is run, the task will |
300 // automatically be cancelled. | 301 // automatically be cancelled. |
301 void PostCleanupTask(); | 302 void PostCleanupTask(); |
302 | 303 |
303 bool IsPrerenderElementFresh(const base::Time start) const; | 304 bool IsPrerenderElementFresh(const base::Time start) const; |
304 void DeleteOldEntries(); | 305 void DeleteOldEntries(); |
305 virtual base::Time GetCurrentTime() const; | 306 virtual base::Time GetCurrentTime() const; |
306 virtual base::TimeTicks GetCurrentTimeTicks() const; | 307 virtual base::TimeTicks GetCurrentTimeTicks() const; |
307 virtual PrerenderContents* CreatePrerenderContents( | 308 virtual PrerenderContents* CreatePrerenderContents( |
308 const GURL& url, | 309 const GURL& url, |
309 const GURL& referrer, | 310 const content::Referrer& referrer, |
310 Origin origin, | 311 Origin origin, |
311 uint8 experiment_id); | 312 uint8 experiment_id); |
312 | 313 |
313 // Checks if the PrerenderContents has been added to the pending delete list. | 314 // Checks if the PrerenderContents has been added to the pending delete list. |
314 bool IsPendingDelete(PrerenderContents* entry) const; | 315 bool IsPendingDelete(PrerenderContents* entry) const; |
315 | 316 |
316 // Deletes any PrerenderContents that have been added to the pending delete | 317 // Deletes any PrerenderContents that have been added to the pending delete |
317 // list. | 318 // list. |
318 void DeletePendingDeleteEntries(); | 319 void DeletePendingDeleteEntries(); |
319 | 320 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 | 427 |
427 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 428 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
428 }; | 429 }; |
429 | 430 |
430 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 431 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
431 int render_process_id); | 432 int render_process_id); |
432 | 433 |
433 } // namespace prerender | 434 } // namespace prerender |
434 | 435 |
435 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 436 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |