OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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> |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 PendingPrerenderData(Origin origin, const GURL& url, const GURL& referrer); | 75 PendingPrerenderData(Origin origin, const GURL& url, const GURL& referrer); |
76 | 76 |
77 Origin origin; | 77 Origin origin; |
78 GURL url; | 78 GURL url; |
79 GURL referrer; | 79 GURL referrer; |
80 }; | 80 }; |
81 typedef std::list<PendingPrerenderData> PendingPrerenderList; | 81 typedef std::list<PendingPrerenderData> PendingPrerenderList; |
82 | 82 |
83 virtual ~PrerenderContents(); | 83 virtual ~PrerenderContents(); |
84 | 84 |
85 // Initializes the prerendering. This can fail if the URL to be prerendered | |
86 // was recently visited. If false is returned, the caller should | |
87 // destroy the PrerenderContents object. | |
85 bool Init(); | 88 bool Init(); |
86 | 89 |
87 static Factory* CreateFactory(); | 90 static Factory* CreateFactory(); |
88 | 91 |
89 // |source_render_view_host| is the RenderViewHost that initiated | 92 // |source_render_view_host| is the RenderViewHost that initiated |
90 // prerendering. | 93 // prerendering. |
91 virtual void StartPrerendering( | 94 virtual void StartPrerendering( |
92 const RenderViewHost* source_render_view_host, | 95 const RenderViewHost* source_render_view_host, |
93 SessionStorageNamespace* session_storage_namespace); | 96 SessionStorageNamespace* session_storage_namespace); |
94 | 97 |
95 // Verifies that the prerendering is not using too many resources, and kills | 98 // Verifies that the prerendering is not using too many resources, and kills |
96 // it if not. | 99 // it if not. |
97 void DestroyWhenUsingTooManyResources(); | 100 void DestroyWhenUsingTooManyResources(); |
98 | 101 |
99 RenderViewHost* render_view_host_mutable(); | 102 RenderViewHost* render_view_host_mutable(); |
100 const RenderViewHost* render_view_host() const; | 103 const RenderViewHost* render_view_host() const; |
101 | 104 |
102 ViewHostMsg_FrameNavigate_Params* navigate_params() { | 105 ViewHostMsg_FrameNavigate_Params* navigate_params() { |
103 return navigate_params_.get(); | 106 return navigate_params_.get(); |
104 } | 107 } |
105 string16 title() const { return title_; } | 108 string16 title() const { return title_; } |
106 int32 page_id() const { return page_id_; } | 109 int32 page_id() const { return page_id_; } |
107 GURL icon_url() const { return icon_url_; } | 110 GURL icon_url() const { return icon_url_; } |
108 const GURL& prerender_url() const { return prerender_url_; } | 111 const GURL& prerender_url() const { return prerender_url_; } |
112 const GURL& referrer() const { return referrer_; } | |
109 bool has_stopped_loading() const { return has_stopped_loading_; } | 113 bool has_stopped_loading() const { return has_stopped_loading_; } |
110 bool prerendering_has_started() const { return prerendering_has_started_; } | 114 bool prerendering_has_started() const { return prerendering_has_started_; } |
111 | 115 |
112 // Sets the parameter to the value of the associated RenderViewHost's child id | 116 // Sets the parameter to the value of the associated RenderViewHost's child id |
113 // and returns a boolean indicating the validity of that id. | 117 // and returns a boolean indicating the validity of that id. |
114 virtual bool GetChildId(int* child_id) const; | 118 virtual bool GetChildId(int* child_id) const; |
115 | 119 |
116 // Sets the parameter to the value of the associated RenderViewHost's route id | 120 // Sets the parameter to the value of the associated RenderViewHost's route id |
117 // and returns a boolean indicating the validity of that id. | 121 // and returns a boolean indicating the validity of that id. |
118 virtual bool GetRouteId(int* route_id) const; | 122 virtual bool GetRouteId(int* route_id) const; |
119 | 123 |
120 // Set the final status for how the PrerenderContents was used. This | 124 // Set the final status for how the PrerenderContents was used. This |
121 // should only be called once, and should be called before the prerender | 125 // should only be called once, and should be called before the prerender |
122 // contents are destroyed. | 126 // contents are destroyed. |
123 void set_final_status(FinalStatus final_status); | 127 void set_final_status(FinalStatus final_status); |
124 FinalStatus final_status() const { return final_status_; } | 128 FinalStatus final_status() const { return final_status_; } |
125 | 129 |
126 Origin origin() const { return origin_; } | 130 Origin origin() const { return origin_; } |
131 uint8 experiment_id() const { return experiment_id_; } | |
127 | 132 |
128 base::TimeTicks load_start_time() const { return load_start_time_; } | 133 base::TimeTicks load_start_time() const { return load_start_time_; } |
129 | 134 |
130 // Indicates whether this prerendered page can be used for the provided | 135 // Indicates whether this prerendered page can be used for the provided |
131 // URL, i.e. whether there is a match. |matching_url| is optional and will be | 136 // URL, i.e. whether there is a match. |matching_url| is optional and will be |
132 // set to the URL that is found as a match if it is provided. | 137 // set to the URL that is found as a match if it is provided. |
133 bool MatchesURL(const GURL& url, GURL* matching_url) const; | 138 bool MatchesURL(const GURL& url, GURL* matching_url) const; |
134 | 139 |
135 void OnJSOutOfMemory(); | 140 void OnJSOutOfMemory(); |
136 bool ShouldSuppressDialogs(); | 141 bool ShouldSuppressDialogs(); |
137 | 142 |
138 // TabContentsObserver implementation. | 143 // TabContentsObserver implementation. |
139 virtual void DidStopLoading() OVERRIDE; | 144 virtual void DidStopLoading() OVERRIDE; |
140 virtual void DidStartProvisionalLoadForFrame( | 145 virtual void DidStartProvisionalLoadForFrame( |
141 int64 frame_id, | 146 int64 frame_id, |
142 bool is_main_frame, | 147 bool is_main_frame, |
143 const GURL& validated_url, | 148 const GURL& validated_url, |
144 bool is_error_page, | 149 bool is_error_page, |
145 RenderViewHost* render_view_host) OVERRIDE; | 150 RenderViewHost* render_view_host) OVERRIDE; |
146 virtual void RenderViewGone() OVERRIDE; | 151 virtual void RenderViewGone() OVERRIDE; |
147 | 152 |
148 // content::NotificationObserver | 153 // content::NotificationObserver |
149 virtual void Observe(int type, | 154 virtual void Observe(int type, |
150 const content::NotificationSource& source, | 155 const content::NotificationSource& source, |
151 const content::NotificationDetails& details) OVERRIDE; | 156 const content::NotificationDetails& details) OVERRIDE; |
152 | 157 |
153 // Adds an alias URL, for one of the many redirections. If the URL can not | 158 // Adds an alias URL, for one of the many redirections. If the URL can not |
154 // be prerendered - for example, it's an ftp URL - |this| will be destroyed | 159 // be prerendered - for example, it's an ftp URL - |this| will be destroyed |
155 // and false is returned. Otherwise, true is returned and the alias is | 160 // and false is returned. Otherwise, true is returned and the alias is |
156 // remembered. | 161 // remembered. If destroy_on_failure is set to false, no actual destruction |
157 virtual bool AddAliasURL(const GURL& url); | 162 // will happen, but the caller will have to take care of deleting the object |
163 // himself. | |
164 virtual bool AddAliasURL(const GURL& url, bool destroy_on_failure); | |
dominich
2011/11/11 20:02:09
I've been through the CL but I don't understand wh
| |
158 | 165 |
159 // The preview TabContents (may be null). | 166 // The preview TabContents (may be null). |
160 TabContentsWrapper* prerender_contents() const { | 167 TabContentsWrapper* prerender_contents() const { |
161 return prerender_contents_.get(); | 168 return prerender_contents_.get(); |
162 } | 169 } |
163 | 170 |
164 TabContentsWrapper* ReleasePrerenderContents(); | 171 TabContentsWrapper* ReleasePrerenderContents(); |
165 | 172 |
166 // Sets the final status, calls OnDestroy and adds |this| to the | 173 // Sets the final status, calls OnDestroy and adds |this| to the |
167 // PrerenderManager's pending deletes list. | 174 // PrerenderManager's pending deletes list. |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
310 | 317 |
311 // Offset by which to offset prerendered pages | 318 // Offset by which to offset prerendered pages |
312 static const int32 kPrerenderPageIdOffset = 10; | 319 static const int32 kPrerenderPageIdOffset = 10; |
313 | 320 |
314 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); | 321 DISALLOW_COPY_AND_ASSIGN(PrerenderContents); |
315 }; | 322 }; |
316 | 323 |
317 } // namespace prerender | 324 } // namespace prerender |
318 | 325 |
319 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ | 326 #endif // CHROME_BROWSER_PRERENDER_PRERENDER_CONTENTS_H_ |
OLD | NEW |