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 <map> | |
10 #include <string> | 11 #include <string> |
11 #include <utility> | 12 #include <utility> |
12 | 13 |
13 #include "base/gtest_prod_util.h" | 14 #include "base/gtest_prod_util.h" |
14 #include "base/hash_tables.h" | 15 #include "base/hash_tables.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" |
18 #include "base/memory/linked_ptr.h" | |
17 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
18 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
19 #include "base/time.h" | 21 #include "base/time.h" |
20 #include "base/timer.h" | 22 #include "base/timer.h" |
21 #include "chrome/browser/prerender/prerender_config.h" | 23 #include "chrome/browser/prerender/prerender_config.h" |
22 #include "chrome/browser/prerender/prerender_contents.h" | 24 #include "chrome/browser/prerender/prerender_contents.h" |
23 #include "chrome/browser/prerender/prerender_final_status.h" | 25 #include "chrome/browser/prerender/prerender_final_status.h" |
24 #include "chrome/browser/prerender/prerender_origin.h" | 26 #include "chrome/browser/prerender/prerender_origin.h" |
25 #include "chrome/browser/profiles/profile_keyed_service.h" | 27 #include "chrome/browser/profiles/profile_keyed_service.h" |
26 #include "googleurl/src/gurl.h" | 28 #include "googleurl/src/gurl.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
48 return reinterpret_cast<std::size_t>(value); | 50 return reinterpret_cast<std::size_t>(value); |
49 } | 51 } |
50 }; | 52 }; |
51 } | 53 } |
52 | 54 |
53 #endif | 55 #endif |
54 | 56 |
55 namespace prerender { | 57 namespace prerender { |
56 | 58 |
57 class PrerenderCondition; | 59 class PrerenderCondition; |
60 class PrerenderHandle; | |
58 class PrerenderHistograms; | 61 class PrerenderHistograms; |
59 class PrerenderHistory; | 62 class PrerenderHistory; |
60 class PrerenderLocalPredictor; | 63 class PrerenderLocalPredictor; |
61 class PrerenderTracker; | 64 class PrerenderTracker; |
62 | 65 |
63 // PrerenderManager is responsible for initiating and keeping prerendered | 66 // PrerenderManager is responsible for initiating and keeping prerendered |
64 // views of web pages. All methods must be called on the UI thread unless | 67 // views of web pages. All methods must be called on the UI thread unless |
65 // indicated otherwise. | 68 // indicated otherwise. |
66 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, | 69 class PrerenderManager : public base::SupportsWeakPtr<PrerenderManager>, |
67 public base::NonThreadSafe, | 70 public base::NonThreadSafe, |
(...skipping 26 matching lines...) Expand all Loading... | |
94 PrerenderManager(Profile* profile, PrerenderTracker* prerender_tracker); | 97 PrerenderManager(Profile* profile, PrerenderTracker* prerender_tracker); |
95 | 98 |
96 virtual ~PrerenderManager(); | 99 virtual ~PrerenderManager(); |
97 | 100 |
98 // ProfileKeyedService implementation. | 101 // ProfileKeyedService implementation. |
99 virtual void Shutdown() OVERRIDE; | 102 virtual void Shutdown() OVERRIDE; |
100 | 103 |
101 // Entry points for adding prerenders. | 104 // Entry points for adding prerenders. |
102 | 105 |
103 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify | 106 // 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 | 107 // the RenderView that the prerender request came from. If |size| is empty, a |
105 // empty, and the current tab size will be used if it is. If the current | 108 // default from the PrerenderConfig is used. Returns a caller-owned |
106 // active tab size cannot be found, we use a default from PrerenderConfig. | 109 // PrerenderHandle* if the URL was added, NULL if it was not. If the launching |
107 // Returns true if the URL was added, false if it was not. | 110 // RenderView is itself prerendering, the prerender is added as a pending |
108 // If the launching RenderView is itself prerendering, the prerender is added | 111 // prerender. |
109 // as a pending prerender. | 112 PrerenderHandle* AddPrerenderFromLinkRelPrerender( |
110 bool 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 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. Returns a |
122 bool AddPrerenderFromOmnibox( | 124 // caller-owned PrerenderHandle*, or NULL. |
125 PrerenderHandle* AddPrerenderFromOmnibox( | |
123 const GURL& url, | 126 const GURL& url, |
124 content::SessionStorageNamespace* session_storage_namespace, | 127 content::SessionStorageNamespace* session_storage_namespace, |
125 gfx::Size size); | 128 const gfx::Size& size); |
126 | 129 |
127 // Request cancelation of a previously added prerender. If the |active_count_| | 130 // If |process_id| and |view_id| refer to a running prerender, destroy |
128 // of the prerender is one, it will be canceled. Otherwise, |active_count_| | 131 // it with |final_status|. |
129 // will be decremented by one. | |
130 void MaybeCancelPrerender(const GURL& url); | |
131 | |
132 // Destroy all prerenders for the given child route id pair and assign a final | |
133 // status to them. | |
134 virtual void DestroyPrerenderForRenderView(int process_id, | 132 virtual void DestroyPrerenderForRenderView(int process_id, |
135 int view_id, | 133 int view_id, |
136 FinalStatus final_status); | 134 FinalStatus final_status); |
137 | 135 |
138 // Cancels all active prerenders. | 136 // Cancels all active prerenders. |
139 void CancelAllPrerenders(); | 137 void CancelAllPrerenders(); |
140 | 138 |
141 // If |url| matches a valid prerendered page, try to swap it into | 139 // If |url| matches a valid prerendered page, try to swap it into |
142 // |web_contents| and merge browsing histories. Returns |true| if a | 140 // |web_contents| and merge browsing histories. Returns |true| if a |
143 // prerendered page is swapped in, |false| otherwise. | 141 // prerendered page is swapped in, |false| otherwise. |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
177 static const char* GetModeString(); | 175 static const char* GetModeString(); |
178 static bool IsPrerenderingPossible(); | 176 static bool IsPrerenderingPossible(); |
179 static bool ActuallyPrerendering(); | 177 static bool ActuallyPrerendering(); |
180 static bool IsControlGroup(); | 178 static bool IsControlGroup(); |
181 static bool IsNoUseGroup(); | 179 static bool IsNoUseGroup(); |
182 | 180 |
183 // Query the list of current prerender pages to see if the given web contents | 181 // Query the list of current prerender pages to see if the given web contents |
184 // is prerendering a page. | 182 // is prerendering a page. |
185 bool IsWebContentsPrerendering(content::WebContents* web_contents) const; | 183 bool IsWebContentsPrerendering(content::WebContents* web_contents) const; |
186 | 184 |
187 // Returns true if there is a prerendered page for the given URL and it has | |
188 // finished loading. Only valid if called before MaybeUsePrerenderedPage. | |
189 bool DidPrerenderFinishLoading(const GURL& url) const; | |
190 | |
191 // Maintaining and querying the set of WebContents belonging to this | 185 // Maintaining and querying the set of WebContents belonging to this |
192 // PrerenderManager that are currently showing prerendered pages. | 186 // PrerenderManager that are currently showing prerendered pages. |
193 void MarkWebContentsAsPrerendered(content::WebContents* web_contents); | 187 void MarkWebContentsAsPrerendered(content::WebContents* web_contents); |
194 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); | 188 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); |
195 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); | 189 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); |
196 bool IsWebContentsPrerendered(content::WebContents* web_contents) const; | 190 bool IsWebContentsPrerendered(content::WebContents* web_contents) const; |
197 bool WouldWebContentsBePrerendered(content::WebContents* web_contents) const; | 191 bool WouldWebContentsBePrerendered(content::WebContents* web_contents) const; |
198 | 192 |
199 // Checks whether |url| has been recently navigated to. | 193 // Checks whether |url| has been recently navigated to. |
200 bool HasRecentlyBeenNavigatedTo(const GURL& url); | 194 bool HasRecentlyBeenNavigatedTo(const GURL& url); |
(...skipping 29 matching lines...) Expand all Loading... | |
230 FinalStatus final_status) const; | 224 FinalStatus final_status) const; |
231 | 225 |
232 const Config& config() const { return config_; } | 226 const Config& config() const { return config_; } |
233 Config& mutable_config() { return config_; } | 227 Config& mutable_config() { return config_; } |
234 | 228 |
235 PrerenderTracker* prerender_tracker() { return prerender_tracker_; } | 229 PrerenderTracker* prerender_tracker() { return prerender_tracker_; } |
236 | 230 |
237 // Adds a condition. This is owned by the PrerenderManager. | 231 // Adds a condition. This is owned by the PrerenderManager. |
238 void AddCondition(const PrerenderCondition* condition); | 232 void AddCondition(const PrerenderCondition* condition); |
239 | 233 |
240 bool IsPendingEntry(const GURL& url) const; | |
241 | |
242 // Returns true if |url| matches any URLs being prerendered. | |
243 bool IsPrerendering(const GURL& url) const; | |
244 | |
245 // Records that some visible tab navigated (or was redirected) to the | 234 // Records that some visible tab navigated (or was redirected) to the |
246 // provided URL. | 235 // provided URL. |
247 void RecordNavigation(const GURL& url); | 236 void RecordNavigation(const GURL& url); |
248 | 237 |
249 Profile* profile() const { return profile_; } | 238 Profile* profile() const { return profile_; } |
250 | 239 |
251 PrerenderHistograms* histograms() const { return histograms_.get(); } | 240 PrerenderHistograms* histograms() const { return histograms_.get(); } |
252 | 241 |
253 protected: | 242 protected: |
243 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { | |
244 public: | |
245 // Constructor for a pending prerender, which will get its contents later. | |
246 explicit PrerenderData(PrerenderManager* manager); | |
247 | |
248 // Constructor for an active prerender. | |
249 PrerenderData(PrerenderManager* manager, PrerenderContents* contents); | |
250 | |
251 ~PrerenderData(); | |
252 | |
253 // Called from PrerenderHandle. | |
254 void OnNewHandle(); | |
255 void OnNavigateAway(); | |
256 void OnCancel(); | |
mmenke
2012/07/12 17:23:21
Think these are worth commenting on what they do.
gavinp
2012/07/13 12:02:22
I'm changing their names to make it more clear tha
| |
257 | |
258 PrerenderContents* contents() { return contents_; } | |
259 | |
260 private: | |
mmenke
2012/07/12 16:26:51
nit: Fix indent.
gavinp
2012/07/13 12:02:22
Done.
| |
261 friend class PrerenderManager; | |
262 | |
263 PrerenderManager* manager_; | |
264 PrerenderContents* contents_; | |
265 int handle_count_; | |
mmenke
2012/07/12 17:23:21
Suggest a comment for this, too. Something along
| |
266 | |
267 DISALLOW_COPY_AND_ASSIGN(PrerenderData); | |
268 }; | |
269 | |
254 void SetPrerenderContentsFactory( | 270 void SetPrerenderContentsFactory( |
255 PrerenderContents::Factory* prerender_contents_factory); | 271 PrerenderContents::Factory* prerender_contents_factory); |
256 | 272 |
273 // Adds a prerender from a pending Prerender, called by | |
274 // PrerenderContents::StartPendingPrerenders. | |
275 void StartPendingPrerender( | |
276 PrerenderHandle* existing_prerender_handle, | |
277 Origin origin, | |
278 int process_id, | |
279 const GURL& url, | |
280 const content::Referrer& referrer, | |
281 const gfx::Size& size, | |
282 content::SessionStorageNamespace* session_storage_namespace); | |
283 | |
284 void DestroyPendingPrerenderData(PrerenderData* pending_prerender_data); | |
285 | |
257 // Utility method that is called from the virtual Shutdown method on this | 286 // Utility method that is called from the virtual Shutdown method on this |
258 // class but is called directly from the TestPrerenderManager in the unit | 287 // class but is called directly from the TestPrerenderManager in the unit |
259 // tests. | 288 // tests. |
260 void DoShutdown(); | 289 void DoShutdown(); |
261 | 290 |
262 private: | 291 private: |
263 // Test that needs needs access to internal functions. | |
264 friend class PrerenderBrowserTest; | 292 friend class PrerenderBrowserTest; |
265 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, AliasURLTest); | 293 friend class PrerenderContents; |
266 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, CancelAllTest); | 294 friend class PrerenderHandle; |
267 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, | 295 friend class UnitTestPrerenderManager; |
268 CancelOmniboxRemovesOmniboxTest); | |
269 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, | |
270 CancelOmniboxDoesNotRemoveLinkTest); | |
271 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, ClearTest); | |
272 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, ControlGroup); | |
273 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, DropOldestRequestTest); | |
274 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, DropSecondRequestTest); | |
275 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, ExpireTest); | |
276 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, FoundTest); | |
277 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, FragmentMatchesFragmentTest); | |
278 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, FragmentMatchesPageTest); | |
279 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerAbandon); | |
280 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerAddTwiceAbandonTwice); | |
281 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerAddTwiceCancelTwice); | |
282 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, | |
283 LinkManagerAddTwiceCancelTwiceThenAbandonTwice); | |
284 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerCancel); | |
285 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerCancelThenAbandon); | |
286 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerCancelThenAddAgain); | |
287 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerCancelTwice); | |
288 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerExpireThenAddAgain); | |
289 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, LinkManagerExpireThenCancel); | |
290 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, NotSoRecentlyVisited); | |
291 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PageMatchesFragmentTest); | |
292 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PendingPrerenderTest); | |
293 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, PPLTDummy); | |
294 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RateLimitInWindowTest); | |
295 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RateLimitOutsideWindowTest); | |
296 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, RecentlyVisitedPPLTDummy); | |
297 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, SourceRenderViewClosed); | |
298 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, TwoElementPrerenderTest); | |
299 | 296 |
300 struct PrerenderContentsData; | 297 class OnCloseTabContentsDeleter; |
301 struct NavigationRecord; | 298 struct NavigationRecord; |
302 | 299 |
303 class OnCloseTabContentsDeleter; | |
304 | |
305 typedef std::list<PrerenderContentsData> PrerenderContentsDataList; | |
306 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; | 300 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; |
307 | 301 |
308 // Time window for which we record old navigations, in milliseconds. | 302 // Time window for which we record old navigations, in milliseconds. |
309 static const int kNavigationRecordWindowMs = 5000; | 303 static const int kNavigationRecordWindowMs = 5000; |
310 | 304 |
311 // Adds a prerender for |url| from referrer |referrer| initiated from the | 305 void OnCancelPrerenderHandle(PrerenderData* prerender_data); |
312 // child process specified by |child_id|. The |origin| specifies how the | 306 |
313 // prerender was added. If the |size| is empty, then | 307 // Adds a prerender for |url| from |referrer| initiated from the process |
314 // PrerenderContents::StartPrerendering will instead use the size of the | 308 // |child_id|. The |origin| specifies how the prerender was added. If |size| |
315 // currently active tab. If the current active tab size cannot be found, it | 309 // is empty, then PrerenderContents::StartPrerendering will instead use a |
316 // then uses a default from PrerenderConfig. | 310 // default from PrerenderConfig. Returns a PrerenderHandle*, owned by the |
317 bool AddPrerender( | 311 // caller, or NULL. |
312 PrerenderHandle* AddPrerender( | |
318 Origin origin, | 313 Origin origin, |
319 int child_id, | 314 int child_id, |
320 const GURL& url, | 315 const GURL& url, |
321 const content::Referrer& referrer, | 316 const content::Referrer& referrer, |
322 gfx::Size size, | 317 const gfx::Size& size, |
323 content::SessionStorageNamespace* session_storage_namespace); | 318 content::SessionStorageNamespace* session_storage_namespace); |
324 | 319 |
325 // Retrieves the PrerenderContents object for the specified URL, if it | 320 void StartSchedulingPeriodicCleanups(); |
326 // has been prerendered. The caller will then have ownership of the | 321 void StopSchedulingPeriodicCleanups(); |
327 // PrerenderContents object and is responsible for freeing it. | |
328 // Returns NULL if the specified URL has not been prerendered. | |
329 PrerenderContents* GetEntry(const GURL& url); | |
330 | 322 |
331 // Identical to GetEntry, with one exception: | 323 void EvictOldestPrerendersIfNecessary(); |
332 // The WebContents specified indicates the WC in which to swap the | |
333 // prerendering into. If the WebContents specified is the one | |
334 // to doing the prerendered itself, will return NULL. | |
335 PrerenderContents* GetEntryButNotSpecifiedWC(const GURL& url, | |
336 content::WebContents* wc); | |
337 | |
338 // Starts scheduling periodic cleanups. | |
339 void StartSchedulingPeriodicCleanups(); | |
340 // Stops scheduling periodic cleanups if they're no longer needed. | |
341 void MaybeStopSchedulingPeriodicCleanups(); | |
342 | 324 |
343 // Deletes stale and cancelled prerendered PrerenderContents, as well as | 325 // Deletes stale and cancelled prerendered PrerenderContents, as well as |
344 // WebContents that have been replaced by prerendered WebContents. | 326 // WebContents that have been replaced by prerendered WebContents. |
345 // Also identifies and kills PrerenderContents that use too much | 327 // Also identifies and kills PrerenderContents that use too much |
346 // resources. | 328 // resources. |
347 void PeriodicCleanup(); | 329 void PeriodicCleanup(); |
348 | 330 |
349 // Posts a task to call PeriodicCleanup. Results in quicker destruction of | 331 // Posts a task to call PeriodicCleanup. Results in quicker destruction of |
350 // objects. If |this| is deleted before the task is run, the task will | 332 // objects. If |this| is deleted before the task is run, the task will |
351 // automatically be cancelled. | 333 // automatically be cancelled. |
352 void PostCleanupTask(); | 334 void PostCleanupTask(); |
353 | 335 |
354 base::TimeDelta GetMaxAge() const; | 336 base::TimeDelta GetMaxAge() const; |
355 bool IsPrerenderElementFresh(const base::Time start) const; | 337 bool IsPrerenderFresh(base::TimeTicks start) const; |
356 void DeleteOldEntries(); | 338 void DeleteOldEntries(); |
357 virtual base::Time GetCurrentTime() const; | 339 virtual base::Time GetCurrentTime() const; |
358 virtual base::TimeTicks GetCurrentTimeTicks() const; | 340 virtual base::TimeTicks GetCurrentTimeTicks() const; |
359 virtual PrerenderContents* CreatePrerenderContents( | 341 virtual PrerenderContents* CreatePrerenderContents( |
360 const GURL& url, | 342 const GURL& url, |
361 const content::Referrer& referrer, | 343 const content::Referrer& referrer, |
362 Origin origin, | 344 Origin origin, |
363 uint8 experiment_id); | 345 uint8 experiment_id); |
364 | 346 |
365 // Deletes any PrerenderContents that have been added to the pending delete | 347 // Deletes any PrerenderContents that have been added to the pending delete |
366 // list. | 348 // list. |
367 void DeletePendingDeleteEntries(); | 349 void DeletePendingDeleteEntries(); |
368 | 350 |
369 // Finds the specified PrerenderContentsData/PrerenderContents and returns it, | 351 // Finds the active PrerenderData object for a running prerender matching |
370 // if it exists. Returns NULL otherwise. Unlike GetEntry, the | 352 // |url| and |session_storage_namespace|. |
371 // PrerenderManager maintains ownership of the PrerenderContents. | 353 PrerenderData* FindPrerenderData( |
372 PrerenderContentsData* FindEntryData(const GURL& url); | 354 const GURL& url, |
373 PrerenderContents* FindEntry(const GURL& url) const; | 355 const content::SessionStorageNamespace* session_storage_namespace); |
374 | 356 |
375 // Returns the iterator to the PrerenderContentsData entry that is being | 357 // If |child_id| and |route_id| correspond to a RenderView that is an active |
376 // prerendered from the given child route id pair. | 358 // prerender, returns the PrerenderData object for that prerender. Otherwise, |
377 PrerenderContentsDataList::iterator | 359 // returns NULL. |
378 FindPrerenderContentsForChildRouteIdPair( | 360 PrerenderData* FindPrerenderDataForChildAndRoute(int child_id, int route_id); |
379 const std::pair<int, int>& child_route_id_pair); | |
380 | 361 |
381 PrerenderContentsDataList::iterator | 362 // Given the |prerender_contents|, find the iterator in active_prerender_list_ |
382 FindPrerenderContentsForURL(const GURL& url); | 363 // correponding to the given prerender. |
364 std::list<linked_ptr<PrerenderData> >::iterator | |
365 FindIteratorForPrerenderContents(PrerenderContents* prerender_contents); | |
383 | 366 |
384 bool DoesRateLimitAllowPrerender() const; | 367 bool DoesRateLimitAllowPrerender() const; |
385 | 368 |
386 // Deletes old WebContents that have been replaced by prerendered ones. This | 369 // Deletes old WebContents that have been replaced by prerendered ones. This |
387 // is needed because they're replaced in a callback from the old WebContents, | 370 // is needed because they're replaced in a callback from the old WebContents, |
388 // so cannot immediately be deleted. | 371 // so cannot immediately be deleted. |
389 void DeleteOldTabContents(); | 372 void DeleteOldTabContents(); |
390 | 373 |
391 // Cleans up old NavigationRecord's. | 374 // Cleans up old NavigationRecord's. |
392 void CleanUpOldNavigations(); | 375 void CleanUpOldNavigations(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 // of the PrerenderManager. | 416 // of the PrerenderManager. |
434 bool enabled_; | 417 bool enabled_; |
435 | 418 |
436 static bool is_prefetch_enabled_; | 419 static bool is_prefetch_enabled_; |
437 | 420 |
438 // The profile that owns this PrerenderManager. | 421 // The profile that owns this PrerenderManager. |
439 Profile* profile_; | 422 Profile* profile_; |
440 | 423 |
441 PrerenderTracker* prerender_tracker_; | 424 PrerenderTracker* prerender_tracker_; |
442 | 425 |
443 // List of prerendered elements. | 426 // List of all running prerenders. It is kept sorted, in increasing order by |
444 PrerenderContentsDataList prerender_list_; | 427 // expiry time. This list owns the PrerenderData objects contained in it. |
428 std::list<linked_ptr<PrerenderData> > active_prerender_list_; | |
dominich
2012/07/12 16:16:48
are you using linked_ptr as ownership annotation h
gavinp
2012/07/13 12:02:22
Ownership annotation, and to save the deleting ite
| |
429 | |
430 // List of all pending prerenders. | |
431 std::list<linked_ptr<PrerenderData> > pending_prerender_list_; | |
445 | 432 |
446 // List of recent navigations in this profile, sorted by ascending | 433 // List of recent navigations in this profile, sorted by ascending |
447 // navigate_time_. | 434 // navigate_time_. |
448 std::list<NavigationRecord> navigations_; | 435 std::list<NavigationRecord> navigations_; |
449 | 436 |
450 // List of prerender elements to be deleted | 437 // List of prerender elements to be deleted |
451 std::list<PrerenderContents*> pending_delete_list_; | 438 std::list<PrerenderContents*> pending_delete_list_; |
452 | 439 |
453 // Set of WebContents which are currently displaying a prerendered page. | 440 // Set of WebContents which are currently displaying a prerendered page. |
454 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; | 441 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 | 483 |
497 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 484 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
498 }; | 485 }; |
499 | 486 |
500 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 487 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
501 int render_process_id); | 488 int render_process_id); |
502 | 489 |
503 } // namespace prerender | 490 } // namespace prerender |
504 | 491 |
505 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 492 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |