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

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

Issue 10198040: New link rel=prerender api, using WebKit::WebPrerenderingPlatform (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remediate to dominich review Created 8 years, 7 months 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
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 #pragma once 7 #pragma once
8 8
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
11 #include <utility>
11 #include <vector> 12 #include <vector>
12 13
13 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
14 #include "base/time.h" 15 #include "base/time.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "chrome/browser/prerender/prerender_final_status.h" 17 #include "chrome/browser/prerender/prerender_final_status.h"
17 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/web_contents_observer.h" 20 #include "content/public/browser/web_contents_observer.h"
20 #include "content/public/common/referrer.h" 21 #include "content/public/common/referrer.h"
22 #include "ui/gfx/size.h"
21 23
22 class Profile; 24 class Profile;
23 class TabContentsWrapper; 25 class TabContentsWrapper;
24 struct FaviconURL; 26 struct FaviconURL;
25 27
26 namespace base { 28 namespace base {
27 class ProcessMetrics; 29 class ProcessMetrics;
28 } 30 }
29 31
30 namespace content { 32 namespace content {
(...skipping 28 matching lines...) Expand all
59 const GURL& url, 61 const GURL& url,
60 const content::Referrer& referrer, 62 const content::Referrer& referrer,
61 Origin origin, 63 Origin origin,
62 uint8 experiment_id) = 0; 64 uint8 experiment_id) = 0;
63 65
64 private: 66 private:
65 DISALLOW_COPY_AND_ASSIGN(Factory); 67 DISALLOW_COPY_AND_ASSIGN(Factory);
66 }; 68 };
67 69
68 // Information on pages that the prerendered page has tried to prerender. 70 // Information on pages that the prerendered page has tried to prerender.
69 struct PendingPrerenderData { 71 typedef std::pair<GURL, content::Referrer> PendingPrerenderData;
mmenke 2012/04/30 18:35:22 nit: Now that we have a "PrerenderExtraData", I s
gavinp 2012/04/30 23:55:39 Done, but spelled right.
mmenke 2012/05/01 16:23:21 I'm not going to sign off on this until you duplic
70 PendingPrerenderData(Origin origin,
71 const GURL& url,
72 const content::Referrer& referrer);
73
74 Origin origin;
75 GURL url;
76 content::Referrer referrer;
77 };
78 typedef std::list<PendingPrerenderData> PendingPrerenderList; 72 typedef std::list<PendingPrerenderData> PendingPrerenderList;
79 73
80 // Indicates how this PrerenderContents relates to MatchComplete. 74 // Indicates how this PrerenderContents relates to MatchComplete.
81 // This is important to figure out in what histograms to record the 75 // This is important to figure out in what histograms to record the
82 // FinalStatus in, as described below. 76 // FinalStatus in, as described below.
83 enum MatchCompleteStatus { 77 enum MatchCompleteStatus {
84 // A regular prerender which will be recorded both in Match and 78 // A regular prerender which will be recorded both in Match and
85 // MatchComplete. 79 // MatchComplete.
86 MATCH_COMPLETE_DEFAULT, 80 MATCH_COMPLETE_DEFAULT,
87 // A prerender that used to be a regular prerender, but has since 81 // A prerender that used to be a regular prerender, but has since
88 // been replaced by a MatchComplete dummy. Therefore, we will record 82 // been replaced by a MatchComplete dummy. Therefore, we will record
89 // this only for Match, but not for MatchComplete. 83 // this only for Match, but not for MatchComplete.
90 MATCH_COMPLETE_REPLACED, 84 MATCH_COMPLETE_REPLACED,
91 // A prerender that is a MatchComplete dummy replacing a regular 85 // A prerender that is a MatchComplete dummy replacing a regular
92 // prerender. Therefore, we will record this only for MatchComplete, 86 // prerender. Therefore, we will record this only for MatchComplete,
93 // but not Match. 87 // but not Match.
94 MATCH_COMPLETE_REPLACEMENT 88 MATCH_COMPLETE_REPLACEMENT
95 }; 89 };
96 90
97 virtual ~PrerenderContents(); 91 virtual ~PrerenderContents();
98 92
99 bool Init(); 93 bool Init();
100 94
101 static Factory* CreateFactory(); 95 static Factory* CreateFactory();
102 96
103 // |source_render_view_host| is the RenderViewHost that initiated 97 // |source_render_view_host| is the RenderViewHost that initiated
104 // prerendering. 98 // prerendering.
105 virtual void StartPrerendering( 99 virtual void StartPrerendering(
106 const content::RenderViewHost* source_render_view_host, 100 int creator_child_id,
101 const gfx::Size& size,
107 content::SessionStorageNamespace* session_storage_namespace); 102 content::SessionStorageNamespace* session_storage_namespace);
108 103
109 // Verifies that the prerendering is not using too many resources, and kills 104 // Verifies that the prerendering is not using too many resources, and kills
110 // it if not. 105 // it if not.
111 void DestroyWhenUsingTooManyResources(); 106 void DestroyWhenUsingTooManyResources();
112 107
113 content::RenderViewHost* render_view_host_mutable(); 108 content::RenderViewHost* GetRenderViewHostMutable();
114 const content::RenderViewHost* render_view_host() const; 109 const content::RenderViewHost* GetRenderViewHost() const;
110
115 string16 title() const { return title_; } 111 string16 title() const { return title_; }
116 int32 page_id() const { return page_id_; } 112 int32 page_id() const { return page_id_; }
117 GURL icon_url() const { return icon_url_; } 113 GURL icon_url() const { return icon_url_; }
118 const GURL& prerender_url() const { return prerender_url_; } 114 const GURL& prerender_url() const { return prerender_url_; }
119 const content::Referrer& referrer() const { return referrer_; } 115 const content::Referrer& referrer() const { return referrer_; }
120 bool has_stopped_loading() const { return has_stopped_loading_; } 116 bool has_stopped_loading() const { return has_stopped_loading_; }
121 bool has_finished_loading() const { return has_finished_loading_; } 117 bool has_finished_loading() const { return has_finished_loading_; }
122 bool prerendering_has_started() const { return prerendering_has_started_; } 118 bool prerendering_has_started() const { return prerendering_has_started_; }
123 MatchCompleteStatus match_complete_status() const { 119 MatchCompleteStatus match_complete_status() const {
124 return match_complete_status_; 120 return match_complete_status_;
(...skipping 17 matching lines...) Expand all
142 FinalStatus final_status() const { return final_status_; } 138 FinalStatus final_status() const { return final_status_; }
143 139
144 Origin origin() const { return origin_; } 140 Origin origin() const { return origin_; }
145 uint8 experiment_id() const { return experiment_id_; } 141 uint8 experiment_id() const { return experiment_id_; }
146 142
147 base::TimeTicks load_start_time() const { return load_start_time_; } 143 base::TimeTicks load_start_time() const { return load_start_time_; }
148 144
149 // Indicates whether this prerendered page can be used for the provided 145 // Indicates whether this prerendered page can be used for the provided
150 // URL, i.e. whether there is a match. |matching_url| is optional and will be 146 // URL, i.e. whether there is a match. |matching_url| is optional and will be
151 // set to the URL that is found as a match if it is provided. 147 // set to the URL that is found as a match if it is provided.
148 // TODO(gavinp,mmenke): Rework matching to be based on both the URL
149 // and the session WebStorage.
152 bool MatchesURL(const GURL& url, GURL* matching_url) const; 150 bool MatchesURL(const GURL& url, GURL* matching_url) const;
153 151
154 void OnJSOutOfMemory(); 152 void OnJSOutOfMemory();
155 bool ShouldSuppressDialogs(); 153 bool ShouldSuppressDialogs();
156 154
157 // content::WebContentsObserver implementation. 155 // content::WebContentsObserver implementation.
158 virtual void DidStopLoading() OVERRIDE; 156 virtual void DidStopLoading() OVERRIDE;
159 virtual void DidStartProvisionalLoadForFrame( 157 virtual void DidStartProvisionalLoadForFrame(
160 int64 frame_id, 158 int64 frame_id,
161 bool is_main_frame, 159 bool is_main_frame,
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 void CommitHistory(TabContentsWrapper* tab); 196 void CommitHistory(TabContentsWrapper* tab);
199 197
200 base::Value* GetAsValue() const; 198 base::Value* GetAsValue() const;
201 199
202 // Returns whether a pending cross-site navigation is happening. 200 // Returns whether a pending cross-site navigation is happening.
203 // This could happen with renderer-issued navigations, such as a 201 // This could happen with renderer-issued navigations, such as a
204 // MouseEvent being dispatched by a link to a website installed as an app. 202 // MouseEvent being dispatched by a link to a website installed as an app.
205 bool IsCrossSiteNavigationPending() const; 203 bool IsCrossSiteNavigationPending() const;
206 204
207 // Adds a pending prerender to the list. 205 // Adds a pending prerender to the list.
208 virtual void AddPendingPrerender(Origin origin, 206 virtual void AddPendingPrerender(const GURL& url,
209 const GURL& url,
210 const content::Referrer& referrer); 207 const content::Referrer& referrer);
211 208
212 // Returns true if |url| corresponds to a pending prerender. 209 // Returns true if |url| corresponds to a pending prerender.
213 bool IsPendingEntry(const GURL& url) const; 210 bool IsPendingEntry(const GURL& url) const;
214 211
215 // Reissues any pending prerender requests from the prerendered page. Also 212 // Reissues any pending prerender requests from the prerendered page. Also
216 // clears the list of pending requests. 213 // clears the list of pending requests.
217 void StartPendingPrerenders(); 214 void StartPendingPrerenders();
218 215
219 protected: 216 protected:
(...skipping 11 matching lines...) Expand all
231 content::RenderViewHost* new_render_view_host); 228 content::RenderViewHost* new_render_view_host);
232 229
233 content::NotificationRegistrar& notification_registrar() { 230 content::NotificationRegistrar& notification_registrar() {
234 return notification_registrar_; 231 return notification_registrar_;
235 } 232 }
236 233
237 const PendingPrerenderList* pending_prerender_list() const { 234 const PendingPrerenderList* pending_prerender_list() const {
238 return &pending_prerender_list_; 235 return &pending_prerender_list_;
239 } 236 }
240 237
238 bool prerendering_has_been_cancelled() const {
239 return prerendering_has_been_cancelled_;
240 }
241
241 virtual content::WebContents* CreateWebContents( 242 virtual content::WebContents* CreateWebContents(
242 content::SessionStorageNamespace* session_storage_namespace); 243 content::SessionStorageNamespace* session_storage_namespace);
243 244
244 private: 245 private:
245 class TabContentsDelegateImpl; 246 class TabContentsDelegateImpl;
246 247
247 // Needs to be able to call the constructor. 248 // Needs to be able to call the constructor.
248 friend class PrerenderContentsFactoryImpl; 249 friend class PrerenderContentsFactoryImpl;
249 250
250 friend class PrerenderRenderViewHostObserver; 251 friend class PrerenderRenderViewHostObserver;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 335
335 // Experiment during which this prerender is performed. 336 // Experiment during which this prerender is performed.
336 uint8 experiment_id_; 337 uint8 experiment_id_;
337 338
338 // List of all pages the prerendered page has tried to prerender. 339 // List of all pages the prerendered page has tried to prerender.
339 PendingPrerenderList pending_prerender_list_; 340 PendingPrerenderList pending_prerender_list_;
340 341
341 // The process that created the child id. 342 // The process that created the child id.
342 int creator_child_id_; 343 int creator_child_id_;
343 344
345 // The size of the WebView from the launching page.
346 gfx::Size size_;
347
344 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); 348 DISALLOW_COPY_AND_ASSIGN(PrerenderContents);
345 }; 349 };
346 350
347 } // namespace prerender 351 } // namespace prerender
348 352
349 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ 353 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698