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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <list> | 9 #include <list> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "chrome/browser/prerender/prerender_final_status.h" | 17 #include "chrome/browser/prerender/prerender_final_status.h" |
18 #include "chrome/browser/prerender/prerender_handle.h" | |
18 #include "content/public/browser/notification_observer.h" | 19 #include "content/public/browser/notification_observer.h" |
19 #include "content/public/browser/notification_registrar.h" | 20 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/common/referrer.h" | 22 #include "content/public/common/referrer.h" |
22 #include "ui/gfx/size.h" | 23 #include "ui/gfx/size.h" |
23 | 24 |
24 class Profile; | 25 class Profile; |
25 class TabContents; | 26 class TabContents; |
26 struct FaviconURL; | 27 struct FaviconURL; |
27 | 28 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 // we record in MatchComplete but not Match. | 89 // we record in MatchComplete but not Match. |
89 MATCH_COMPLETE_REPLACEMENT, | 90 MATCH_COMPLETE_REPLACEMENT, |
90 // A prerender that is a MatchComplete dummy, early in the process of being | 91 // A prerender that is a MatchComplete dummy, early in the process of being |
91 // created. This prerender should not fail. Record for MatchComplete, but | 92 // created. This prerender should not fail. Record for MatchComplete, but |
92 // not Match. | 93 // not Match. |
93 MATCH_COMPLETE_REPLACEMENT_PENDING, | 94 MATCH_COMPLETE_REPLACEMENT_PENDING, |
94 }; | 95 }; |
95 | 96 |
96 virtual ~PrerenderContents(); | 97 virtual ~PrerenderContents(); |
97 | 98 |
98 bool Init(); | 99 bool Init(WeakPrerenderHandle prerender); |
dominich
2012/06/18 15:32:44
PrerenderHandle* or const PrerenderHandle& or base
| |
99 | 100 |
100 static Factory* CreateFactory(); | 101 static Factory* CreateFactory(); |
101 | 102 |
102 // Start rendering the contents in the prerendered state. If | 103 // Start rendering the contents in the prerendered state. If |
103 // |is_control_group| is true, this will go through some of the mechanics of | 104 // |is_control_group| is true, this will go through some of the mechanics of |
104 // starting a prerender, without actually creating the RenderView. | 105 // starting a prerender, without actually creating the RenderView. |
105 // |creator_child_id| is the id of the child process that caused the prerender | 106 // |creator_child_id| is the id of the child process that caused the prerender |
106 // to be created, and is needed so that the prerendered URLs can be sent to it | 107 // to be created, and is needed so that the prerendered URLs can be sent to it |
107 // so render-initiated navigations will swap in the prerendered page. |size| | 108 // so render-initiated navigations will swap in the prerendered page. |size| |
108 // indicates the rectangular dimensions that the prerendered page should be. | 109 // indicates the rectangular dimensions that the prerendered page should be. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 // contents are destroyed. | 150 // contents are destroyed. |
150 void set_final_status(FinalStatus final_status); | 151 void set_final_status(FinalStatus final_status); |
151 FinalStatus final_status() const { return final_status_; } | 152 FinalStatus final_status() const { return final_status_; } |
152 | 153 |
153 Origin origin() const { return origin_; } | 154 Origin origin() const { return origin_; } |
154 uint8 experiment_id() const { return experiment_id_; } | 155 uint8 experiment_id() const { return experiment_id_; } |
155 | 156 |
156 base::TimeTicks load_start_time() const { return load_start_time_; } | 157 base::TimeTicks load_start_time() const { return load_start_time_; } |
157 | 158 |
158 // Indicates whether this prerendered page can be used for the provided | 159 // Indicates whether this prerendered page can be used for the provided |
159 // URL, i.e. whether there is a match. |matching_url| is optional and will be | 160 // |url| and |session_storage_namespace|. |
160 // set to the URL that is found as a match if it is provided. | 161 bool Matches( |
161 // TODO(gavinp,mmenke): Rework matching to be based on both the URL | 162 const GURL& url, |
162 // and the session WebStorage. | 163 const content::SessionStorageNamespace* session_storage_namespace) const; |
163 bool MatchesURL(const GURL& url, GURL* matching_url) const; | |
164 | 164 |
165 void OnJSOutOfMemory(); | 165 void OnJSOutOfMemory(); |
166 bool ShouldSuppressDialogs(); | 166 bool ShouldSuppressDialogs(); |
167 | 167 |
168 // content::WebContentsObserver implementation. | 168 // content::WebContentsObserver implementation. |
169 virtual void DidStopLoading() OVERRIDE; | 169 virtual void DidStopLoading() OVERRIDE; |
170 virtual void DidStartProvisionalLoadForFrame( | 170 virtual void DidStartProvisionalLoadForFrame( |
171 int64 frame_id, | 171 int64 frame_id, |
172 bool is_main_frame, | 172 bool is_main_frame, |
173 const GURL& validated_url, | 173 const GURL& validated_url, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 void CommitHistory(TabContents* tab); | 209 void CommitHistory(TabContents* tab); |
210 | 210 |
211 base::Value* GetAsValue() const; | 211 base::Value* GetAsValue() const; |
212 | 212 |
213 // Returns whether a pending cross-site navigation is happening. | 213 // Returns whether a pending cross-site navigation is happening. |
214 // This could happen with renderer-issued navigations, such as a | 214 // This could happen with renderer-issued navigations, such as a |
215 // MouseEvent being dispatched by a link to a website installed as an app. | 215 // MouseEvent being dispatched by a link to a website installed as an app. |
216 bool IsCrossSiteNavigationPending() const; | 216 bool IsCrossSiteNavigationPending() const; |
217 | 217 |
218 // Adds a pending prerender to the list. | 218 // Adds a pending prerender to the list. |
219 virtual void AddPendingPrerender(const GURL& url, | 219 virtual PrerenderHandle AddPendingPrerender(const GURL& url, |
dominich
2012/06/18 15:32:44
so this will copy the PrerenderHandle on return? T
gavinp
2012/06/18 16:40:48
The PrerenderHandle is a machine word in size.
| |
220 const content::Referrer& referrer, | 220 const content::Referrer& referrer, |
221 const gfx::Size& size); | 221 const gfx::Size& size); |
222 | 222 |
223 // Returns true if |url| corresponds to a pending prerender. | 223 // Returns true if |url| corresponds to a pending prerender. |
224 bool IsPendingEntry(const GURL& url) const; | 224 bool IsPendingEntry(const GURL& url) const; |
225 | 225 |
226 // Reissues any pending prerender requests from the prerendered page. Also | 226 // Reissues any pending prerender requests from the prerendered page. Also |
227 // clears the list of pending requests. | 227 // clears the list of pending requests. |
228 void StartPendingPrerenders(); | 228 void StartPendingPrerenders(); |
229 | 229 |
230 protected: | 230 protected: |
231 PrerenderContents(PrerenderManager* prerender_manager, | 231 PrerenderContents(PrerenderManager* prerender_manager, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 | 274 |
275 // Returns the ProcessMetrics for the render process, if it exists. | 275 // Returns the ProcessMetrics for the render process, if it exists. |
276 base::ProcessMetrics* MaybeGetProcessMetrics(); | 276 base::ProcessMetrics* MaybeGetProcessMetrics(); |
277 | 277 |
278 // The prerender manager owning this object. | 278 // The prerender manager owning this object. |
279 PrerenderManager* prerender_manager_; | 279 PrerenderManager* prerender_manager_; |
280 | 280 |
281 // The prerender tracker tracking prerenders. | 281 // The prerender tracker tracking prerenders. |
282 PrerenderTracker* prerender_tracker_; | 282 PrerenderTracker* prerender_tracker_; |
283 | 283 |
284 WeakPrerenderHandle prerender_; | |
285 | |
284 // The URL being prerendered. | 286 // The URL being prerendered. |
285 GURL prerender_url_; | 287 GURL prerender_url_; |
286 | 288 |
287 // The referrer. | 289 // The referrer. |
288 content::Referrer referrer_; | 290 content::Referrer referrer_; |
289 | 291 |
290 // The profile being used | 292 // The profile being used |
291 Profile* profile_; | 293 Profile* profile_; |
292 | 294 |
293 // Information about the title and URL of the page that this class as a | 295 // Information about the title and URL of the page that this class as a |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
358 | 360 |
359 // The size of the WebView from the launching page. | 361 // The size of the WebView from the launching page. |
360 gfx::Size size_; | 362 gfx::Size size_; |
361 | 363 |
362 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 364 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
363 }; | 365 }; |
364 | 366 |
365 } // namespace prerender | 367 } // namespace prerender |
366 | 368 |
367 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 369 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
OLD | NEW |