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 void OnNewHandle(); |
| 254 void OnCancel(); |
| 255 |
| 256 PrerenderContents* contents() { return contents_; } |
| 257 |
| 258 private: |
| 259 friend class PrerenderManager; |
| 260 |
| 261 PrerenderManager* manager_; |
| 262 PrerenderContents* contents_; |
| 263 int handle_count_; |
| 264 |
| 265 DISALLOW_COPY_AND_ASSIGN(PrerenderData); |
| 266 }; |
| 267 |
254 void SetPrerenderContentsFactory( | 268 void SetPrerenderContentsFactory( |
255 PrerenderContents::Factory* prerender_contents_factory); | 269 PrerenderContents::Factory* prerender_contents_factory); |
256 | 270 |
| 271 // Adds a prerender from a pending Prerender, called by |
| 272 // PrerenderContents::StartPendingPrerenders. |
| 273 void StartPendingPrerender( |
| 274 PrerenderHandle* existing_prerender_handle, |
| 275 Origin origin, |
| 276 int process_id, |
| 277 const GURL& url, |
| 278 const content::Referrer& referrer, |
| 279 const gfx::Size& size, |
| 280 content::SessionStorageNamespace* session_storage_namespace); |
| 281 |
257 // Utility method that is called from the virtual Shutdown method on this | 282 // Utility method that is called from the virtual Shutdown method on this |
258 // class but is called directly from the TestPrerenderManager in the unit | 283 // class but is called directly from the TestPrerenderManager in the unit |
259 // tests. | 284 // tests. |
260 void DoShutdown(); | 285 void DoShutdown(); |
261 | 286 |
262 private: | 287 private: |
263 // Test that needs needs access to internal functions. | |
264 friend class PrerenderBrowserTest; | 288 friend class PrerenderBrowserTest; |
265 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, AliasURLTest); | 289 friend class PrerenderContents; |
266 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, CancelAllTest); | 290 friend class PrerenderHandle; |
267 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, | 291 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 | 292 |
300 struct PrerenderContentsData; | 293 class OnCloseTabContentsDeleter; |
301 struct NavigationRecord; | 294 struct NavigationRecord; |
302 | 295 |
303 class OnCloseTabContentsDeleter; | |
304 | |
305 typedef std::list<PrerenderContentsData> PrerenderContentsDataList; | |
306 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; | 296 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; |
307 | 297 |
308 // Time window for which we record old navigations, in milliseconds. | 298 // Time window for which we record old navigations, in milliseconds. |
309 static const int kNavigationRecordWindowMs = 5000; | 299 static const int kNavigationRecordWindowMs = 5000; |
310 | 300 |
311 // Adds a prerender for |url| from referrer |referrer| initiated from the | 301 void OnCancelPrerenderHandle(PrerenderData* prerender_data); |
312 // child process specified by |child_id|. The |origin| specifies how the | 302 |
313 // prerender was added. If the |size| is empty, then | 303 // Adds a prerender for |url| from |referrer| initiated from the process |
314 // PrerenderContents::StartPrerendering will instead use the size of the | 304 // |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 | 305 // is empty, then PrerenderContents::StartPrerendering will instead use a |
316 // then uses a default from PrerenderConfig. | 306 // default from PrerenderConfig. Returns a PrerenderHandle*, owned by the |
317 bool AddPrerender( | 307 // caller, or NULL. |
| 308 PrerenderHandle* AddPrerender( |
318 Origin origin, | 309 Origin origin, |
319 int child_id, | 310 int child_id, |
320 const GURL& url, | 311 const GURL& url, |
321 const content::Referrer& referrer, | 312 const content::Referrer& referrer, |
322 gfx::Size size, | 313 const gfx::Size& size, |
323 content::SessionStorageNamespace* session_storage_namespace); | 314 content::SessionStorageNamespace* session_storage_namespace); |
324 | 315 |
325 // Retrieves the PrerenderContents object for the specified URL, if it | 316 void StartSchedulingPeriodicCleanups(); |
326 // has been prerendered. The caller will then have ownership of the | 317 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 | 318 |
331 // Identical to GetEntry, with one exception: | 319 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 | 320 |
343 // Deletes stale and cancelled prerendered PrerenderContents, as well as | 321 // Deletes stale and cancelled prerendered PrerenderContents, as well as |
344 // WebContents that have been replaced by prerendered WebContents. | 322 // WebContents that have been replaced by prerendered WebContents. |
345 // Also identifies and kills PrerenderContents that use too much | 323 // Also identifies and kills PrerenderContents that use too much |
346 // resources. | 324 // resources. |
347 void PeriodicCleanup(); | 325 void PeriodicCleanup(); |
348 | 326 |
349 // Posts a task to call PeriodicCleanup. Results in quicker destruction of | 327 // 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 | 328 // objects. If |this| is deleted before the task is run, the task will |
351 // automatically be cancelled. | 329 // automatically be cancelled. |
352 void PostCleanupTask(); | 330 void PostCleanupTask(); |
353 | 331 |
354 base::TimeDelta GetMaxAge() const; | 332 base::TimeDelta GetMaxAge() const; |
355 bool IsPrerenderElementFresh(const base::Time start) const; | 333 bool IsPrerenderFresh(base::TimeTicks start) const; |
356 void DeleteOldEntries(); | 334 void DeleteOldEntries(); |
357 virtual base::Time GetCurrentTime() const; | 335 virtual base::Time GetCurrentTime() const; |
358 virtual base::TimeTicks GetCurrentTimeTicks() const; | 336 virtual base::TimeTicks GetCurrentTimeTicks() const; |
359 virtual PrerenderContents* CreatePrerenderContents( | 337 virtual PrerenderContents* CreatePrerenderContents( |
360 const GURL& url, | 338 const GURL& url, |
361 const content::Referrer& referrer, | 339 const content::Referrer& referrer, |
362 Origin origin, | 340 Origin origin, |
363 uint8 experiment_id); | 341 uint8 experiment_id); |
364 | 342 |
365 // Deletes any PrerenderContents that have been added to the pending delete | 343 // Deletes any PrerenderContents that have been added to the pending delete |
366 // list. | 344 // list. |
367 void DeletePendingDeleteEntries(); | 345 void DeletePendingDeleteEntries(); |
368 | 346 |
369 // Finds the specified PrerenderContentsData/PrerenderContents and returns it, | 347 // Finds the active PrerenderData object for a running prerender matching |
370 // if it exists. Returns NULL otherwise. Unlike GetEntry, the | 348 // |url| and |session_storage_namespace|. |
371 // PrerenderManager maintains ownership of the PrerenderContents. | 349 PrerenderData* FindPrerenderData( |
372 PrerenderContentsData* FindEntryData(const GURL& url); | 350 const GURL& url, |
373 PrerenderContents* FindEntry(const GURL& url) const; | 351 const content::SessionStorageNamespace* session_storage_namespace); |
374 | 352 |
375 // Returns the iterator to the PrerenderContentsData entry that is being | 353 // If |child_id| and |route_id| correspond to a RenderView that is an active |
376 // prerendered from the given child route id pair. | 354 // prerender, returns the PrerenderData object for that prerender. Otherwise, |
377 PrerenderContentsDataList::iterator | 355 // returns NULL. |
378 FindPrerenderContentsForChildRouteIdPair( | 356 PrerenderData* FindPrerenderDataForChildAndRoute(int child_id, int route_id); |
379 const std::pair<int, int>& child_route_id_pair); | |
380 | 357 |
381 PrerenderContentsDataList::iterator | 358 // Given the |prerender_contents|, find the iterator in active_prerender_list_ |
382 FindPrerenderContentsForURL(const GURL& url); | 359 // correponding to the given prerender. |
| 360 std::list<linked_ptr<PrerenderData> >::iterator |
| 361 FindIteratorForPrerenderContents(PrerenderContents* prerender_contents); |
383 | 362 |
384 bool DoesRateLimitAllowPrerender() const; | 363 bool DoesRateLimitAllowPrerender() const; |
385 | 364 |
386 // Deletes old WebContents that have been replaced by prerendered ones. This | 365 // 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, | 366 // is needed because they're replaced in a callback from the old WebContents, |
388 // so cannot immediately be deleted. | 367 // so cannot immediately be deleted. |
389 void DeleteOldTabContents(); | 368 void DeleteOldTabContents(); |
390 | 369 |
391 // Cleans up old NavigationRecord's. | 370 // Cleans up old NavigationRecord's. |
392 void CleanUpOldNavigations(); | 371 void CleanUpOldNavigations(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 // of the PrerenderManager. | 412 // of the PrerenderManager. |
434 bool enabled_; | 413 bool enabled_; |
435 | 414 |
436 static bool is_prefetch_enabled_; | 415 static bool is_prefetch_enabled_; |
437 | 416 |
438 // The profile that owns this PrerenderManager. | 417 // The profile that owns this PrerenderManager. |
439 Profile* profile_; | 418 Profile* profile_; |
440 | 419 |
441 PrerenderTracker* prerender_tracker_; | 420 PrerenderTracker* prerender_tracker_; |
442 | 421 |
443 // List of prerendered elements. | 422 // List of all running prerenders. It is kept sorted, in increasing order by |
444 PrerenderContentsDataList prerender_list_; | 423 // expiry time. This list owns the PrerenderData objects contained in it. |
| 424 std::list<linked_ptr<PrerenderData> > active_prerender_list_; |
445 | 425 |
446 // List of recent navigations in this profile, sorted by ascending | 426 // List of recent navigations in this profile, sorted by ascending |
447 // navigate_time_. | 427 // navigate_time_. |
448 std::list<NavigationRecord> navigations_; | 428 std::list<NavigationRecord> navigations_; |
449 | 429 |
450 // List of prerender elements to be deleted | 430 // List of prerender elements to be deleted |
451 std::list<PrerenderContents*> pending_delete_list_; | 431 std::list<PrerenderContents*> pending_delete_list_; |
452 | 432 |
453 // Set of WebContents which are currently displaying a prerendered page. | 433 // Set of WebContents which are currently displaying a prerendered page. |
454 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; | 434 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 | 476 |
497 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 477 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
498 }; | 478 }; |
499 | 479 |
500 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 480 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
501 int render_process_id); | 481 int render_process_id); |
502 | 482 |
503 } // namespace prerender | 483 } // namespace prerender |
504 | 484 |
505 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 485 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |