| 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: |
| 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, |
| (...skipping 30 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 PrerenderContents(PrerenderManager* prerender_manager, | 281 PrerenderContents(PrerenderManager* prerender_manager, |
| 276 Profile* profile, | 282 Profile* profile, |
| 277 const GURL& url, | 283 const GURL& url, |
| 278 const content::Referrer& referrer, | 284 const content::Referrer& referrer, |
| 279 Origin origin, | 285 Origin origin, |
| 280 uint8 experiment_id); | 286 uint8 experiment_id); |
| 281 | 287 |
| 282 // These call out to methods on our Observers, using our observer_list_. | 288 // These call out to methods on our Observers, using our observer_list_. |
| 283 void NotifyPrerenderStart(); | 289 void NotifyPrerenderStart(); |
| 284 void NotifyPrerenderStop(); | 290 void NotifyPrerenderStop(); |
| 291 void NotifyPrerenderAddAlias(const GURL& alias_url); |
| 285 | 292 |
| 286 // Called whenever a RenderViewHost is created for prerendering. Only called | 293 // Called whenever a RenderViewHost is created for prerendering. Only called |
| 287 // once the RenderViewHost has a RenderView and RenderWidgetHostView. | 294 // once the RenderViewHost has a RenderView and RenderWidgetHostView. |
| 288 virtual void OnRenderViewHostCreated( | 295 virtual void OnRenderViewHostCreated( |
| 289 content::RenderViewHost* new_render_view_host); | 296 content::RenderViewHost* new_render_view_host); |
| 290 | 297 |
| 291 content::NotificationRegistrar& notification_registrar() { | 298 content::NotificationRegistrar& notification_registrar() { |
| 292 return notification_registrar_; | 299 return notification_registrar_; |
| 293 } | 300 } |
| 294 | 301 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 | 417 |
| 411 // Caches pages to be added to the history. | 418 // Caches pages to be added to the history. |
| 412 AddPageVector add_page_vector_; | 419 AddPageVector add_page_vector_; |
| 413 | 420 |
| 414 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 421 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
| 415 }; | 422 }; |
| 416 | 423 |
| 417 } // namespace prerender | 424 } // namespace prerender |
| 418 | 425 |
| 419 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 426 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
| OLD | NEW |