OLD | NEW |
---|---|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_RENDERER_NAVIGATION_STATE_H_ | 5 #ifndef CHROME_RENDERER_NAVIGATION_STATE_H_ |
6 #define CHROME_RENDERER_NAVIGATION_STATE_H_ | 6 #define CHROME_RENDERER_NAVIGATION_STATE_H_ |
7 | 7 |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/common/page_transition_types.h" | 10 #include "chrome/common/page_transition_types.h" |
11 #include "chrome/renderer/user_script_idle_scheduler.h" | |
11 #include "webkit/api/public/WebDataSource.h" | 12 #include "webkit/api/public/WebDataSource.h" |
12 #include "webkit/glue/alt_error_page_resource_fetcher.h" | 13 #include "webkit/glue/alt_error_page_resource_fetcher.h" |
13 #include "webkit/glue/password_form.h" | 14 #include "webkit/glue/password_form.h" |
14 | 15 |
15 // The RenderView stores an instance of this class in the "extra data" of each | 16 // The RenderView stores an instance of this class in the "extra data" of each |
16 // WebDataSource (see RenderView::DidCreateDataSource). | 17 // WebDataSource (see RenderView::DidCreateDataSource). |
17 class NavigationState : public WebKit::WebDataSource::ExtraData { | 18 class NavigationState : public WebKit::WebDataSource::ExtraData { |
18 public: | 19 public: |
19 static NavigationState* CreateBrowserInitiated( | 20 static NavigationState* CreateBrowserInitiated( |
20 int32 pending_page_id, | 21 int32 pending_page_id, |
21 PageTransition::Type transition_type, | 22 PageTransition::Type transition_type, |
22 base::Time request_time) { | 23 base::Time request_time) { |
23 return new NavigationState(transition_type, request_time, false, | 24 return new NavigationState(transition_type, request_time, false, |
24 pending_page_id); | 25 pending_page_id); |
25 } | 26 } |
26 | 27 |
27 static NavigationState* CreateContentInitiated() { | 28 static NavigationState* CreateContentInitiated() { |
28 // We assume navigations initiated by content are link clicks. | 29 // We assume navigations initiated by content are link clicks. |
29 return new NavigationState(PageTransition::LINK, base::Time(), true, -1); | 30 return new NavigationState(PageTransition::LINK, base::Time(), true, -1); |
30 } | 31 } |
31 | 32 |
32 static NavigationState* FromDataSource(WebKit::WebDataSource* ds) { | 33 static NavigationState* FromDataSource(WebKit::WebDataSource* ds) { |
33 return static_cast<NavigationState*>(ds->extraData()); | 34 return static_cast<NavigationState*>(ds->extraData()); |
34 } | 35 } |
35 | 36 |
37 UserScriptIdleScheduler* user_script_idle_scheduler() { | |
Matt Perry
2009/11/02 19:46:30
Very clean. I like it.
| |
38 return user_script_idle_scheduler_.get(); | |
39 } | |
40 void set_user_script_idle_scheduler(UserScriptIdleScheduler* scheduler) { | |
41 user_script_idle_scheduler_.reset(scheduler); | |
42 } | |
43 | |
36 // Contains the page_id for this navigation or -1 if there is none yet. | 44 // Contains the page_id for this navigation or -1 if there is none yet. |
37 int32 pending_page_id() const { return pending_page_id_; } | 45 int32 pending_page_id() const { return pending_page_id_; } |
38 | 46 |
39 // Contains the transition type that the browser specified when it | 47 // Contains the transition type that the browser specified when it |
40 // initiated the load. | 48 // initiated the load. |
41 PageTransition::Type transition_type() const { return transition_type_; } | 49 PageTransition::Type transition_type() const { return transition_type_; } |
42 void set_transition_type(PageTransition::Type type) { | 50 void set_transition_type(PageTransition::Type type) { |
43 transition_type_ = type; | 51 transition_type_ = type; |
44 } | 52 } |
45 | 53 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 NavigationState(PageTransition::Type transition_type, | 174 NavigationState(PageTransition::Type transition_type, |
167 const base::Time& request_time, | 175 const base::Time& request_time, |
168 bool is_content_initiated, | 176 bool is_content_initiated, |
169 int32 pending_page_id) | 177 int32 pending_page_id) |
170 : transition_type_(transition_type), | 178 : transition_type_(transition_type), |
171 request_time_(request_time), | 179 request_time_(request_time), |
172 load_histograms_recorded_(false), | 180 load_histograms_recorded_(false), |
173 request_committed_(false), | 181 request_committed_(false), |
174 is_content_initiated_(is_content_initiated), | 182 is_content_initiated_(is_content_initiated), |
175 pending_page_id_(pending_page_id), | 183 pending_page_id_(pending_page_id), |
176 postpone_loading_data_(false) { | 184 postpone_loading_data_(false), |
185 user_script_idle_scheduler_(NULL) { | |
darin (slow to review)
2009/11/03 05:11:00
nit: no need to NULL out a scoped_ptr
| |
177 } | 186 } |
178 | 187 |
179 PageTransition::Type transition_type_; | 188 PageTransition::Type transition_type_; |
180 base::Time request_time_; | 189 base::Time request_time_; |
181 base::Time start_load_time_; | 190 base::Time start_load_time_; |
182 base::Time commit_load_time_; | 191 base::Time commit_load_time_; |
183 base::Time finish_document_load_time_; | 192 base::Time finish_document_load_time_; |
184 base::Time finish_load_time_; | 193 base::Time finish_load_time_; |
185 base::Time first_paint_time_; | 194 base::Time first_paint_time_; |
186 base::Time first_paint_after_load_time_; | 195 base::Time first_paint_after_load_time_; |
187 bool load_histograms_recorded_; | 196 bool load_histograms_recorded_; |
188 bool request_committed_; | 197 bool request_committed_; |
189 bool is_content_initiated_; | 198 bool is_content_initiated_; |
190 int32 pending_page_id_; | 199 int32 pending_page_id_; |
191 GURL searchable_form_url_; | 200 GURL searchable_form_url_; |
192 std::string searchable_form_encoding_; | 201 std::string searchable_form_encoding_; |
193 scoped_ptr<webkit_glue::PasswordForm> password_form_data_; | 202 scoped_ptr<webkit_glue::PasswordForm> password_form_data_; |
194 scoped_ptr<webkit_glue::AltErrorPageResourceFetcher> alt_error_page_fetcher_; | 203 scoped_ptr<webkit_glue::AltErrorPageResourceFetcher> alt_error_page_fetcher_; |
195 std::string security_info_; | 204 std::string security_info_; |
196 bool postpone_loading_data_; | 205 bool postpone_loading_data_; |
197 std::string postponed_data_; | 206 std::string postponed_data_; |
207 scoped_ptr<UserScriptIdleScheduler> user_script_idle_scheduler_; | |
198 | 208 |
199 DISALLOW_COPY_AND_ASSIGN(NavigationState); | 209 DISALLOW_COPY_AND_ASSIGN(NavigationState); |
200 }; | 210 }; |
201 | 211 |
202 #endif // CHROME_RENDERER_NAVIGATION_STATE_H_ | 212 #endif // CHROME_RENDERER_NAVIGATION_STATE_H_ |
OLD | NEW |