Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: chrome/browser/prerender/prerender_contents.h

Issue 11316311: Make PrerenderHandle an observer of PrerenderContents. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clear to land Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_contents.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 }; 71 };
72 72
73 class Observer { 73 class Observer {
74 public: 74 public:
75 // Signals that the prerender has started running. 75 // Signals that the prerender has started running.
76 virtual void OnPrerenderStart(PrerenderContents* contents) = 0; 76 virtual void OnPrerenderStart(PrerenderContents* contents) = 0;
77 77
78 // Signals that the prerender has stopped running. 78 // Signals that the prerender has stopped running.
79 virtual void OnPrerenderStop(PrerenderContents* contents) = 0; 79 virtual void OnPrerenderStop(PrerenderContents* contents) = 0;
80 80
81 // Signals the discovery, through redirects, of a new alias for this
82 // prerender.
83 virtual void OnPrerenderAddAlias(PrerenderContents* contents,
84 const GURL& alias_url);
85
86 // Signals that this prerender has just become a MatchComplete replacement.
87 virtual void OnPrerenderCreatedMatchCompleteReplacement(
88 PrerenderContents* contents, PrerenderContents* replacement);
89
81 protected: 90 protected:
82 Observer(); 91 Observer();
83 virtual ~Observer() = 0; 92 virtual ~Observer() = 0;
84 }; 93 };
85 94
86 // A container for extra data on pending prerenders. 95 // A container for extra data on pending prerenders.
87 struct PendingPrerenderInfo { 96 struct PendingPrerenderInfo {
88 public: 97 public:
89 PendingPrerenderInfo( 98 PendingPrerenderInfo(
90 base::WeakPtr<PrerenderHandle> weak_prerender_handle, 99 base::WeakPtr<PrerenderHandle> weak_prerender_handle,
(...skipping 30 matching lines...) Expand all
121 MATCH_COMPLETE_REPLACEMENT, 130 MATCH_COMPLETE_REPLACEMENT,
122 // A prerender that is a MatchComplete dummy, early in the process of being 131 // A prerender that is a MatchComplete dummy, early in the process of being
123 // created. This prerender should not fail. Record for MatchComplete, but 132 // created. This prerender should not fail. Record for MatchComplete, but
124 // not Match. 133 // not Match.
125 MATCH_COMPLETE_REPLACEMENT_PENDING, 134 MATCH_COMPLETE_REPLACEMENT_PENDING,
126 }; 135 };
127 136
128 virtual ~PrerenderContents(); 137 virtual ~PrerenderContents();
129 138
130 // All observers of a PrerenderContents are removed after the OnPrerenderStop 139 // All observers of a PrerenderContents are removed after the OnPrerenderStop
131 // event is sent, so there is no need for a RemoveObserver() method. 140 // event is sent, so there is no need to call RemoveObserver() in the normal
141 // use case.
132 void AddObserver(Observer* observer); 142 void AddObserver(Observer* observer);
143 void RemoveObserver(Observer* observer);
133 144
134 // For MatchComplete correctness, create a dummy replacement prerender 145 // For MatchComplete correctness, create a dummy replacement prerender
135 // contents to stand in for this prerender contents that (which we are about 146 // contents to stand in for this prerender contents that (which we are about
136 // to destroy). 147 // to destroy).
137 PrerenderContents* CreateMatchCompleteReplacement() const; 148 PrerenderContents* CreateMatchCompleteReplacement();
138 149
139 bool Init(); 150 bool Init();
140 151
141 static Factory* CreateFactory(); 152 static Factory* CreateFactory();
142 153
143 // Start rendering the contents in the prerendered state. If 154 // Start rendering the contents in the prerendered state. If
144 // |is_control_group| is true, this will go through some of the mechanics of 155 // |is_control_group| is true, this will go through some of the mechanics of
145 // starting a prerender, without actually creating the RenderView. 156 // starting a prerender, without actually creating the RenderView.
146 // |creator_child_id| is the id of the child process that caused the prerender 157 // |creator_child_id| is the id of the child process that caused the prerender
147 // to be created, and is needed so that the prerendered URLs can be sent to it 158 // 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
260 // This could happen with renderer-issued navigations, such as a 271 // This could happen with renderer-issued navigations, such as a
261 // MouseEvent being dispatched by a link to a website installed as an app. 272 // MouseEvent being dispatched by a link to a website installed as an app.
262 bool IsCrossSiteNavigationPending() const; 273 bool IsCrossSiteNavigationPending() const;
263 274
264 // Adds a pending prerender to the list. If |weak_prerender_handle| still 275 // Adds a pending prerender to the list. If |weak_prerender_handle| still
265 // exists when this page is made visible, it will be launched. 276 // exists when this page is made visible, it will be launched.
266 virtual void AddPendingPrerender( 277 virtual void AddPendingPrerender(
267 scoped_ptr<PendingPrerenderInfo> pending_prerender_info); 278 scoped_ptr<PendingPrerenderInfo> pending_prerender_info);
268 279
269 // Reissues any pending prerender requests from the prerendered page. Also 280 // Reissues any pending prerender requests from the prerendered page. Also
270 // clears the list of pending requests. 281 // clears the list of pending requests. Sends notifications.
271 void StartPendingPrerenders(); 282 void PrepareForUse();
272 283
273 protected: 284 protected:
274 PrerenderContents(PrerenderManager* prerender_manager, 285 PrerenderContents(PrerenderManager* prerender_manager,
275 Profile* profile, 286 Profile* profile,
276 const GURL& url, 287 const GURL& url,
277 const content::Referrer& referrer, 288 const content::Referrer& referrer,
278 Origin origin, 289 Origin origin,
279 uint8 experiment_id); 290 uint8 experiment_id);
280 291
281 // These call out to methods on our Observers, using our observer_list_. Note 292 // These call out to methods on our Observers, using our observer_list_. Note
282 // that NotifyPrerenderStop() also clears the observer list. 293 // that NotifyPrerenderStop() also clears the observer list.
283 void NotifyPrerenderStart(); 294 void NotifyPrerenderStart();
284 void NotifyPrerenderStop(); 295 void NotifyPrerenderStop();
296 void NotifyPrerenderAddAlias(const GURL& alias_url);
297 void NotifyPrerenderCreatedMatchCompleteReplacement(
298 PrerenderContents* replacement);
285 299
286 // Called whenever a RenderViewHost is created for prerendering. Only called 300 // Called whenever a RenderViewHost is created for prerendering. Only called
287 // once the RenderViewHost has a RenderView and RenderWidgetHostView. 301 // once the RenderViewHost has a RenderView and RenderWidgetHostView.
288 virtual void OnRenderViewHostCreated( 302 virtual void OnRenderViewHostCreated(
289 content::RenderViewHost* new_render_view_host); 303 content::RenderViewHost* new_render_view_host);
290 304
291 content::NotificationRegistrar& notification_registrar() { 305 content::NotificationRegistrar& notification_registrar() {
292 return notification_registrar_; 306 return notification_registrar_;
293 } 307 }
294 308
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 421
408 // Caches pages to be added to the history. 422 // Caches pages to be added to the history.
409 AddPageVector add_page_vector_; 423 AddPageVector add_page_vector_;
410 424
411 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); 425 DISALLOW_COPY_AND_ASSIGN(PrerenderContents);
412 }; 426 };
413 427
414 } // namespace prerender 428 } // namespace prerender
415 429
416 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ 430 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prerender/prerender_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698