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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "base/gtest_prod_util.h" | 13 #include "base/gtest_prod_util.h" |
14 #include "base/hash_tables.h" | 14 #include "base/hash_tables.h" |
15 #include "base/memory/linked_ptr.h" | |
15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/scoped_vector.h" | 17 #include "base/memory/scoped_vector.h" |
17 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
18 #include "base/threading/non_thread_safe.h" | 19 #include "base/threading/non_thread_safe.h" |
19 #include "base/time.h" | 20 #include "base/time.h" |
20 #include "base/timer.h" | 21 #include "base/timer.h" |
21 #include "chrome/browser/prerender/prerender_config.h" | 22 #include "chrome/browser/prerender/prerender_config.h" |
22 #include "chrome/browser/prerender/prerender_contents.h" | 23 #include "chrome/browser/prerender/prerender_contents.h" |
23 #include "chrome/browser/prerender/prerender_final_status.h" | 24 #include "chrome/browser/prerender/prerender_final_status.h" |
24 #include "chrome/browser/prerender/prerender_origin.h" | 25 #include "chrome/browser/prerender/prerender_origin.h" |
(...skipping 23 matching lines...) Expand all Loading... | |
48 return reinterpret_cast<std::size_t>(value); | 49 return reinterpret_cast<std::size_t>(value); |
49 } | 50 } |
50 }; | 51 }; |
51 } | 52 } |
52 | 53 |
53 #endif | 54 #endif |
54 | 55 |
55 namespace prerender { | 56 namespace prerender { |
56 | 57 |
57 class PrerenderCondition; | 58 class PrerenderCondition; |
59 class PrerenderHandle; | |
58 class PrerenderHistograms; | 60 class PrerenderHistograms; |
59 class PrerenderHistory; | 61 class PrerenderHistory; |
60 class PrerenderLocalPredictor; | 62 class PrerenderLocalPredictor; |
61 class PrerenderTracker; | 63 class PrerenderTracker; |
62 | 64 |
63 // PrerenderManager is responsible for initiating and keeping prerendered | 65 // PrerenderManager is responsible for initiating and keeping prerendered |
64 // views of web pages. All methods must be called on the UI thread unless | 66 // views of web pages. All methods must be called on the UI thread unless |
65 // indicated otherwise. | 67 // indicated otherwise. |
66 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, | 68 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, |
67 public base::NonThreadSafe, | 69 public base::NonThreadSafe, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 | 102 |
101 // Entry points for adding prerenders. | 103 // Entry points for adding prerenders. |
102 | 104 |
103 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify | 105 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify |
104 // the RenderView that the prerender request came from. The |size| may be | 106 // the RenderView that the prerender request came from. The |size| may be |
105 // empty, and the current tab size will be used if it is. If the current | 107 // empty, and the current tab size will be used if it is. If the current |
106 // active tab size cannot be found, we use a default from PrerenderConfig. | 108 // active tab size cannot be found, we use a default from PrerenderConfig. |
107 // Returns true if the URL was added, false if it was not. | 109 // Returns true if the URL was added, false if it was not. |
108 // If the launching RenderView is itself prerendering, the prerender is added | 110 // If the launching RenderView is itself prerendering, the prerender is added |
109 // as a pending prerender. | 111 // as a pending prerender. |
110 bool AddPrerenderFromLinkRelPrerender( | 112 base::WeakPtr<PrerenderHandle> AddPrerenderFromLinkRelPrerender( |
111 int process_id, | 113 int process_id, |
112 int route_id, | 114 int route_id, |
113 const GURL& url, | 115 const GURL& url, |
114 const content::Referrer& referrer, | 116 const content::Referrer& referrer, |
115 const gfx::Size& size); | 117 const gfx::Size& size); |
116 | 118 |
117 // Adds a prerender for |url| if valid. As the prerender request is coming | 119 // Adds a prerender for |url| if valid. As the prerender request is coming |
118 // from a source without a RenderViewHost (i.e., the omnibox) we don't have a | 120 // from a source without a RenderViewHost (i.e., the omnibox) we don't have a |
119 // child or route id, or a referrer. This method uses sensible values for | 121 // child or route id, or a referrer. This method uses sensible values for |
120 // those. The |session_storage_namespace| matches the namespace of the active | 122 // those. The |session_storage_namespace| matches the namespace of the active |
121 // tab at the time the prerender is generated from the omnibox. | 123 // tab at the time the prerender is generated from the omnibox. |
122 bool AddPrerenderFromOmnibox( | 124 base::WeakPtr<PrerenderHandle> AddPrerenderFromOmnibox( |
dominich
2012/06/22 15:36:16
This cements it for me. I don't like an API that r
| |
123 const GURL& url, | 125 const GURL& url, |
124 content::SessionStorageNamespace* session_storage_namespace); | 126 content::SessionStorageNamespace* session_storage_namespace); |
125 | 127 |
126 // Request cancelation of a previously added prerender. If the |active_count_| | 128 // Adds a prerender |
127 // of the prerender is one, it will be canceled. Otherwise, |active_count_| | 129 void StartPendingPrerender( |
128 // will be decremented by one. | 130 scoped_ptr<PrerenderHandle> existing_prerender_handle, |
dominich
2012/06/22 15:36:16
... uses a different smart pointer to the same typ
| |
129 void MaybeCancelPrerender(const GURL& url); | 131 int process_id, |
132 const GURL& url, | |
133 const content::Referrer& referrer, | |
134 const gfx::Size& size, | |
135 content::SessionStorageNamespace* session_storage_namespace); | |
dominich
2012/06/22 15:36:16
ps - why is starting a pending prerender a public
| |
130 | 136 |
131 // Destroy all prerenders for the given child route id pair and assign a final | 137 // Destroy all prerenders for the given child route id pair and assign a final |
132 // status to them. | 138 // status to them. |
133 virtual void DestroyPrerenderForRenderView(int process_id, | 139 virtual void DestroyPrerenderForRenderView(int process_id, |
134 int view_id, | 140 int view_id, |
135 FinalStatus final_status); | 141 FinalStatus final_status); |
136 | 142 |
137 // Cancels all active prerenders. | 143 // Cancels all active prerenders. |
138 void CancelAllPrerenders(); | 144 void CancelAllPrerenders(); |
139 | 145 |
140 // Cancels all active prerenders with the ORIGIN_OMNIBOX origin. | |
141 void CancelOmniboxPrerenders(); | |
142 | |
143 // If |url| matches a valid prerendered page, try to swap it into | 146 // If |url| matches a valid prerendered page, try to swap it into |
144 // |web_contents| and merge browsing histories. Returns |true| if a | 147 // |web_contents| and merge browsing histories. Returns |true| if a |
145 // prerendered page is swapped in, |false| otherwise. | 148 // prerendered page is swapped in, |false| otherwise. |
146 bool MaybeUsePrerenderedPage(content::WebContents* web_contents, | 149 bool MaybeUsePrerenderedPage(content::WebContents* web_contents, |
147 const GURL& url); | 150 const GURL& url); |
148 | 151 |
149 // Moves a PrerenderContents to the pending delete list from the list of | 152 // Moves a PrerenderContents to the pending delete list from the list of |
150 // active prerenders when prerendering should be cancelled. | 153 // active prerenders when prerendering should be cancelled. |
151 void MoveEntryToPendingDelete(PrerenderContents* entry, | 154 void MoveEntryToPendingDelete(PrerenderContents* entry, |
152 FinalStatus final_status); | 155 FinalStatus final_status); |
(...skipping 26 matching lines...) Expand all Loading... | |
179 static const char* GetModeString(); | 182 static const char* GetModeString(); |
180 static bool IsPrerenderingPossible(); | 183 static bool IsPrerenderingPossible(); |
181 static bool ActuallyPrerendering(); | 184 static bool ActuallyPrerendering(); |
182 static bool IsControlGroup(); | 185 static bool IsControlGroup(); |
183 static bool IsNoUseGroup(); | 186 static bool IsNoUseGroup(); |
184 | 187 |
185 // Query the list of current prerender pages to see if the given web contents | 188 // Query the list of current prerender pages to see if the given web contents |
186 // is prerendering a page. | 189 // is prerendering a page. |
187 bool IsWebContentsPrerendering(content::WebContents* web_contents) const; | 190 bool IsWebContentsPrerendering(content::WebContents* web_contents) const; |
188 | 191 |
189 // Returns true if there is a prerendered page for the given URL and it has | |
190 // finished loading. Only valid if called before MaybeUsePrerenderedPage. | |
191 bool DidPrerenderFinishLoading(const GURL& url) const; | |
192 | |
193 // Maintaining and querying the set of WebContents belonging to this | 192 // Maintaining and querying the set of WebContents belonging to this |
194 // PrerenderManager that are currently showing prerendered pages. | 193 // PrerenderManager that are currently showing prerendered pages. |
195 void MarkWebContentsAsPrerendered(content::WebContents* web_contents); | 194 void MarkWebContentsAsPrerendered(content::WebContents* web_contents); |
196 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); | 195 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); |
197 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); | 196 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); |
198 bool IsWebContentsPrerendered(content::WebContents* web_contents) const; | 197 bool IsWebContentsPrerendered(content::WebContents* web_contents) const; |
199 bool WouldWebContentsBePrerendered(content::WebContents* web_contents) const; | 198 bool WouldWebContentsBePrerendered(content::WebContents* web_contents) const; |
200 | 199 |
201 // Checks whether |url| has been recently navigated to. | 200 // Checks whether |url| has been recently navigated to. |
202 bool HasRecentlyBeenNavigatedTo(const GURL& url); | 201 bool HasRecentlyBeenNavigatedTo(const GURL& url); |
(...skipping 29 matching lines...) Expand all Loading... | |
232 FinalStatus final_status) const; | 231 FinalStatus final_status) const; |
233 | 232 |
234 const Config& config() const { return config_; } | 233 const Config& config() const { return config_; } |
235 Config& mutable_config() { return config_; } | 234 Config& mutable_config() { return config_; } |
236 | 235 |
237 PrerenderTracker* prerender_tracker() { return prerender_tracker_; } | 236 PrerenderTracker* prerender_tracker() { return prerender_tracker_; } |
238 | 237 |
239 // Adds a condition. This is owned by the PrerenderManager. | 238 // Adds a condition. This is owned by the PrerenderManager. |
240 void AddCondition(const PrerenderCondition* condition); | 239 void AddCondition(const PrerenderCondition* condition); |
241 | 240 |
242 bool IsPendingEntry(const GURL& url) const; | |
243 | |
244 // Returns true if |url| matches any URLs being prerendered. | |
245 bool IsPrerendering(const GURL& url) const; | |
246 | |
247 // Records that some visible tab navigated (or was redirected) to the | 241 // Records that some visible tab navigated (or was redirected) to the |
248 // provided URL. | 242 // provided URL. |
249 void RecordNavigation(const GURL& url); | 243 void RecordNavigation(const GURL& url); |
250 | 244 |
251 Profile* profile() const { return profile_; } | 245 Profile* profile() const { return profile_; } |
252 | 246 |
253 PrerenderHistograms* histograms() const { return histograms_.get(); } | 247 PrerenderHistograms* histograms() const { return histograms_.get(); } |
254 | 248 |
255 protected: | 249 protected: |
256 void SetPrerenderContentsFactory( | 250 void SetPrerenderContentsFactory( |
257 PrerenderContents::Factory* prerender_contents_factory); | 251 PrerenderContents::Factory* prerender_contents_factory); |
258 | 252 |
259 // Utility method that is called from the virtual Shutdown method on this | 253 // Utility method that is called from the virtual Shutdown method on this |
260 // class but is called directly from the TestPrerenderManager in the unit | 254 // class but is called directly from the TestPrerenderManager in the unit |
261 // tests. | 255 // tests. |
262 void DoShutdown(); | 256 void DoShutdown(); |
263 | 257 |
258 PrerenderContents* FindEntry(const GURL& url); | |
dominich
2012/06/22 15:36:16
move to protected for tests?
gavinp
2012/06/22 17:45:29
Yup.
| |
259 | |
264 private: | 260 private: |
265 // Test that needs needs access to internal functions. | 261 // Test that needs needs access to internal functions. |
266 friend class PrerenderBrowserTest; | 262 friend class PrerenderBrowserTest; |
267 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, AliasURLTest); | 263 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, AliasURLTest); |
268 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, CancelAllTest); | 264 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, CancelAllTest); |
269 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, | 265 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, |
270 CancelOmniboxRemovesOmniboxTest); | 266 CancelOmniboxRemovesOmniboxTest); |
271 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, | 267 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, |
272 CancelOmniboxDoesNotRemoveLinkTest); | 268 CancelOmniboxDoesNotRemoveLinkTest); |
273 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, ClearTest); | 269 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, ClearTest); |
(...skipping 18 matching lines...) Expand all Loading... | |
292 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, NotSoRecentlyVisited); | 288 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, NotSoRecentlyVisited); |
293 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PageMatchesFragmentTest); | 289 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PageMatchesFragmentTest); |
294 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PendingPrerenderTest); | 290 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PendingPrerenderTest); |
295 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PPLTDummy); | 291 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PPLTDummy); |
296 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RateLimitInWindowTest); | 292 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RateLimitInWindowTest); |
297 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RateLimitOutsideWindowTest); | 293 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RateLimitOutsideWindowTest); |
298 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RecentlyVisitedPPLTDummy); | 294 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RecentlyVisitedPPLTDummy); |
299 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, SourceRenderViewClosed); | 295 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, SourceRenderViewClosed); |
300 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, TwoElementPrerenderTest); | 296 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, TwoElementPrerenderTest); |
301 | 297 |
302 struct PrerenderContentsData; | |
303 struct NavigationRecord; | 298 struct NavigationRecord; |
304 | 299 |
305 class OnCloseTabContentsDeleter; | 300 class OnCloseTabContentsDeleter; |
306 | 301 |
307 typedef std::list<PrerenderContentsData> PrerenderContentsDataList; | 302 typedef std::map<PrerenderContents*, linked_ptr<PrerenderHandle>, |
303 PrerenderContents::LessThanByLoadStartTime> | |
304 PrerenderHandleMap; | |
dominich
2012/06/22 15:36:16
if the PrerenderHandle already contains the Preren
| |
308 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; | 305 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; |
309 | 306 |
310 // Time window for which we record old navigations, in milliseconds. | 307 // Time window for which we record old navigations, in milliseconds. |
311 static const int kNavigationRecordWindowMs = 5000; | 308 static const int kNavigationRecordWindowMs = 5000; |
312 | 309 |
313 // Adds a prerender for |url| from referrer |referrer| initiated from the | 310 // Adds a prerender for |url| from |referrer| initiated from the process |
314 // child process specified by |child_id|. The |origin| specifies how the | 311 // |child_id|. The |origin| specifies how the prerender was added. If |size| |
315 // prerender was added. If the |size| is empty, then | 312 // is empty, then PrerenderContents::StartPrerendering will instead use the |
316 // PrerenderContents::StartPrerendering will instead use the size of the | 313 // size of the currently active tab. If the current active tab size cannot be |
317 // currently active tab. If the current active tab size cannot be found, it | 314 // found, it then uses a default from PrerenderConfig. If |prerender_handle| |
318 // then uses a default from PrerenderConfig. | 315 // is NULL, then AddPrerender will allocate a handle for the caller if |
319 bool AddPrerender( | 316 // successful. If |preexisting_prerender_handle| is not-NULL, the |
317 // PrerenderManager will take ownership of it and associate the prerender with | |
318 // that handle. The return value is a WeakPtr to a PrerenderHandle. It can | |
319 // be NULL, if for instance Prerendering is disabled or if there was an error | |
320 // adding this prerender. | |
321 base::WeakPtr<PrerenderHandle> AddPrerender( | |
320 Origin origin, | 322 Origin origin, |
321 int child_id, | 323 int child_id, |
322 const GURL& url, | 324 const GURL& url, |
323 const content::Referrer& referrer, | 325 const content::Referrer& referrer, |
324 const gfx::Size& size, | 326 const gfx::Size& size, |
325 content::SessionStorageNamespace* session_storage_namespace); | 327 content::SessionStorageNamespace* session_storage_namespace, |
328 const scoped_ptr<PrerenderHandle> preexisting_prerender_handle); | |
dominich
2012/06/22 15:36:16
I don't understand why this is passed through and
| |
326 | 329 |
327 // Retrieves the PrerenderContents object for the specified URL, if it | 330 // Retrieves the PrerenderContents object for the specified URL, if it |
328 // has been prerendered. The caller will then have ownership of the | 331 // has been prerendered. The caller will then have ownership of the |
329 // PrerenderContents object and is responsible for freeing it. | 332 // PrerenderContents object and is responsible for freeing it. |
330 // Returns NULL if the specified URL has not been prerendered. | 333 // Returns NULL if the specified URL has not been prerendered. |
331 PrerenderContents* GetEntry(const GURL& url); | 334 PrerenderContents* GetEntry(const GURL& url); |
332 | 335 |
333 // Identical to GetEntry, with one exception: | 336 // Identical to GetEntry, with one exception: |
334 // The WebContents specified indicates the WC in which to swap the | 337 // The WebContents specified indicates the WC in which to swap the |
335 // prerendering into. If the WebContents specified is the one | 338 // prerendering into. If the WebContents specified is the one |
336 // to doing the prerendered itself, will return NULL. | 339 // to doing the prerendered itself, will return NULL. |
337 PrerenderContents* GetEntryButNotSpecifiedWC(const GURL& url, | 340 PrerenderContents* GetEntryButNotSpecifiedWC( |
338 content::WebContents* wc); | 341 const GURL& url, |
342 content::WebContents* web_contents); | |
339 | 343 |
340 // Starts scheduling periodic cleanups. | |
341 void StartSchedulingPeriodicCleanups(); | 344 void StartSchedulingPeriodicCleanups(); |
342 // Stops scheduling periodic cleanups if they're no longer needed. | 345 void StopSchedulingPeriodicCleanups(); |
343 void MaybeStopSchedulingPeriodicCleanups(); | 346 |
347 void EvictOldestPrerendersIfNecessary(); | |
344 | 348 |
345 // Deletes stale and cancelled prerendered PrerenderContents, as well as | 349 // Deletes stale and cancelled prerendered PrerenderContents, as well as |
346 // WebContents that have been replaced by prerendered WebContents. | 350 // WebContents that have been replaced by prerendered WebContents. |
347 // Also identifies and kills PrerenderContents that use too much | 351 // Also identifies and kills PrerenderContents that use too much |
348 // resources. | 352 // resources. |
349 void PeriodicCleanup(); | 353 void PeriodicCleanup(); |
350 | 354 |
351 // Posts a task to call PeriodicCleanup. Results in quicker destruction of | 355 // Posts a task to call PeriodicCleanup. Results in quicker destruction of |
352 // objects. If |this| is deleted before the task is run, the task will | 356 // objects. If |this| is deleted before the task is run, the task will |
353 // automatically be cancelled. | 357 // automatically be cancelled. |
354 void PostCleanupTask(); | 358 void PostCleanupTask(); |
355 | 359 |
356 base::TimeDelta GetMaxAge() const; | 360 base::TimeDelta GetMaxAge() const; |
357 bool IsPrerenderElementFresh(const base::Time start) const; | 361 bool IsPrerenderFresh(base::TimeTicks start) const; |
358 void DeleteOldEntries(); | 362 void DeleteOldEntries(); |
359 virtual base::Time GetCurrentTime() const; | 363 virtual base::Time GetCurrentTime() const; |
360 virtual base::TimeTicks GetCurrentTimeTicks() const; | 364 virtual base::TimeTicks GetCurrentTimeTicks() const; |
361 virtual PrerenderContents* CreatePrerenderContents( | 365 virtual PrerenderContents* CreatePrerenderContents( |
362 const GURL& url, | 366 const GURL& url, |
363 const content::Referrer& referrer, | 367 const content::Referrer& referrer, |
364 Origin origin, | 368 Origin origin, |
365 uint8 experiment_id); | 369 uint8 experiment_id); |
366 | 370 |
367 // Deletes any PrerenderContents that have been added to the pending delete | 371 // Deletes any PrerenderContents that have been added to the pending delete |
368 // list. | 372 // list. |
369 void DeletePendingDeleteEntries(); | 373 void DeletePendingDeleteEntries(); |
370 | 374 |
371 // Finds the specified PrerenderContentsData/PrerenderContents and returns it, | |
372 // if it exists. Returns NULL otherwise. Unlike GetEntry, the | |
373 // PrerenderManager maintains ownership of the PrerenderContents. | 375 // PrerenderManager maintains ownership of the PrerenderContents. |
374 PrerenderContentsData* FindEntryData(const GURL& url); | 376 PrerenderHandle* FindHandle( |
dominich
2012/06/22 15:36:16
with all those smart pointer returns, i'm surprise
| |
375 PrerenderContents* FindEntry(const GURL& url) const; | 377 const GURL& url, |
378 const content::SessionStorageNamespace* session_storage_namespace); | |
376 | 379 |
377 // Returns the iterator to the PrerenderContentsData entry that is being | 380 // PrerenderManager maintains ownership of the PrerenderContents. |
378 // prerendered from the given child route id pair. | 381 PrerenderContents* FindContentsForChildAndRoute(int child_id, int route_id); |
dominich
2012/06/22 15:36:16
If we add a new prerender for the same URL/Session
| |
379 PrerenderContentsDataList::iterator | |
380 FindPrerenderContentsForChildRouteIdPair( | |
381 const std::pair<int, int>& child_route_id_pair); | |
382 | |
383 PrerenderContentsDataList::iterator | |
384 FindPrerenderContentsForURL(const GURL& url); | |
385 | 382 |
386 bool DoesRateLimitAllowPrerender() const; | 383 bool DoesRateLimitAllowPrerender() const; |
387 | 384 |
388 // Deletes old WebContents that have been replaced by prerendered ones. This | 385 // Deletes old WebContents that have been replaced by prerendered ones. This |
389 // is needed because they're replaced in a callback from the old WebContents, | 386 // is needed because they're replaced in a callback from the old WebContents, |
390 // so cannot immediately be deleted. | 387 // so cannot immediately be deleted. |
391 void DeleteOldTabContents(); | 388 void DeleteOldTabContents(); |
392 | 389 |
393 // Cleans up old NavigationRecord's. | 390 // Cleans up old NavigationRecord's. |
394 void CleanUpOldNavigations(); | 391 void CleanUpOldNavigations(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
435 // of the PrerenderManager. | 432 // of the PrerenderManager. |
436 bool enabled_; | 433 bool enabled_; |
437 | 434 |
438 static bool is_prefetch_enabled_; | 435 static bool is_prefetch_enabled_; |
439 | 436 |
440 // The profile that owns this PrerenderManager. | 437 // The profile that owns this PrerenderManager. |
441 Profile* profile_; | 438 Profile* profile_; |
442 | 439 |
443 PrerenderTracker* prerender_tracker_; | 440 PrerenderTracker* prerender_tracker_; |
444 | 441 |
445 // List of prerendered elements. | 442 // Map of prerendered elements. This map owns both each PrerenderHandle* and |
446 PrerenderContentsDataList prerender_list_; | 443 // each PrerenderContents* in it. |
444 PrerenderHandleMap prerender_map_; | |
447 | 445 |
448 // List of recent navigations in this profile, sorted by ascending | 446 // List of recent navigations in this profile, sorted by ascending |
449 // navigate_time_. | 447 // navigate_time_. |
450 std::list<NavigationRecord> navigations_; | 448 std::list<NavigationRecord> navigations_; |
451 | 449 |
452 // List of prerender elements to be deleted | 450 // List of prerender elements to be deleted |
453 std::list<PrerenderContents*> pending_delete_list_; | 451 std::list<PrerenderContents*> pending_delete_list_; |
454 | 452 |
455 // Set of WebContents which are currently displaying a prerendered page. | 453 // Set of WebContents which are currently displaying a prerendered page. |
456 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; | 454 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 | 496 |
499 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 497 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
500 }; | 498 }; |
501 | 499 |
502 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 500 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
503 int render_process_id); | 501 int render_process_id); |
504 | 502 |
505 } // namespace prerender | 503 } // namespace prerender |
506 | 504 |
507 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 505 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |