| 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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 // When a swap can't happen immediately, due to a sesison storage namespace | 424 // When a swap can't happen immediately, due to a sesison storage namespace |
| 425 // merge, there will be a pending swap object while the merge is in | 425 // merge, there will be a pending swap object while the merge is in |
| 426 // progress. It retains all the data needed to do the merge, maintains | 426 // progress. It retains all the data needed to do the merge, maintains |
| 427 // throttles for the navigation in the target WebContents that needs to be | 427 // throttles for the navigation in the target WebContents that needs to be |
| 428 // delayed, and handles all conditions which would cancel a pending swap. | 428 // delayed, and handles all conditions which would cancel a pending swap. |
| 429 class PendingSwap : public content::WebContentsObserver { | 429 class PendingSwap : public content::WebContentsObserver { |
| 430 public: | 430 public: |
| 431 PendingSwap(PrerenderManager* manager, | 431 PendingSwap(PrerenderManager* manager, |
| 432 content::WebContents* target_contents, | 432 content::WebContents* target_contents, |
| 433 PrerenderData* prerender_data, | 433 PrerenderData* prerender_data, |
| 434 const GURL& url); | 434 const GURL& url, |
| 435 bool should_replace_current_entry); |
| 435 virtual ~PendingSwap(); | 436 virtual ~PendingSwap(); |
| 436 | 437 |
| 437 void set_swap_successful(bool swap_successful) { | 438 void set_swap_successful(bool swap_successful) { |
| 438 swap_successful_ = swap_successful; | 439 swap_successful_ = swap_successful; |
| 439 } | 440 } |
| 440 | 441 |
| 441 void BeginSwap(); | 442 void BeginSwap(); |
| 442 | 443 |
| 443 // content::WebContentsObserver implementation. | 444 // content::WebContentsObserver implementation. |
| 444 virtual void ProvisionalChangeToMainFrameUrl( | 445 virtual void ProvisionalChangeToMainFrameUrl( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 463 content::RenderViewHost* render_view_host) OVERRIDE; | 464 content::RenderViewHost* render_view_host) OVERRIDE; |
| 464 virtual void WebContentsDestroyed(content::WebContents* web_contents) | 465 virtual void WebContentsDestroyed(content::WebContents* web_contents) |
| 465 OVERRIDE; | 466 OVERRIDE; |
| 466 | 467 |
| 467 private: | 468 private: |
| 468 void RecordEvent(PrerenderEvent event) const; | 469 void RecordEvent(PrerenderEvent event) const; |
| 469 | 470 |
| 470 void OnMergeCompleted(content::SessionStorageNamespace::MergeResult result); | 471 void OnMergeCompleted(content::SessionStorageNamespace::MergeResult result); |
| 471 void OnMergeTimeout(); | 472 void OnMergeTimeout(); |
| 472 | 473 |
| 474 // Prerender parameters. |
| 473 PrerenderManager* manager_; | 475 PrerenderManager* manager_; |
| 474 content::WebContents* target_contents_; | 476 content::WebContents* target_contents_; |
| 475 PrerenderData* prerender_data_; | 477 PrerenderData* prerender_data_; |
| 476 GURL url_; | 478 GURL url_; |
| 479 bool should_replace_current_entry_; |
| 480 |
| 477 base::TimeTicks start_time_; | 481 base::TimeTicks start_time_; |
| 478 std::vector<PrerenderTracker::ChildRouteIdPair> rvh_ids_; | 482 std::vector<PrerenderTracker::ChildRouteIdPair> rvh_ids_; |
| 479 base::OneShotTimer<PendingSwap> merge_timeout_; | 483 base::OneShotTimer<PendingSwap> merge_timeout_; |
| 480 bool swap_successful_; | 484 bool swap_successful_; |
| 481 | 485 |
| 482 base::WeakPtrFactory<PendingSwap> weak_factory_; | 486 base::WeakPtrFactory<PendingSwap> weak_factory_; |
| 483 }; | 487 }; |
| 484 | 488 |
| 485 void SetPrerenderContentsFactory( | 489 void SetPrerenderContentsFactory( |
| 486 PrerenderContents::Factory* prerender_contents_factory); | 490 PrerenderContents::Factory* prerender_contents_factory); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 | 657 |
| 654 void CookieChanged(ChromeCookieDetails* details); | 658 void CookieChanged(ChromeCookieDetails* details); |
| 655 void CookieChangedAnyCookiesLeftLookupResult(const std::string& domain_key, | 659 void CookieChangedAnyCookiesLeftLookupResult(const std::string& domain_key, |
| 656 bool cookies_exist); | 660 bool cookies_exist); |
| 657 void LoggedInPredictorDataReceived(scoped_ptr<LoggedInStateMap> new_map); | 661 void LoggedInPredictorDataReceived(scoped_ptr<LoggedInStateMap> new_map); |
| 658 | 662 |
| 659 void RecordEvent(PrerenderContents* contents, PrerenderEvent event) const; | 663 void RecordEvent(PrerenderContents* contents, PrerenderEvent event) const; |
| 660 | 664 |
| 661 // Swaps a prerender |prerender_data| for |url| into the tab, replacing | 665 // Swaps a prerender |prerender_data| for |url| into the tab, replacing |
| 662 // |web_contents|. Returns the new WebContents that was swapped in, or NULL | 666 // |web_contents|. Returns the new WebContents that was swapped in, or NULL |
| 663 // if a swap-in was not possible. | 667 // if a swap-in was not possible. If |should_replace_current_entry| is true, |
| 668 // the current history entry in |web_contents| is replaced. |
| 664 content::WebContents* SwapInternal(const GURL& url, | 669 content::WebContents* SwapInternal(const GURL& url, |
| 665 content::WebContents* web_contents, | 670 content::WebContents* web_contents, |
| 666 PrerenderData* prerender_data); | 671 PrerenderData* prerender_data, |
| 672 bool should_replace_current_entry); |
| 667 | 673 |
| 668 // The configuration. | 674 // The configuration. |
| 669 Config config_; | 675 Config config_; |
| 670 | 676 |
| 671 // Specifies whether prerendering is currently enabled for this | 677 // Specifies whether prerendering is currently enabled for this |
| 672 // manager. The value can change dynamically during the lifetime | 678 // manager. The value can change dynamically during the lifetime |
| 673 // of the PrerenderManager. | 679 // of the PrerenderManager. |
| 674 bool enabled_; | 680 bool enabled_; |
| 675 | 681 |
| 676 static bool is_prefetch_enabled_; | 682 static bool is_prefetch_enabled_; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 | 756 |
| 751 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 757 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
| 752 }; | 758 }; |
| 753 | 759 |
| 754 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( | 760 PrerenderManager* FindPrerenderManagerUsingRenderProcessId( |
| 755 int render_process_id); | 761 int render_process_id); |
| 756 | 762 |
| 757 } // namespace prerender | 763 } // namespace prerender |
| 758 | 764 |
| 759 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 765 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
| OLD | NEW |