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 <map> |
10 #include <string> | 10 #include <string> |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 // provided URL. | 260 // provided URL. |
261 void RecordNavigation(const GURL& url); | 261 void RecordNavigation(const GURL& url); |
262 | 262 |
263 Profile* profile() const { return profile_; } | 263 Profile* profile() const { return profile_; } |
264 | 264 |
265 protected: | 265 protected: |
266 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { | 266 class PrerenderData : public base::SupportsWeakPtr<PrerenderData> { |
267 public: | 267 public: |
268 struct OrderByExpiryTime; | 268 struct OrderByExpiryTime; |
269 | 269 |
270 // Constructor for a pending prerender, which will get its contents later. | |
271 explicit PrerenderData(PrerenderManager* manager); | |
272 | |
273 // Constructor for an active prerender. | |
274 PrerenderData(PrerenderManager* manager, | 270 PrerenderData(PrerenderManager* manager, |
275 PrerenderContents* contents, | 271 PrerenderContents* contents, |
276 base::TimeTicks expiry_time); | 272 base::TimeTicks expiry_time); |
277 | 273 |
278 ~PrerenderData(); | 274 ~PrerenderData(); |
279 | 275 |
280 // Turn this PrerenderData into a Match Complete replacement for itself, | 276 // Turn this PrerenderData into a Match Complete replacement for itself, |
281 // placing the current prerender contents into |to_delete_prerenders_|. | 277 // placing the current prerender contents into |to_delete_prerenders_|. |
282 void MakeIntoMatchCompleteReplacement(); | 278 void MakeIntoMatchCompleteReplacement(); |
283 | 279 |
284 // A new PrerenderHandle has been created for this PrerenderData. | 280 // A new PrerenderHandle has been created for this PrerenderData. |
285 void OnNewHandle(); | 281 void OnNewHandle(PrerenderHandle* prerender_handle); |
mmenke
2012/12/06 22:22:15
I think "OnHandleCreated" seems to fit in a bit mo
gavinp
2012/12/10 17:55:10
Done.
| |
286 | 282 |
287 // The launcher associated with a handle is navigating away from the context | 283 // The launcher associated with a handle is navigating away from the context |
288 // that launched this prerender. If the prerender is active, it may stay | 284 // that launched this prerender. If the prerender is active, it may stay |
289 // alive briefly though, in case we we going through a redirect chain that | 285 // alive briefly though, in case we we going through a redirect chain that |
290 // will eventually land at it. | 286 // will eventually land at it. |
291 void OnNavigateAwayByHandle(); | 287 void OnNavigateAwayByHandle(PrerenderHandle* prerender_handle); |
292 | 288 |
293 // The launcher associated with a handle has taken explicit action to cancel | 289 // The launcher associated with a handle has taken explicit action to cancel |
294 // this prerender. We may well destroy the prerender in this case if no | 290 // this prerender. We may well destroy the prerender in this case if no |
295 // other handles continue to track it. | 291 // other handles continue to track it. |
296 void OnCancelByHandle(); | 292 void OnCancelByHandle(PrerenderHandle* prerender_handle); |
mmenke
2012/12/06 22:22:15
I'd suggest OnHandleNavigatedAway and OnHandleCanc
gavinp
2012/12/10 17:55:10
Done. Good work using the American spelling of "Ca
mmenke
2012/12/11 19:53:45
Thanks. It's one of the few cases where I hate th
gavinp
2012/12/13 13:38:03
Wait: the American spelling is "Canceled." Would y
| |
297 | 293 |
298 PrerenderContents* contents() { return contents_.get(); } | 294 PrerenderContents* contents() { return contents_.get(); } |
299 | 295 |
300 PrerenderContents* ReleaseContents(); | 296 PrerenderContents* ReleaseContents(); |
301 | 297 |
302 int handle_count() const { return handle_count_; } | 298 int handle_count() const { return handle_count_; } |
303 | 299 |
304 base::TimeTicks expiry_time() const { return expiry_time_; } | 300 base::TimeTicks expiry_time() const { return expiry_time_; } |
305 void set_expiry_time(base::TimeTicks expiry_time) { | 301 void set_expiry_time(base::TimeTicks expiry_time) { |
306 expiry_time_ = expiry_time; | 302 expiry_time_ = expiry_time; |
(...skipping 20 matching lines...) Expand all Loading... | |
327 void SetPrerenderContentsFactory( | 323 void SetPrerenderContentsFactory( |
328 PrerenderContents::Factory* prerender_contents_factory); | 324 PrerenderContents::Factory* prerender_contents_factory); |
329 | 325 |
330 // Adds prerenders from the pending Prerenders, called by | 326 // Adds prerenders from the pending Prerenders, called by |
331 // PrerenderContents::StartPendingPrerenders. | 327 // PrerenderContents::StartPendingPrerenders. |
332 void StartPendingPrerenders( | 328 void StartPendingPrerenders( |
333 int process_id, | 329 int process_id, |
334 ScopedVector<PrerenderContents::PendingPrerenderInfo>* pending_prerenders, | 330 ScopedVector<PrerenderContents::PendingPrerenderInfo>* pending_prerenders, |
335 content::SessionStorageNamespace* session_storage_namespace); | 331 content::SessionStorageNamespace* session_storage_namespace); |
336 | 332 |
337 // Called by a PrerenderData to self-destroy, but only when the PrerenderData | |
338 // is pending (as in not yet active). Should not be called except for | |
339 // objects known to be in |pending_prerender_list_|. | |
340 void DestroyPendingPrerenderData(PrerenderData* pending_prerender_data); | |
341 | |
342 // Called by a PrerenderData to signal that the launcher has navigated away | 333 // Called by a PrerenderData to signal that the launcher has navigated away |
343 // from the context that launched the prerender. A user may have clicked | 334 // from the context that launched the prerender. A user may have clicked |
344 // a link in a page containing a <link rel=prerender> element, or the user | 335 // a link in a page containing a <link rel=prerender> element, or the user |
345 // might have committed an omnibox navigation. This is used to possibly | 336 // might have committed an omnibox navigation. This is used to possibly |
346 // shorten the TTL of the prerendered page. | 337 // shorten the TTL of the prerendered page. |
347 void SourceNavigatedAway(PrerenderData* prerender_data); | 338 void SourceNavigatedAway(PrerenderData* prerender_data); |
348 | 339 |
349 private: | 340 private: |
350 friend class PrerenderBrowserTest; | 341 friend class PrerenderBrowserTest; |
351 friend class PrerenderContents; | 342 friend class PrerenderContents; |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 static bool is_prefetch_enabled_; | 502 static bool is_prefetch_enabled_; |
512 | 503 |
513 // The profile that owns this PrerenderManager. | 504 // The profile that owns this PrerenderManager. |
514 Profile* profile_; | 505 Profile* profile_; |
515 | 506 |
516 PrerenderTracker* prerender_tracker_; | 507 PrerenderTracker* prerender_tracker_; |
517 | 508 |
518 // All running prerenders. Sorted by expiry time, in ascending order. | 509 // All running prerenders. Sorted by expiry time, in ascending order. |
519 ScopedVector<PrerenderData> active_prerenders_; | 510 ScopedVector<PrerenderData> active_prerenders_; |
520 | 511 |
521 // All pending prerenders. | |
522 ScopedVector<PrerenderData> pending_prerenders_; | |
523 | |
524 // Prerenders awaiting deletion. | 512 // Prerenders awaiting deletion. |
525 ScopedVector<PrerenderData> to_delete_prerenders_; | 513 ScopedVector<PrerenderData> to_delete_prerenders_; |
526 | 514 |
527 // List of recent navigations in this profile, sorted by ascending | 515 // List of recent navigations in this profile, sorted by ascending |
528 // navigate_time_. | 516 // navigate_time_. |
529 std::list<NavigationRecord> navigations_; | 517 std::list<NavigationRecord> navigations_; |
530 | 518 |
531 // This map is from all WebContents which are currently displaying a | 519 // This map is from all WebContents which are currently displaying a |
532 // prerendered page which has already been swapped in to a | 520 // prerendered page which has already been swapped in to a |
533 // PrerenderedWebContentsData for tracking full lifetime information | 521 // PrerenderedWebContentsData for tracking full lifetime information |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
579 | 567 |
580 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 568 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
581 }; | 569 }; |
582 | 570 |
583 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 571 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
584 int render_process_id); | 572 int render_process_id); |
585 | 573 |
586 } // namespace prerender | 574 } // namespace prerender |
587 | 575 |
588 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 576 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
OLD | NEW |