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); |
| 86 |
| 87 // Signals that this prerender has just become a MatchComplete replacement. |
| 88 virtual void OnPrerenderCreatedMatchCompleteReplacement( |
| 89 PrerenderContents* contents, PrerenderContents* replacement); |
| 90 |
82 protected: | 91 protected: |
83 Observer(); | 92 Observer(); |
84 virtual ~Observer() = 0; | 93 virtual ~Observer() = 0; |
85 }; | 94 }; |
86 | 95 |
87 // A container for extra data on pending prerenders. | 96 // A container for extra data on pending prerenders. |
88 struct PendingPrerenderInfo { | 97 struct PendingPrerenderInfo { |
89 public: | 98 public: |
90 PendingPrerenderInfo( | 99 PendingPrerenderInfo( |
91 base::WeakPtr<PrerenderHandle> weak_prerender_handle, | 100 base::WeakPtr<PrerenderHandle> weak_prerender_handle, |
(...skipping 30 matching lines...) Expand all Loading... |
122 MATCH_COMPLETE_REPLACEMENT, | 131 MATCH_COMPLETE_REPLACEMENT, |
123 // A prerender that is a MatchComplete dummy, early in the process of being | 132 // A prerender that is a MatchComplete dummy, early in the process of being |
124 // created. This prerender should not fail. Record for MatchComplete, but | 133 // created. This prerender should not fail. Record for MatchComplete, but |
125 // not Match. | 134 // not Match. |
126 MATCH_COMPLETE_REPLACEMENT_PENDING, | 135 MATCH_COMPLETE_REPLACEMENT_PENDING, |
127 }; | 136 }; |
128 | 137 |
129 virtual ~PrerenderContents(); | 138 virtual ~PrerenderContents(); |
130 | 139 |
131 // All observers of a PrerenderContents are removed after the OnPrerenderStop | 140 // All observers of a PrerenderContents are removed after the OnPrerenderStop |
132 // event is sent, so there is no need for a RemoveObserver() method. | 141 // event is sent, so there is no need to call RemoveObserver() in the normal |
| 142 // use case. |
133 void AddObserver(Observer* observer); | 143 void AddObserver(Observer* observer); |
| 144 void RemoveObserver(Observer* observer); |
134 | 145 |
135 // For MatchComplete correctness, create a dummy replacement prerender | 146 // For MatchComplete correctness, create a dummy replacement prerender |
136 // contents to stand in for this prerender contents that (which we are about | 147 // contents to stand in for this prerender contents that (which we are about |
137 // to destroy). | 148 // to destroy). |
138 PrerenderContents* CreateMatchCompleteReplacement() const; | 149 PrerenderContents* CreateMatchCompleteReplacement(); |
139 | 150 |
140 bool Init(); | 151 bool Init(); |
141 | 152 |
142 static Factory* CreateFactory(); | 153 static Factory* CreateFactory(); |
143 | 154 |
144 // Start rendering the contents in the prerendered state. If | 155 // Start rendering the contents in the prerendered state. If |
145 // |is_control_group| is true, this will go through some of the mechanics of | 156 // |is_control_group| is true, this will go through some of the mechanics of |
146 // starting a prerender, without actually creating the RenderView. | 157 // starting a prerender, without actually creating the RenderView. |
147 // |creator_child_id| is the id of the child process that caused the prerender | 158 // |creator_child_id| is the id of the child process that caused the prerender |
148 // to be created, and is needed so that the prerendered URLs can be sent to it | 159 // to be created, and is needed so that the prerendered URLs can be sent to it |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // This could happen with renderer-issued navigations, such as a | 272 // This could happen with renderer-issued navigations, such as a |
262 // MouseEvent being dispatched by a link to a website installed as an app. | 273 // MouseEvent being dispatched by a link to a website installed as an app. |
263 bool IsCrossSiteNavigationPending() const; | 274 bool IsCrossSiteNavigationPending() const; |
264 | 275 |
265 // Adds a pending prerender to the list. If |weak_prerender_handle| still | 276 // Adds a pending prerender to the list. If |weak_prerender_handle| still |
266 // exists when this page is made visible, it will be launched. | 277 // exists when this page is made visible, it will be launched. |
267 virtual void AddPendingPrerender( | 278 virtual void AddPendingPrerender( |
268 scoped_ptr<PendingPrerenderInfo> pending_prerender_info); | 279 scoped_ptr<PendingPrerenderInfo> pending_prerender_info); |
269 | 280 |
270 // Reissues any pending prerender requests from the prerendered page. Also | 281 // Reissues any pending prerender requests from the prerendered page. Also |
271 // clears the list of pending requests. | 282 // clears the list of pending requests. Sends notifications. |
272 void StartPendingPrerenders(); | 283 void PrepareForUse(); |
273 | 284 |
274 protected: | 285 protected: |
275 PrerenderContents(PrerenderManager* prerender_manager, | 286 PrerenderContents(PrerenderManager* prerender_manager, |
276 Profile* profile, | 287 Profile* profile, |
277 const GURL& url, | 288 const GURL& url, |
278 const content::Referrer& referrer, | 289 const content::Referrer& referrer, |
279 Origin origin, | 290 Origin origin, |
280 uint8 experiment_id); | 291 uint8 experiment_id); |
281 | 292 |
282 // These call out to methods on our Observers, using our observer_list_. Note | 293 // These call out to methods on our Observers, using our observer_list_. Note |
283 // that NotifyPrerenderStop() also clears the observer list. | 294 // that NotifyPrerenderStop() also clears the observer list. |
284 void NotifyPrerenderStart(); | 295 void NotifyPrerenderStart(); |
285 void NotifyPrerenderStop(); | 296 void NotifyPrerenderStop(); |
| 297 void NotifyPrerenderAddAlias(const GURL& alias_url); |
| 298 void NotifyPrerenderCreatedMatchCompleteReplacement( |
| 299 PrerenderContents* replacement); |
286 | 300 |
287 // Called whenever a RenderViewHost is created for prerendering. Only called | 301 // Called whenever a RenderViewHost is created for prerendering. Only called |
288 // once the RenderViewHost has a RenderView and RenderWidgetHostView. | 302 // once the RenderViewHost has a RenderView and RenderWidgetHostView. |
289 virtual void OnRenderViewHostCreated( | 303 virtual void OnRenderViewHostCreated( |
290 content::RenderViewHost* new_render_view_host); | 304 content::RenderViewHost* new_render_view_host); |
291 | 305 |
292 content::NotificationRegistrar& notification_registrar() { | 306 content::NotificationRegistrar& notification_registrar() { |
293 return notification_registrar_; | 307 return notification_registrar_; |
294 } | 308 } |
295 | 309 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 | 425 |
412 // Caches pages to be added to the history. | 426 // Caches pages to be added to the history. |
413 AddPageVector add_page_vector_; | 427 AddPageVector add_page_vector_; |
414 | 428 |
415 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 429 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
416 }; | 430 }; |
417 | 431 |
418 } // namespace prerender | 432 } // namespace prerender |
419 | 433 |
420 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 434 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
OLD | NEW |