Chromium Code Reviews| 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_CONTENTS_H_ | 5 #ifndef CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 6 #define CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 class Observer { | 74 class Observer { |
| 75 public: | 75 public: |
| 76 // Signals that the prerender has started running. | 76 // Signals that the prerender has started running. |
| 77 virtual void OnPrerenderStart(PrerenderContents* contents) = 0; | 77 virtual void OnPrerenderStart(PrerenderContents* contents) = 0; |
| 78 | 78 |
| 79 // Signals that the prerender has stopped running. | 79 // Signals that the prerender has stopped running. |
| 80 virtual void OnPrerenderStop(PrerenderContents* contents) = 0; | 80 virtual void OnPrerenderStop(PrerenderContents* contents) = 0; |
| 81 | 81 |
| 82 // Signals the discovery, through redirects, of a new alias for this | |
| 83 // prerender. | |
| 84 virtual void OnPrerenderAddAlias(PrerenderContents* contents, | |
| 85 const GURL& alias_url); | |
| 82 protected: | 86 protected: |
|
mmenke
2012/12/06 22:22:15
nit: Line break above protected
gavinp
2012/12/10 17:55:10
Done.
| |
| 83 Observer(); | 87 Observer(); |
| 84 virtual ~Observer() = 0; | 88 virtual ~Observer() = 0; |
| 85 }; | 89 }; |
| 86 | 90 |
| 87 // A container for extra data on pending prerenders. | 91 // A container for extra data on pending prerenders. |
| 88 struct PendingPrerenderInfo { | 92 struct PendingPrerenderInfo { |
| 89 public: | 93 public: |
| 90 PendingPrerenderInfo( | 94 PendingPrerenderInfo( |
| 91 base::WeakPtr<PrerenderHandle> weak_prerender_handle, | 95 base::WeakPtr<PrerenderHandle> weak_prerender_handle, |
| 92 Origin origin, | 96 Origin origin, |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 122 MATCH_COMPLETE_REPLACEMENT, | 126 MATCH_COMPLETE_REPLACEMENT, |
| 123 // A prerender that is a MatchComplete dummy, early in the process of being | 127 // A prerender that is a MatchComplete dummy, early in the process of being |
| 124 // created. This prerender should not fail. Record for MatchComplete, but | 128 // created. This prerender should not fail. Record for MatchComplete, but |
| 125 // not Match. | 129 // not Match. |
| 126 MATCH_COMPLETE_REPLACEMENT_PENDING, | 130 MATCH_COMPLETE_REPLACEMENT_PENDING, |
| 127 }; | 131 }; |
| 128 | 132 |
| 129 virtual ~PrerenderContents(); | 133 virtual ~PrerenderContents(); |
| 130 | 134 |
| 131 // All observers of a PrerenderContents are removed after the OnPrerenderStop | 135 // All observers of a PrerenderContents are removed after the OnPrerenderStop |
| 132 // event is sent, so there is no need for a RemoveObserver() method. | 136 // event is sent, so there is no need to call RemoveObserver() in the normal |
| 137 // use case. | |
| 133 void AddObserver(Observer* observer); | 138 void AddObserver(Observer* observer); |
| 139 void RemoveObserver(Observer* observer); | |
| 134 | 140 |
| 135 // For MatchComplete correctness, create a dummy replacement prerender | 141 // For MatchComplete correctness, create a dummy replacement prerender |
| 136 // contents to stand in for this prerender contents that (which we are about | 142 // contents to stand in for this prerender contents that (which we are about |
| 137 // to destroy). | 143 // to destroy). |
| 138 PrerenderContents* CreateMatchCompleteReplacement() const; | 144 PrerenderContents* CreateMatchCompleteReplacement() const; |
| 139 | 145 |
| 140 bool Init(); | 146 bool Init(); |
| 141 | 147 |
| 142 static Factory* CreateFactory(); | 148 static Factory* CreateFactory(); |
| 143 | 149 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 PrerenderContents(PrerenderManager* prerender_manager, | 280 PrerenderContents(PrerenderManager* prerender_manager, |
| 275 Profile* profile, | 281 Profile* profile, |
| 276 const GURL& url, | 282 const GURL& url, |
| 277 const content::Referrer& referrer, | 283 const content::Referrer& referrer, |
| 278 Origin origin, | 284 Origin origin, |
| 279 uint8 experiment_id); | 285 uint8 experiment_id); |
| 280 | 286 |
| 281 // These call out to methods on our Observers, using our observer_list_. | 287 // These call out to methods on our Observers, using our observer_list_. |
| 282 void NotifyPrerenderStart(); | 288 void NotifyPrerenderStart(); |
| 283 void NotifyPrerenderStop(); | 289 void NotifyPrerenderStop(); |
| 290 void NotifyPrerenderAddAlias(const GURL& alias_url); | |
| 284 | 291 |
| 285 // Called whenever a RenderViewHost is created for prerendering. Only called | 292 // Called whenever a RenderViewHost is created for prerendering. Only called |
| 286 // once the RenderViewHost has a RenderView and RenderWidgetHostView. | 293 // once the RenderViewHost has a RenderView and RenderWidgetHostView. |
| 287 virtual void OnRenderViewHostCreated( | 294 virtual void OnRenderViewHostCreated( |
| 288 content::RenderViewHost* new_render_view_host); | 295 content::RenderViewHost* new_render_view_host); |
| 289 | 296 |
| 290 content::NotificationRegistrar& notification_registrar() { | 297 content::NotificationRegistrar& notification_registrar() { |
| 291 return notification_registrar_; | 298 return notification_registrar_; |
| 292 } | 299 } |
| 293 | 300 |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 | 419 |
| 413 // Caches pages to be added to the history. | 420 // Caches pages to be added to the history. |
| 414 AddPageVector add_page_vector_; | 421 AddPageVector add_page_vector_; |
| 415 | 422 |
| 416 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 423 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
| 417 }; | 424 }; |
| 418 | 425 |
| 419 } // namespace prerender | 426 } // namespace prerender |
| 420 | 427 |
| 421 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 428 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| OLD | NEW |