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