| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 // ID indicating that no experiment is active. | 106 // ID indicating that no experiment is active. |
| 107 static const uint8 kNoExperiment = 0; | 107 static const uint8 kNoExperiment = 0; |
| 108 | 108 |
| 109 // Owned by a Profile object for the lifetime of the profile. | 109 // Owned by a Profile object for the lifetime of the profile. |
| 110 PrerenderManager(Profile* profile, PrerenderTracker* prerender_tracker); | 110 PrerenderManager(Profile* profile, PrerenderTracker* prerender_tracker); |
| 111 | 111 |
| 112 virtual ~PrerenderManager(); | 112 virtual ~PrerenderManager(); |
| 113 | 113 |
| 114 // From KeyedService: | 114 // From KeyedService: |
| 115 virtual void Shutdown() OVERRIDE; | 115 virtual void Shutdown() override; |
| 116 | 116 |
| 117 // Entry points for adding prerenders. | 117 // Entry points for adding prerenders. |
| 118 | 118 |
| 119 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify | 119 // Adds a prerender for |url| if valid. |process_id| and |route_id| identify |
| 120 // the RenderView that the prerender request came from. If |size| is empty, a | 120 // the RenderView that the prerender request came from. If |size| is empty, a |
| 121 // default from the PrerenderConfig is used. Returns a caller-owned | 121 // default from the PrerenderConfig is used. Returns a caller-owned |
| 122 // PrerenderHandle* if the URL was added, NULL if it was not. If the launching | 122 // PrerenderHandle* if the URL was added, NULL if it was not. If the launching |
| 123 // RenderView is itself prerendering, the prerender is added as a pending | 123 // RenderView is itself prerendering, the prerender is added as a pending |
| 124 // prerender. | 124 // prerender. |
| 125 PrerenderHandle* AddPrerenderFromLinkRelPrerender( | 125 PrerenderHandle* AddPrerenderFromLinkRelPrerender( |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 int cookie_status) const; | 274 int cookie_status) const; |
| 275 | 275 |
| 276 // Record a cookie send type histogram (see prerender_histograms.h). | 276 // Record a cookie send type histogram (see prerender_histograms.h). |
| 277 void RecordCookieSendType(Origin origin, | 277 void RecordCookieSendType(Origin origin, |
| 278 uint8 experiment_id, | 278 uint8 experiment_id, |
| 279 int cookie_send_type) const; | 279 int cookie_send_type) const; |
| 280 | 280 |
| 281 // content::NotificationObserver | 281 // content::NotificationObserver |
| 282 virtual void Observe(int type, | 282 virtual void Observe(int type, |
| 283 const content::NotificationSource& source, | 283 const content::NotificationSource& source, |
| 284 const content::NotificationDetails& details) OVERRIDE; | 284 const content::NotificationDetails& details) override; |
| 285 | 285 |
| 286 // MediaCaptureDevicesDispatcher::Observer | 286 // MediaCaptureDevicesDispatcher::Observer |
| 287 virtual void OnCreatingAudioStream(int render_process_id, | 287 virtual void OnCreatingAudioStream(int render_process_id, |
| 288 int render_frame_id) OVERRIDE; | 288 int render_frame_id) override; |
| 289 | 289 |
| 290 const Config& config() const { return config_; } | 290 const Config& config() const { return config_; } |
| 291 Config& mutable_config() { return config_; } | 291 Config& mutable_config() { return config_; } |
| 292 | 292 |
| 293 PrerenderTracker* prerender_tracker() { return prerender_tracker_; } | 293 PrerenderTracker* prerender_tracker() { return prerender_tracker_; } |
| 294 | 294 |
| 295 bool cookie_store_loaded() { return cookie_store_loaded_; } | 295 bool cookie_store_loaded() { return cookie_store_loaded_; } |
| 296 | 296 |
| 297 // Records that some visible tab navigated (or was redirected) to the | 297 // Records that some visible tab navigated (or was redirected) to the |
| 298 // provided URL. | 298 // provided URL. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 // PrerenderContents. | 362 // PrerenderContents. |
| 363 void AddPrerenderProcessHost(content::RenderProcessHost* process_host); | 363 void AddPrerenderProcessHost(content::RenderProcessHost* process_host); |
| 364 | 364 |
| 365 // Returns whether or not |process_host| may be reused for new navigations | 365 // Returns whether or not |process_host| may be reused for new navigations |
| 366 // from a prerendering perspective. Currently, if Prerender Cookie Stores are | 366 // from a prerendering perspective. Currently, if Prerender Cookie Stores are |
| 367 // enabled, prerenders must be in their own processes that may not be shared. | 367 // enabled, prerenders must be in their own processes that may not be shared. |
| 368 bool MayReuseProcessHost(content::RenderProcessHost* process_host); | 368 bool MayReuseProcessHost(content::RenderProcessHost* process_host); |
| 369 | 369 |
| 370 // content::RenderProcessHostObserver implementation. | 370 // content::RenderProcessHostObserver implementation. |
| 371 virtual void RenderProcessHostDestroyed( | 371 virtual void RenderProcessHostDestroyed( |
| 372 content::RenderProcessHost* host) OVERRIDE; | 372 content::RenderProcessHost* host) override; |
| 373 | 373 |
| 374 // To be called once the cookie store for this profile has been loaded. | 374 // To be called once the cookie store for this profile has been loaded. |
| 375 void OnCookieStoreLoaded(); | 375 void OnCookieStoreLoaded(); |
| 376 | 376 |
| 377 // For testing purposes. Issues a callback once the cookie store has been | 377 // For testing purposes. Issues a callback once the cookie store has been |
| 378 // loaded. | 378 // loaded. |
| 379 void set_on_cookie_store_loaded_cb_for_testing(base::Closure cb) { | 379 void set_on_cookie_store_loaded_cb_for_testing(base::Closure cb) { |
| 380 on_cookie_store_loaded_cb_for_testing_ = cb; | 380 on_cookie_store_loaded_cb_for_testing_ = cb; |
| 381 } | 381 } |
| 382 | 382 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 virtual ~PendingSwap(); | 470 virtual ~PendingSwap(); |
| 471 | 471 |
| 472 void set_swap_successful(bool swap_successful) { | 472 void set_swap_successful(bool swap_successful) { |
| 473 swap_successful_ = swap_successful; | 473 swap_successful_ = swap_successful; |
| 474 } | 474 } |
| 475 | 475 |
| 476 void BeginSwap(); | 476 void BeginSwap(); |
| 477 | 477 |
| 478 // content::WebContentsObserver implementation. | 478 // content::WebContentsObserver implementation. |
| 479 virtual void AboutToNavigateRenderView( | 479 virtual void AboutToNavigateRenderView( |
| 480 content::RenderViewHost* render_view_host) OVERRIDE; | 480 content::RenderViewHost* render_view_host) override; |
| 481 virtual void DidStartProvisionalLoadForFrame( | 481 virtual void DidStartProvisionalLoadForFrame( |
| 482 content::RenderFrameHost* render_frame_host, | 482 content::RenderFrameHost* render_frame_host, |
| 483 const GURL& validated_url, | 483 const GURL& validated_url, |
| 484 bool is_error_page, | 484 bool is_error_page, |
| 485 bool is_iframe_srcdoc) OVERRIDE; | 485 bool is_iframe_srcdoc) override; |
| 486 virtual void DidCommitProvisionalLoadForFrame( | 486 virtual void DidCommitProvisionalLoadForFrame( |
| 487 content::RenderFrameHost* render_frame_host, | 487 content::RenderFrameHost* render_frame_host, |
| 488 const GURL& validated_url, | 488 const GURL& validated_url, |
| 489 ui::PageTransition transition_type) OVERRIDE; | 489 ui::PageTransition transition_type) override; |
| 490 virtual void DidFailProvisionalLoad( | 490 virtual void DidFailProvisionalLoad( |
| 491 content::RenderFrameHost* render_frame_host, | 491 content::RenderFrameHost* render_frame_host, |
| 492 const GURL& validated_url, | 492 const GURL& validated_url, |
| 493 int error_code, | 493 int error_code, |
| 494 const base::string16& error_description) OVERRIDE; | 494 const base::string16& error_description) override; |
| 495 virtual void WebContentsDestroyed() OVERRIDE; | 495 virtual void WebContentsDestroyed() override; |
| 496 | 496 |
| 497 private: | 497 private: |
| 498 void RecordEvent(PrerenderEvent event) const; | 498 void RecordEvent(PrerenderEvent event) const; |
| 499 | 499 |
| 500 void OnMergeCompleted(content::SessionStorageNamespace::MergeResult result); | 500 void OnMergeCompleted(content::SessionStorageNamespace::MergeResult result); |
| 501 void OnMergeTimeout(); | 501 void OnMergeTimeout(); |
| 502 | 502 |
| 503 // Prerender parameters. | 503 // Prerender parameters. |
| 504 PrerenderManager* manager_; | 504 PrerenderManager* manager_; |
| 505 PrerenderData* prerender_data_; | 505 PrerenderData* prerender_data_; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 738 bool cookie_store_loaded_; | 738 bool cookie_store_loaded_; |
| 739 | 739 |
| 740 base::Closure on_cookie_store_loaded_cb_for_testing_; | 740 base::Closure on_cookie_store_loaded_cb_for_testing_; |
| 741 | 741 |
| 742 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); | 742 DISALLOW_COPY_AND_ASSIGN(PrerenderManager); |
| 743 }; | 743 }; |
| 744 | 744 |
| 745 } // namespace prerender | 745 } // namespace prerender |
| 746 | 746 |
| 747 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ | 747 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_MANAGER_H_ |
| OLD | NEW |