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" |
20 #include "base/timer.h" | 21 #include "base/timer.h" |
21 #include "chrome/browser/prerender/prerender_config.h" | 22 #include "chrome/browser/prerender/prerender_config.h" |
22 #include "chrome/browser/prerender/prerender_contents.h" | 23 #include "chrome/browser/prerender/prerender_contents.h" |
23 #include "chrome/browser/prerender/prerender_final_status.h" | 24 #include "chrome/browser/prerender/prerender_final_status.h" |
25 #include "chrome/browser/prerender/prerender_handle.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" |
27 | 29 |
28 class Profile; | 30 class Profile; |
29 | 31 |
30 namespace base { | 32 namespace base { |
31 class DictionaryValue; | 33 class DictionaryValue; |
32 } | 34 } |
33 | 35 |
34 namespace content { | 36 namespace content { |
35 class WebContents; | 37 class WebContents; |
36 } | 38 } |
37 | 39 |
38 namespace gfx { | 40 namespace gfx { |
39 class Size; | 41 class Size; |
mmenke
2012/07/09 18:06:57
Know this is pre-existing code, but since it's bei
gavinp
2012/07/11 17:04:00
Mooted, as I went to the reference.
| |
40 } | 42 } |
41 | 43 |
42 #if defined(COMPILER_GCC) | 44 #if defined(COMPILER_GCC) |
43 | 45 |
44 namespace BASE_HASH_NAMESPACE { | 46 namespace BASE_HASH_NAMESPACE { |
45 template <> | 47 template <> |
46 struct hash<content::WebContents*> { | 48 struct hash<content::WebContents*> { |
47 std::size_t operator()(content::WebContents* value) const { | 49 std::size_t operator()(content::WebContents* value) const { |
48 return reinterpret_cast<std::size_t>(value); | 50 return reinterpret_cast<std::size_t>(value); |
49 } | 51 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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. The |size| may be |
105 // empty, and the current tab size will be used if it is. If the current | 107 // empty, and the current tab size will be used if it is. If the current |
106 // active tab size cannot be found, we use a default from PrerenderConfig. | 108 // active tab size cannot be found, we use a default from PrerenderConfig. |
107 // Returns true if the URL was added, false if it was not. | 109 // Returns a caller owned PrerenderHandle* if the URL was added, NULL if it |
mmenke
2012/07/09 18:06:57
nit: believe this should be caller-owned here and
gavinp
2012/07/11 17:04:00
Done.
| |
108 // If the launching RenderView is itself prerendering, the prerender is added | 110 // was not. If the launching RenderView is itself prerendering, the prerender |
109 // as a pending prerender. | 111 // is added as a pending prerender. |
110 bool AddPrerenderFromLinkRelPrerender( | 112 PrerenderHandle* AddPrerenderFromLinkRelPrerender( |
111 int process_id, | 113 int process_id, |
112 int route_id, | 114 int route_id, |
113 const GURL& url, | 115 const GURL& url, |
114 const content::Referrer& referrer, | 116 const content::Referrer& referrer, |
115 gfx::Size size); | 117 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*. |
mmenke
2012/07/09 18:06:57
nit: or NULL.
gavinp
2012/07/11 17:04:00
Done.
| |
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 gfx::Size size); |
126 | 129 |
127 // Request cancelation of a previously added prerender. If the |active_count_| | |
128 // of the prerender is one, it will be canceled. Otherwise, |active_count_| | |
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 | 130 // Destroy all prerenders for the given child route id pair and assign a final |
133 // status to them. | 131 // status to them. |
mmenke
2012/07/10 18:01:13
This comment looks wrong to me. From both the old
gavinp
2012/07/11 17:04:00
Done.
| |
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 friend class PrerenderContents; | |
244 friend class PrerenderHandle; | |
mmenke
2012/07/09 18:06:57
All friends should be together, in the private sec
gavinp
2012/07/11 17:04:00
Done.
| |
245 | |
254 void SetPrerenderContentsFactory( | 246 void SetPrerenderContentsFactory( |
255 PrerenderContents::Factory* prerender_contents_factory); | 247 PrerenderContents::Factory* prerender_contents_factory); |
256 | 248 |
249 // Adds a prerender from a pending Prerender, called by | |
250 // PrerenderContents::StartPendingPrerenders. | |
251 void StartPendingPrerender( | |
252 PrerenderHandle* existing_prerender_handle, | |
253 Origin origin, | |
254 int process_id, | |
255 const GURL& url, | |
256 const content::Referrer& referrer, | |
257 const gfx::Size& size, | |
258 content::SessionStorageNamespace* session_storage_namespace); | |
mmenke
2012/07/09 18:06:57
The other functions take Sizes by value rather tha
gavinp
2012/07/11 17:04:00
Done.
| |
259 | |
260 void DestroyPendingPrerenderData( | |
261 PrerenderHandle::PrerenderData* pending_prerender_data); | |
262 | |
257 // Utility method that is called from the virtual Shutdown method on this | 263 // Utility method that is called from the virtual Shutdown method on this |
258 // class but is called directly from the TestPrerenderManager in the unit | 264 // class but is called directly from the TestPrerenderManager in the unit |
259 // tests. | 265 // tests. |
260 void DoShutdown(); | 266 void DoShutdown(); |
261 | 267 |
262 private: | 268 private: |
263 // Test that needs needs access to internal functions. | |
264 friend class PrerenderBrowserTest; | 269 friend class PrerenderBrowserTest; |
265 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, AliasURLTest); | 270 friend class UnitTestPrerenderManager; |
266 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, CancelAllTest); | |
267 FRIEND_TEST_ALL_PREFIXES(PrerenderTest, | |
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 | 271 |
300 struct PrerenderContentsData; | 272 class OnCloseTabContentsDeleter; |
301 struct NavigationRecord; | 273 struct NavigationRecord; |
302 | 274 |
303 class OnCloseTabContentsDeleter; | 275 typedef PrerenderHandle::PrerenderData PrerenderData; |
276 typedef std::map<const PrerenderHandle::PrerenderData*, | |
277 base::WeakPtrFactory<PrerenderHandle::PrerenderData>*> | |
mmenke
2012/07/09 18:06:57
nit: You typedefed PrerenderHandle::PrerenderData
dominich
2012/07/09 18:25:43
i asked for the typedef to be removed to make it c
gavinp
2012/07/11 17:04:00
Yeah, sorry. My new upload gets rid of not only th
| |
278 PrerenderWeakPtrFactoryMap; | |
304 | 279 |
305 typedef std::list<PrerenderContentsData> PrerenderContentsDataList; | |
306 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; | 280 typedef base::hash_map<content::WebContents*, bool> WouldBePrerenderedMap; |
307 | 281 |
308 // Time window for which we record old navigations, in milliseconds. | 282 // Time window for which we record old navigations, in milliseconds. |
309 static const int kNavigationRecordWindowMs = 5000; | 283 static const int kNavigationRecordWindowMs = 5000; |
310 | 284 |
311 // Adds a prerender for |url| from referrer |referrer| initiated from the | 285 // Adds a prerender for |url| from |referrer| initiated from the process |
312 // child process specified by |child_id|. The |origin| specifies how the | 286 // |child_id|. The |origin| specifies how the prerender was added. If |size| |
313 // prerender was added. If the |size| is empty, then | 287 // is empty, then PrerenderContents::StartPrerendering will instead use the |
314 // PrerenderContents::StartPrerendering will instead use the size of the | 288 // size of the currently active tab. If the current active tab size cannot be |
315 // currently active tab. If the current active tab size cannot be found, it | 289 // found, it then uses a default from PrerenderConfig. Returns a |
316 // then uses a default from PrerenderConfig. | 290 // PrerenderHandle*, owned by the caller. |
mmenke
2012/07/09 18:06:57
Or NULL
gavinp
2012/07/11 17:04:00
Done.
| |
317 bool AddPrerender( | 291 PrerenderHandle* AddPrerender( |
318 Origin origin, | 292 Origin origin, |
319 int child_id, | 293 int child_id, |
320 const GURL& url, | 294 const GURL& url, |
321 const content::Referrer& referrer, | 295 const content::Referrer& referrer, |
322 gfx::Size size, | 296 gfx::Size size, |
323 content::SessionStorageNamespace* session_storage_namespace); | 297 content::SessionStorageNamespace* session_storage_namespace); |
324 | 298 |
325 // Retrieves the PrerenderContents object for the specified URL, if it | 299 void StartSchedulingPeriodicCleanups(); |
326 // has been prerendered. The caller will then have ownership of the | 300 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 | 301 |
331 // Identical to GetEntry, with one exception: | 302 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 | 303 |
343 // Deletes stale and cancelled prerendered PrerenderContents, as well as | 304 // Deletes stale and cancelled prerendered PrerenderContents, as well as |
344 // WebContents that have been replaced by prerendered WebContents. | 305 // WebContents that have been replaced by prerendered WebContents. |
345 // Also identifies and kills PrerenderContents that use too much | 306 // Also identifies and kills PrerenderContents that use too much |
346 // resources. | 307 // resources. |
347 void PeriodicCleanup(); | 308 void PeriodicCleanup(); |
348 | 309 |
349 // Posts a task to call PeriodicCleanup. Results in quicker destruction of | 310 // 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 | 311 // objects. If |this| is deleted before the task is run, the task will |
351 // automatically be cancelled. | 312 // automatically be cancelled. |
352 void PostCleanupTask(); | 313 void PostCleanupTask(); |
353 | 314 |
354 base::TimeDelta GetMaxAge() const; | 315 base::TimeDelta GetMaxAge() const; |
355 bool IsPrerenderElementFresh(const base::Time start) const; | 316 bool IsPrerenderFresh(base::TimeTicks start) const; |
356 void DeleteOldEntries(); | 317 void DeleteOldEntries(); |
357 virtual base::Time GetCurrentTime() const; | 318 virtual base::Time GetCurrentTime() const; |
358 virtual base::TimeTicks GetCurrentTimeTicks() const; | 319 virtual base::TimeTicks GetCurrentTimeTicks() const; |
359 virtual PrerenderContents* CreatePrerenderContents( | 320 virtual PrerenderContents* CreatePrerenderContents( |
360 const GURL& url, | 321 const GURL& url, |
361 const content::Referrer& referrer, | 322 const content::Referrer& referrer, |
362 Origin origin, | 323 Origin origin, |
363 uint8 experiment_id); | 324 uint8 experiment_id); |
364 | 325 |
365 // Deletes any PrerenderContents that have been added to the pending delete | 326 // Deletes any PrerenderContents that have been added to the pending delete |
366 // list. | 327 // list. |
367 void DeletePendingDeleteEntries(); | 328 void DeletePendingDeleteEntries(); |
368 | 329 |
369 // Finds the specified PrerenderContentsData/PrerenderContents and returns it, | 330 PrerenderHandle* CreatePrerenderHandleForPrerenderData( |
370 // if it exists. Returns NULL otherwise. Unlike GetEntry, the | 331 PrerenderHandle::PrerenderData* prerender_data); |
mmenke
2012/07/09 18:06:57
nit: All of these should just be PrerenderData, u
gavinp
2012/07/11 17:04:00
Done.
| |
371 // PrerenderManager maintains ownership of the PrerenderContents. | |
372 PrerenderContentsData* FindEntryData(const GURL& url); | |
373 PrerenderContents* FindEntry(const GURL& url) const; | |
374 | 332 |
375 // Returns the iterator to the PrerenderContentsData entry that is being | 333 void InvalidatePrerenderHandlesForPrerenderData( |
376 // prerendered from the given child route id pair. | 334 const PrerenderHandle::PrerenderData& prerender_data); |
377 PrerenderContentsDataList::iterator | |
378 FindPrerenderContentsForChildRouteIdPair( | |
379 const std::pair<int, int>& child_route_id_pair); | |
380 | 335 |
381 PrerenderContentsDataList::iterator | 336 // Finds the active PrerenderData object for a running prerender matching |
382 FindPrerenderContentsForURL(const GURL& url); | 337 // |url| and |session_storage_namespace|. |
338 PrerenderHandle::PrerenderData* FindPrerenderData( | |
339 const GURL& url, | |
340 const content::SessionStorageNamespace* session_storage_namespace); | |
341 | |
342 // Finds the active PrerenderData object for a running prerender corresponding | |
343 // to the renderer process |child_id| and the render view in |route_id|. | |
mmenke
2012/07/09 18:06:57
This comment could just as easily mean a prerender
gavinp
2012/07/11 17:04:00
Done.
| |
344 PrerenderHandle::PrerenderData* FindPrerenderDataForChildAndRoute( | |
345 int child_id, | |
346 int route_id); | |
347 | |
348 // Given the |prerender_contents|, find the iterator in active_prerender_list_ | |
349 // correponding to that running prerender. | |
mmenke
2012/07/09 18:06:57
nit: "that running" -> "the given active"
gavinp
2012/07/11 17:04:00
Done.
| |
350 std::list<PrerenderHandle::PrerenderData>::iterator | |
351 FindIteratorForPrerenderContents(PrerenderContents* prerender_contents); | |
383 | 352 |
384 bool DoesRateLimitAllowPrerender() const; | 353 bool DoesRateLimitAllowPrerender() const; |
385 | 354 |
386 // Deletes old WebContents that have been replaced by prerendered ones. This | 355 // 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, | 356 // is needed because they're replaced in a callback from the old WebContents, |
388 // so cannot immediately be deleted. | 357 // so cannot immediately be deleted. |
389 void DeleteOldTabContents(); | 358 void DeleteOldTabContents(); |
390 | 359 |
391 // Cleans up old NavigationRecord's. | 360 // Cleans up old NavigationRecord's. |
392 void CleanUpOldNavigations(); | 361 void CleanUpOldNavigations(); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
433 // of the PrerenderManager. | 402 // of the PrerenderManager. |
434 bool enabled_; | 403 bool enabled_; |
435 | 404 |
436 static bool is_prefetch_enabled_; | 405 static bool is_prefetch_enabled_; |
437 | 406 |
438 // The profile that owns this PrerenderManager. | 407 // The profile that owns this PrerenderManager. |
439 Profile* profile_; | 408 Profile* profile_; |
440 | 409 |
441 PrerenderTracker* prerender_tracker_; | 410 PrerenderTracker* prerender_tracker_; |
442 | 411 |
443 // List of prerendered elements. | 412 // List of all running prerenders. |
444 PrerenderContentsDataList prerender_list_; | 413 // It is kept sorted, in increasing order by expiry time. The STL list was |
414 // chosen because it does not move items in memory (this lets handles continue | |
415 // to point to their PrerenderData). | |
416 std::list<PrerenderHandle::PrerenderData> active_prerender_list_; | |
417 | |
418 // List of all pending prerenders. | |
419 std::list<PrerenderHandle::PrerenderData> pending_prerender_list_; | |
420 | |
421 // The prerenders in the above lists need WeakPtrs to instantiate handles. We | |
422 // keep the factories for those WeakPtrs here for the lifetime of each element | |
423 // in either list. In a perfect world, these factories would be a part of | |
424 // PrerenderHandle::PrerenderData, but that would then make the copy semantics | |
425 // of PrerenderHandle::PrerenderData quite confusing (copy everything except | |
426 // for the WeakPtrFactory). Storing this map externally is a least bad | |
427 // compromise. | |
428 PrerenderWeakPtrFactoryMap prerender_weak_ptr_factory_map_; | |
445 | 429 |
446 // List of recent navigations in this profile, sorted by ascending | 430 // List of recent navigations in this profile, sorted by ascending |
447 // navigate_time_. | 431 // navigate_time_. |
448 std::list<NavigationRecord> navigations_; | 432 std::list<NavigationRecord> navigations_; |
449 | 433 |
450 // List of prerender elements to be deleted | 434 // List of prerender elements to be deleted |
451 std::list<PrerenderContents*> pending_delete_list_; | 435 std::list<PrerenderContents*> pending_delete_list_; |
452 | 436 |
453 // Set of WebContents which are currently displaying a prerendered page. | 437 // Set of WebContents which are currently displaying a prerendered page. |
454 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; | 438 base::hash_set<content::WebContents*> prerendered_tab_contents_set_; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
496 | 480 |
497 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 481 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
498 }; | 482 }; |
499 | 483 |
500 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 484 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
501 int render_process_id); | 485 int render_process_id); |
502 | 486 |
503 } // namespace prerender | 487 } // namespace prerender |
504 | 488 |
505 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 489 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |