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

Side by Side Diff: chrome/renderer/navigation_state.h

Issue 6685072: Move a bunch more random files from chrome\renderer to content\renderer. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 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
« no previous file with comments | « chrome/renderer/loadtimes_extension_bindings.cc ('k') | chrome/renderer/navigation_state.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_RENDERER_NAVIGATION_STATE_H_
6 #define CHROME_RENDERER_NAVIGATION_STATE_H_
7 #pragma once
8
9 #include <string>
10
11 #include "base/logging.h"
12 #include "base/scoped_ptr.h"
13 #include "base/time.h"
14 #include "chrome/common/extensions/url_pattern.h"
15 #include "content/common/page_transition_types.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h"
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h"
18
19 namespace webkit_glue {
20 struct PasswordForm;
21 class AltErrorPageResourceFetcher;
22 }
23
24 class UserScriptIdleScheduler;
25
26 // The RenderView stores an instance of this class in the "extra data" of each
27 // WebDataSource (see RenderView::DidCreateDataSource).
28 class NavigationState : public WebKit::WebDataSource::ExtraData {
29 public:
30 // The exact values of this enum are used in histograms, so new values must be
31 // added to the end.
32 enum LoadType {
33 UNDEFINED_LOAD, // Not yet initialized.
34 RELOAD, // User pressed reload.
35 HISTORY_LOAD, // Back or forward.
36 NORMAL_LOAD, // User entered URL, or omnibox search.
37 LINK_LOAD, // (deprecated) Included next 4 categories.
38 LINK_LOAD_NORMAL, // Commonly following of link.
39 LINK_LOAD_RELOAD, // JS/link directed reload.
40 LINK_LOAD_CACHE_STALE_OK, // back/forward or encoding change.
41 LINK_LOAD_CACHE_ONLY, // Allow stale data (avoid doing a re-post)
42 PRERENDER_LOAD, // Navigation started as the speculative
43 // prendering of a linked page.
44 kLoadTypeMax // Bounding value for this enum.
45 };
46
47 virtual ~NavigationState();
48
49 static NavigationState* CreateBrowserInitiated(
50 int32 pending_page_id,
51 int pending_history_list_offset,
52 PageTransition::Type transition_type,
53 base::Time request_time) {
54 return new NavigationState(transition_type, request_time, false,
55 pending_page_id,
56 pending_history_list_offset);
57 }
58
59 static NavigationState* CreateContentInitiated() {
60 // We assume navigations initiated by content are link clicks.
61 return new NavigationState(PageTransition::LINK, base::Time(), true, -1,
62 -1);
63 }
64
65 static NavigationState* FromDataSource(WebKit::WebDataSource* ds) {
66 return static_cast<NavigationState*>(ds->extraData());
67 }
68
69 UserScriptIdleScheduler* user_script_idle_scheduler() {
70 return user_script_idle_scheduler_.get();
71 }
72 void set_user_script_idle_scheduler(UserScriptIdleScheduler* scheduler);
73 void swap_user_script_idle_scheduler(NavigationState* state);
74
75 // Contains the page_id for this navigation or -1 if there is none yet.
76 int32 pending_page_id() const { return pending_page_id_; }
77
78 // If pending_page_id() is not -1, then this contains the corresponding
79 // offset of the page in the back/forward history list.
80 int pending_history_list_offset() const {
81 return pending_history_list_offset_;
82 }
83
84 // Contains the transition type that the browser specified when it
85 // initiated the load.
86 PageTransition::Type transition_type() const { return transition_type_; }
87 void set_transition_type(PageTransition::Type type) {
88 transition_type_ = type;
89 }
90
91 // Record the nature of this load, for use when histogramming page load times.
92 LoadType load_type() const { return load_type_; }
93 void set_load_type(LoadType load_type) { load_type_ = load_type; }
94
95 // The time that this navigation was requested.
96 const base::Time& request_time() const {
97 return request_time_;
98 }
99 void set_request_time(const base::Time& value) {
100 DCHECK(start_load_time_.is_null());
101 request_time_ = value;
102 }
103
104 // The time that the document load started.
105 const base::Time& start_load_time() const {
106 return start_load_time_;
107 }
108 void set_start_load_time(const base::Time& value) {
109 // TODO(jar): This should not be set twice.
110 // DCHECK(!start_load_time_.is_null());
111 DCHECK(finish_document_load_time_.is_null());
112 start_load_time_ = value;
113 }
114
115 // The time that the document load was committed.
116 const base::Time& commit_load_time() const {
117 return commit_load_time_;
118 }
119 void set_commit_load_time(const base::Time& value) {
120 commit_load_time_ = value;
121 }
122
123 // The time that the document finished loading.
124 const base::Time& finish_document_load_time() const {
125 return finish_document_load_time_;
126 }
127 void set_finish_document_load_time(const base::Time& value) {
128 // TODO(jar): Some unittests break the following DCHECK, and don't have
129 // DCHECK(!start_load_time_.is_null());
130 DCHECK(!value.is_null());
131 // TODO(jar): Double setting does happen, but probably shouldn't.
132 // DCHECK(finish_document_load_time_.is_null());
133 // TODO(jar): We should guarantee this order :-(.
134 // DCHECK(finish_load_time_.is_null());
135 finish_document_load_time_ = value;
136 }
137
138 // The time that the document and all subresources finished loading.
139 const base::Time& finish_load_time() const { return finish_load_time_; }
140 void set_finish_load_time(const base::Time& value) {
141 DCHECK(!value.is_null());
142 DCHECK(finish_load_time_.is_null());
143 // The following is not already set in all cases :-(
144 // DCHECK(!finish_document_load_time_.is_null());
145 finish_load_time_ = value;
146 }
147
148 // The time that painting first happened after a new navigation.
149 const base::Time& first_paint_time() const { return first_paint_time_; }
150 void set_first_paint_time(const base::Time& value) {
151 first_paint_time_ = value;
152 }
153
154 // The time that painting first happened after the document finished loading.
155 const base::Time& first_paint_after_load_time() const {
156 return first_paint_after_load_time_;
157 }
158 void set_first_paint_after_load_time(const base::Time& value) {
159 first_paint_after_load_time_ = value;
160 }
161
162 // The time that a prerendered page was displayed. Invalid for
163 // non-prerendered pages. Can be either before or after
164 // |finish_document_load_time_|.
165 const base::Time& prerendered_page_display_time() const;
166 void set_prerendered_page_display_time(const base::Time& value);
167
168 // True iff the histograms for the associated frame have been dumped.
169 bool load_histograms_recorded() const { return load_histograms_recorded_; }
170 void set_load_histograms_recorded(bool value) {
171 load_histograms_recorded_ = value;
172 }
173
174 bool web_timing_histograms_recorded() const {
175 return web_timing_histograms_recorded_;
176 }
177 void set_web_timing_histograms_recorded(bool value) {
178 web_timing_histograms_recorded_ = value;
179 }
180
181 // True if we have already processed the "DidCommitLoad" event for this
182 // request. Used by session history.
183 bool request_committed() const { return request_committed_; }
184 void set_request_committed(bool value) { request_committed_ = value; }
185
186 // True if this navigation was not initiated via WebFrame::LoadRequest.
187 bool is_content_initiated() const { return is_content_initiated_; }
188
189 const GURL& searchable_form_url() const { return searchable_form_url_; }
190 void set_searchable_form_url(const GURL& url) { searchable_form_url_ = url; }
191 const std::string& searchable_form_encoding() const {
192 return searchable_form_encoding_;
193 }
194 void set_searchable_form_encoding(const std::string& encoding) {
195 searchable_form_encoding_ = encoding;
196 }
197
198 webkit_glue::PasswordForm* password_form_data() const {
199 return password_form_data_.get();
200 }
201 void set_password_form_data(webkit_glue::PasswordForm* data);
202
203 webkit_glue::AltErrorPageResourceFetcher* alt_error_page_fetcher() const {
204 return alt_error_page_fetcher_.get();
205 }
206 void set_alt_error_page_fetcher(webkit_glue::AltErrorPageResourceFetcher* f);
207
208 const std::string& security_info() const { return security_info_; }
209 void set_security_info(const std::string& security_info) {
210 security_info_ = security_info;
211 }
212
213 bool use_error_page() const { return use_error_page_; }
214 void set_use_error_page(bool use_error_page) {
215 use_error_page_ = use_error_page;
216 }
217
218 bool was_started_as_prerender() const;
219 void set_was_started_as_prerender(bool was_started_as_prerender);
220
221 int http_status_code() const { return http_status_code_; }
222 void set_http_status_code(int http_status_code) {
223 http_status_code_ = http_status_code;
224 }
225
226 // Sets the cache policy. The cache policy is only used if explicitly set and
227 // by default is not set. You can mark a NavigationState as not having a cache
228 // state by way of clear_cache_policy_override.
229 void set_cache_policy_override(
230 WebKit::WebURLRequest::CachePolicy cache_policy) {
231 cache_policy_override_ = cache_policy;
232 cache_policy_override_set_ = true;
233 }
234 WebKit::WebURLRequest::CachePolicy cache_policy_override() const {
235 return cache_policy_override_;
236 }
237 void clear_cache_policy_override() {
238 cache_policy_override_set_ = false;
239 cache_policy_override_ = WebKit::WebURLRequest::UseProtocolCachePolicy;
240 }
241 bool is_cache_policy_override_set() const {
242 return cache_policy_override_set_;
243 }
244
245 // Indicator if SPDY was used as part of this page load.
246 void set_was_fetched_via_spdy(bool value) { was_fetched_via_spdy_ = value; }
247 bool was_fetched_via_spdy() const { return was_fetched_via_spdy_; }
248
249 void set_was_npn_negotiated(bool value) { was_npn_negotiated_ = value; }
250 bool was_npn_negotiated() const { return was_npn_negotiated_; }
251
252 void set_was_alternate_protocol_available(bool value) {
253 was_alternate_protocol_available_ = value;
254 }
255 bool was_alternate_protocol_available() const {
256 return was_alternate_protocol_available_;
257 }
258
259 void set_was_fetched_via_proxy(bool value) {
260 was_fetched_via_proxy_ = value;
261 }
262 bool was_fetched_via_proxy() const { return was_fetched_via_proxy_; }
263
264 // Whether the frame text contents was translated to a different language.
265 void set_was_translated(bool value) { was_translated_ = value; }
266 bool was_translated() const { return was_translated_; }
267
268 // True iff the frame's navigation was within the same page.
269 void set_was_within_same_page(bool value) { was_within_same_page_ = value; }
270 bool was_within_same_page() const { return was_within_same_page_; }
271
272 void set_was_prefetcher(bool value) { was_prefetcher_ = value; }
273 bool was_prefetcher() const { return was_prefetcher_; }
274
275 void set_was_referred_by_prefetcher(bool value) {
276 was_referred_by_prefetcher_ = value;
277 }
278 bool was_referred_by_prefetcher() const {
279 return was_referred_by_prefetcher_;
280 }
281
282 private:
283 NavigationState(PageTransition::Type transition_type,
284 const base::Time& request_time,
285 bool is_content_initiated,
286 int32 pending_page_id,
287 int pending_history_list_offset);
288
289 PageTransition::Type transition_type_;
290 LoadType load_type_;
291 base::Time request_time_;
292 base::Time start_load_time_;
293 base::Time commit_load_time_;
294 base::Time finish_document_load_time_;
295 base::Time finish_load_time_;
296 base::Time first_paint_time_;
297 base::Time first_paint_after_load_time_;
298 base::Time prerendered_page_display_time_;
299 bool load_histograms_recorded_;
300 bool web_timing_histograms_recorded_;
301 bool request_committed_;
302 bool is_content_initiated_;
303 int32 pending_page_id_;
304 int pending_history_list_offset_;
305 GURL searchable_form_url_;
306 std::string searchable_form_encoding_;
307 scoped_ptr<webkit_glue::PasswordForm> password_form_data_;
308 scoped_ptr<webkit_glue::AltErrorPageResourceFetcher> alt_error_page_fetcher_;
309 std::string security_info_;
310
311 // True if we should use an error page, if the http status code alos indicates
312 // an error.
313 bool use_error_page_;
314
315 // True if a page load started as a prerender. Preserved across redirects.
316 bool was_started_as_prerender_;
317
318 bool cache_policy_override_set_;
319 WebKit::WebURLRequest::CachePolicy cache_policy_override_;
320
321 scoped_ptr<UserScriptIdleScheduler> user_script_idle_scheduler_;
322 int http_status_code_;
323
324 bool was_fetched_via_spdy_;
325 bool was_npn_negotiated_;
326 bool was_alternate_protocol_available_;
327 bool was_fetched_via_proxy_;
328 bool was_translated_;
329 bool was_within_same_page_;
330
331 // A prefetcher is a page that contains link rel=prefetch elements.
332 bool was_prefetcher_;
333 bool was_referred_by_prefetcher_;
334
335 DISALLOW_COPY_AND_ASSIGN(NavigationState);
336 };
337
338 #endif // CHROME_RENDERER_NAVIGATION_STATE_H_
OLDNEW
« no previous file with comments | « chrome/renderer/loadtimes_extension_bindings.cc ('k') | chrome/renderer/navigation_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698