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" |
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" |
(...skipping 28 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 26 matching lines...) Expand all Loading... | |
94 PrerenderManager(Profile* profile, PrerenderTracker* prerender_tracker); | 96 PrerenderManager(Profile* profile, PrerenderTracker* prerender_tracker); |
95 | 97 |
96 virtual ~PrerenderManager(); | 98 virtual ~PrerenderManager(); |
97 | 99 |
98 // ProfileKeyedService implementation. | 100 // ProfileKeyedService implementation. |
99 virtual void Shutdown() OVERRIDE; | 101 virtual void Shutdown() OVERRIDE; |
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. If |size| is empty, a |
105 // 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 |
106 // 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 |
107 // Returns true if the URL was added, false if it was not. | 109 // RenderView is itself prerendering, the prerender is added as a pending |
108 // If the launching RenderView is itself prerendering, the prerender is added | 110 // prerender. |
109 // as a pending prerender. | 111 PrerenderHandle* AddPrerenderFromLinkRelPrerender( |
110 bool AddPrerenderFromLinkRelPrerender( | |
111 int process_id, | 112 int process_id, |
112 int route_id, | 113 int route_id, |
113 const GURL& url, | 114 const GURL& url, |
114 const content::Referrer& referrer, | 115 const content::Referrer& referrer, |
115 gfx::Size size); | 116 const gfx::Size& size); |
116 | 117 |
117 // 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 |
118 // 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 |
119 // 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 |
120 // those. The |session_storage_namespace| matches the namespace of the active | 121 // those. The |session_storage_namespace| matches the namespace of the active |
121 // 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 |
122 bool AddPrerenderFromOmnibox( | 123 // caller-owned PrerenderHandle*, or NULL. |
124 PrerenderHandle* AddPrerenderFromOmnibox( | |
123 const GURL& url, | 125 const GURL& url, |
124 content::SessionStorageNamespace* session_storage_namespace, | 126 content::SessionStorageNamespace* session_storage_namespace, |
125 gfx::Size size); | 127 const gfx::Size& size); |
126 | 128 |
127 // Request cancelation of a previously added prerender. If the |active_count_| | 129 // 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_| | 130 // 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, | 131 virtual void DestroyPrerenderForRenderView(int process_id, |
135 int view_id, | 132 int view_id, |
136 FinalStatus final_status); | 133 FinalStatus final_status); |
137 | 134 |
138 // Cancels all active prerenders. | 135 // Cancels all active prerenders. |
139 void CancelAllPrerenders(); | 136 void CancelAllPrerenders(); |
140 | 137 |
141 // 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 |
142 // |web_contents| and merge browsing histories. Returns |true| if a | 139 // |web_contents| and merge browsing histories. Returns |true| if a |
143 // 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... | |
177 static const char* GetModeString(); | 174 static const char* GetModeString(); |
178 static bool IsPrerenderingPossible(); | 175 static bool IsPrerenderingPossible(); |
179 static bool ActuallyPrerendering(); | 176 static bool ActuallyPrerendering(); |
180 static bool IsControlGroup(); | 177 static bool IsControlGroup(); |
181 static bool IsNoUseGroup(); | 178 static bool IsNoUseGroup(); |
182 | 179 |
183 // 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 |
184 // is prerendering a page. | 181 // is prerendering a page. |
185 bool IsWebContentsPrerendering(content::WebContents* web_contents) const; | 182 bool IsWebContentsPrerendering(content::WebContents* web_contents) const; |
186 | 183 |
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 | 184 // Maintaining and querying the set of WebContents belonging to this |
192 // PrerenderManager that are currently showing prerendered pages. | 185 // PrerenderManager that are currently showing prerendered pages. |
193 void MarkWebContentsAsPrerendered(content::WebContents* web_contents); | 186 void MarkWebContentsAsPrerendered(content::WebContents* web_contents); |
194 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); | 187 void MarkWebContentsAsWouldBePrerendered(content::WebContents* web_contents); |
195 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); | 188 void MarkWebContentsAsNotPrerendered(content::WebContents* web_contents); |
196 bool IsWebContentsPrerendered(content::WebContents* web_contents) const; | 189 bool IsWebContentsPrerendered(content::WebContents* web_contents) const; |
197 bool WouldWebContentsBePrerendered(content::WebContents* web_contents) const; | 190 bool WouldWebContentsBePrerendered(content::WebContents* web_contents) const; |
198 | 191 |
199 // Checks whether |url| has been recently navigated to. | 192 // Checks whether |url| has been recently navigated to. |
200 bool HasRecentlyBeenNavigatedTo(const GURL& url); | 193 bool HasRecentlyBeenNavigatedTo(const GURL& url); |
(...skipping 29 matching lines...) Expand all Loading... | |
230 FinalStatus final_status) const; | 223 FinalStatus final_status) const; |
231 | 224 |
232 const Config& config() const { return config_; } | 225 const Config& config() const { return config_; } |
233 Config& mutable_config() { return config_; } | 226 Config& mutable_config() { return config_; } |
234 | 227 |
235 PrerenderTracker* prerender_tracker() { return prerender_tracker_; } | 228 PrerenderTracker* prerender_tracker() { return prerender_tracker_; } |
236 | 229 |
237 // Adds a condition. This is owned by the PrerenderManager. | 230 // Adds a condition. This is owned by the PrerenderManager. |
238 void AddCondition(const PrerenderCondition* condition); | 231 void AddCondition(const PrerenderCondition* condition); |
239 | 232 |
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 | 233 // Records that some visible tab navigated (or was redirected) to the |
246 // provided URL. | 234 // provided URL. |
247 void RecordNavigation(const GURL& url); | 235 void RecordNavigation(const GURL& url); |
248 | 236 |
249 Profile* profile() const { return profile_; } | 237 Profile* profile() const { return profile_; } |
250 | 238 |
251 PrerenderHistograms* histograms() const { return histograms_.get(); } | 239 PrerenderHistograms* histograms() const { return histograms_.get(); } |
252 | 240 |
253 protected: | 241 protected: |
242 struct PrerenderData { | |
243 explicit PrerenderData(PrerenderManager* manager); | |
244 explicit PrerenderData(const PrerenderData& other); | |
245 PrerenderData(PrerenderManager* manager, | |
246 PrerenderContents* contents); | |
mmenke
2012/07/11 18:40:05
nit: May fit on a single line.
gavinp
2012/07/11 21:19:30
Done.
| |
247 ~PrerenderData(); | |
248 | |
249 PrerenderManager* manager; | |
250 PrerenderContents* contents; | |
251 int instance_count; | |
252 | |
253 const scoped_ptr<base::WeakPtrFactory<PrerenderData> > weak_ptr_factory; | |
mmenke
2012/07/11 18:40:05
I don't believe this needs to be a scoped_ptr.
gavinp
2012/07/11 21:19:30
Mooted once I gave up on the lists.
| |
254 }; | |
255 | |
254 void SetPrerenderContentsFactory( | 256 void SetPrerenderContentsFactory( |
255 PrerenderContents::Factory* prerender_contents_factory); | 257 PrerenderContents::Factory* prerender_contents_factory); |
256 | 258 |
259 // Adds a prerender from a pending Prerender, called by | |
260 // PrerenderContents::StartPendingPrerenders. | |
261 void StartPendingPrerender( | |
262 PrerenderHandle* existing_prerender_handle, | |
263 Origin origin, | |
264 int process_id, | |
265 const GURL& url, | |
266 const content::Referrer& referrer, | |
267 const gfx::Size& size, | |
268 content::SessionStorageNamespace* session_storage_namespace); | |
269 | |
270 void DestroyPendingPrerenderData( | |
271 PrerenderData* pending_prerender_data); | |
272 | |
257 // Utility method that is called from the virtual Shutdown method on this | 273 // Utility method that is called from the virtual Shutdown method on this |
258 // class but is called directly from the TestPrerenderManager in the unit | 274 // class but is called directly from the TestPrerenderManager in the unit |
259 // tests. | 275 // tests. |
260 void DoShutdown(); | 276 void DoShutdown(); |
261 | 277 |
262 private: | 278 private: |
263 // Test that needs needs access to internal functions. | |
264 friend class PrerenderBrowserTest; | 279 friend class PrerenderBrowserTest; |
265 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, AliasURLTest); | 280 friend class PrerenderContents; |
266 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, CancelAllTest); | 281 friend class PrerenderHandle; |
267 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, | 282 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 | 283 |
300 struct PrerenderContentsData; | 284 class OnCloseTabContentsDeleter; |
301 struct NavigationRecord; | 285 struct NavigationRecord; |
302 | 286 |
303 class OnCloseTabContentsDeleter; | |
304 | |
305 typedef std::list<PrerenderContentsData> PrerenderContentsDataList; | |
306 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; | 287 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; |
307 | 288 |
308 // Time window for which we record old navigations, in milliseconds. | 289 // Time window for which we record old navigations, in milliseconds. |
309 static const int kNavigationRecordWindowMs = 5000; | 290 static const int kNavigationRecordWindowMs = 5000; |
310 | 291 |
311 // Adds a prerender for |url| from referrer |referrer| initiated from the | 292 // Adds a prerender for |url| from |referrer| initiated from the process |
312 // child process specified by |child_id|. The |origin| specifies how the | 293 // |child_id|. The |origin| specifies how the prerender was added. If |size| |
313 // prerender was added. If the |size| is empty, then | 294 // is empty, then PrerenderContents::StartPrerendering will instead use a |
314 // PrerenderContents::StartPrerendering will instead use the size of the | 295 // default from PrerenderConfig. Returns a PrerenderHandle*, owned by the |
315 // currently active tab. If the current active tab size cannot be found, it | 296 // caller, or NULL. |
316 // then uses a default from PrerenderConfig. | 297 PrerenderHandle* AddPrerender( |
317 bool AddPrerender( | |
318 Origin origin, | 298 Origin origin, |
319 int child_id, | 299 int child_id, |
320 const GURL& url, | 300 const GURL& url, |
321 const content::Referrer& referrer, | 301 const content::Referrer& referrer, |
322 gfx::Size size, | 302 const gfx::Size& size, |
323 content::SessionStorageNamespace* session_storage_namespace); | 303 content::SessionStorageNamespace* session_storage_namespace); |
324 | 304 |
325 // Retrieves the PrerenderContents object for the specified URL, if it | 305 void StartSchedulingPeriodicCleanups(); |
326 // has been prerendered. The caller will then have ownership of the | 306 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 | 307 |
331 // Identical to GetEntry, with one exception: | 308 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 | 309 |
343 // Deletes stale and cancelled prerendered PrerenderContents, as well as | 310 // Deletes stale and cancelled prerendered PrerenderContents, as well as |
344 // WebContents that have been replaced by prerendered WebContents. | 311 // WebContents that have been replaced by prerendered WebContents. |
345 // Also identifies and kills PrerenderContents that use too much | 312 // Also identifies and kills PrerenderContents that use too much |
346 // resources. | 313 // resources. |
347 void PeriodicCleanup(); | 314 void PeriodicCleanup(); |
348 | 315 |
349 // Posts a task to call PeriodicCleanup. Results in quicker destruction of | 316 // 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 | 317 // objects. If |this| is deleted before the task is run, the task will |
351 // automatically be cancelled. | 318 // automatically be cancelled. |
352 void PostCleanupTask(); | 319 void PostCleanupTask(); |
353 | 320 |
354 base::TimeDelta GetMaxAge() const; | 321 base::TimeDelta GetMaxAge() const; |
355 bool IsPrerenderElementFresh(const base::Time start) const; | 322 bool IsPrerenderFresh(base::TimeTicks start) const; |
356 void DeleteOldEntries(); | 323 void DeleteOldEntries(); |
357 virtual base::Time GetCurrentTime() const; | 324 virtual base::Time GetCurrentTime() const; |
358 virtual base::TimeTicks GetCurrentTimeTicks() const; | 325 virtual base::TimeTicks GetCurrentTimeTicks() const; |
359 virtual PrerenderContents* CreatePrerenderContents( | 326 virtual PrerenderContents* CreatePrerenderContents( |
360 const GURL& url, | 327 const GURL& url, |
361 const content::Referrer& referrer, | 328 const content::Referrer& referrer, |
362 Origin origin, | 329 Origin origin, |
363 uint8 experiment_id); | 330 uint8 experiment_id); |
364 | 331 |
365 // Deletes any PrerenderContents that have been added to the pending delete | 332 // Deletes any PrerenderContents that have been added to the pending delete |
366 // list. | 333 // list. |
367 void DeletePendingDeleteEntries(); | 334 void DeletePendingDeleteEntries(); |
368 | 335 |
369 // Finds the specified PrerenderContentsData/PrerenderContents and returns it, | 336 // Finds the active PrerenderData object for a running prerender matching |
370 // if it exists. Returns NULL otherwise. Unlike GetEntry, the | 337 // |url| and |session_storage_namespace|. |
371 // PrerenderManager maintains ownership of the PrerenderContents. | 338 PrerenderData* FindPrerenderData( |
372 PrerenderContentsData* FindEntryData(const GURL& url); | 339 const GURL& url, |
373 PrerenderContents* FindEntry(const GURL& url) const; | 340 const content::SessionStorageNamespace* session_storage_namespace); |
374 | 341 |
375 // Returns the iterator to the PrerenderContentsData entry that is being | 342 // If |child_id| and |route_id| correspond to a RenderView that is an active |
376 // prerendered from the given child route id pair. | 343 // prerender, returns the PrerenderData object for that prerender. Otherwise, |
377 PrerenderContentsDataList::iterator | 344 // returns NULL. |
378 FindPrerenderContentsForChildRouteIdPair( | 345 PrerenderData* FindPrerenderDataForChildAndRoute( |
379 const std::pair<int, int>& child_route_id_pair); | 346 int child_id, |
347 int route_id); | |
mmenke
2012/07/11 18:40:05
nit: May fit onto one line now.
gavinp
2012/07/11 21:19:30
Done.
| |
380 | 348 |
381 PrerenderContentsDataList::iterator | 349 // Given the |prerender_contents|, find the iterator in active_prerender_list_ |
382 FindPrerenderContentsForURL(const GURL& url); | 350 // correponding to the given prerender. |
351 std::list<PrerenderData>::iterator | |
352 FindIteratorForPrerenderContents(PrerenderContents* prerender_contents); | |
383 | 353 |
384 bool DoesRateLimitAllowPrerender() const; | 354 bool DoesRateLimitAllowPrerender() const; |
385 | 355 |
386 // Deletes old WebContents that have been replaced by prerendered ones. This | 356 // 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, | 357 // is needed because they're replaced in a callback from the old WebContents, |
388 // so cannot immediately be deleted. | 358 // so cannot immediately be deleted. |
389 void DeleteOldTabContents(); | 359 void DeleteOldTabContents(); |
390 | 360 |
391 // Cleans up old NavigationRecord's. | 361 // Cleans up old NavigationRecord's. |
392 void CleanUpOldNavigations(); | 362 void CleanUpOldNavigations(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 // of the PrerenderManager. | 403 // of the PrerenderManager. |
434 bool enabled_; | 404 bool enabled_; |
435 | 405 |
436 static bool is_prefetch_enabled_; | 406 static bool is_prefetch_enabled_; |
437 | 407 |
438 // The profile that owns this PrerenderManager. | 408 // The profile that owns this PrerenderManager. |
439 Profile* profile_; | 409 Profile* profile_; |
440 | 410 |
441 PrerenderTracker* prerender_tracker_; | 411 PrerenderTracker* prerender_tracker_; |
442 | 412 |
443 // List of prerendered elements. | 413 // List of all running prerenders. |
444 PrerenderContentsDataList prerender_list_; | 414 // It is kept sorted, in increasing order by expiry time. The STL list was |
415 // chosen because it does not move items in memory (this lets handles continue | |
416 // to point to their PrerenderData). | |
417 std::list<PrerenderData> active_prerender_list_; | |
418 | |
419 // List of all pending prerenders. | |
420 std::list<PrerenderData> pending_prerender_list_; | |
445 | 421 |
446 // List of recent navigations in this profile, sorted by ascending | 422 // List of recent navigations in this profile, sorted by ascending |
447 // navigate_time_. | 423 // navigate_time_. |
448 std::list<NavigationRecord> navigations_; | 424 std::list<NavigationRecord> navigations_; |
449 | 425 |
450 // List of prerender elements to be deleted | 426 // List of prerender elements to be deleted |
451 std::list<PrerenderContents*> pending_delete_list_; | 427 std::list<PrerenderContents*> pending_delete_list_; |
452 | 428 |
453 // Set of WebContents which are currently displaying a prerendered page. | 429 // Set of WebContents which are currently displaying a prerendered page. |
454 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; | 430 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 | 472 |
497 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 473 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
498 }; | 474 }; |
499 | 475 |
500 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 476 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
501 int render_process_id); | 477 int render_process_id); |
502 | 478 |
503 } // namespace prerender | 479 } // namespace prerender |
504 | 480 |
505 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 481 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |