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

Side by Side Diff: content/browser/frame_host/navigation_request.cc

Issue 1425823002: (DEPRECATED) Send navigation_start to browser process in DidStartProvisionalLoad (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop calling didCreateDataSource for same-page navs Created 5 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/browser/frame_host/navigation_request.h" 5 #include "content/browser/frame_host/navigation_request.h"
6 6
7 #include "content/browser/frame_host/frame_tree.h" 7 #include "content/browser/frame_host/frame_tree.h"
8 #include "content/browser/frame_host/frame_tree_node.h" 8 #include "content/browser/frame_host/frame_tree_node.h"
9 #include "content/browser/frame_host/navigation_controller_impl.h" 9 #include "content/browser/frame_host/navigation_controller_impl.h"
10 #include "content/browser/frame_host/navigation_handle_impl.h" 10 #include "content/browser/frame_host/navigation_handle_impl.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 // static 56 // static
57 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( 57 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
58 FrameTreeNode* frame_tree_node, 58 FrameTreeNode* frame_tree_node,
59 const GURL& dest_url, 59 const GURL& dest_url,
60 const Referrer& dest_referrer, 60 const Referrer& dest_referrer,
61 const FrameNavigationEntry& frame_entry, 61 const FrameNavigationEntry& frame_entry,
62 const NavigationEntryImpl& entry, 62 const NavigationEntryImpl& entry,
63 FrameMsg_Navigate_Type::Value navigation_type, 63 FrameMsg_Navigate_Type::Value navigation_type,
64 bool is_same_document_history_load, 64 bool is_same_document_history_load,
65 base::TimeTicks navigation_start, 65 const base::TimeTicks& navigation_start,
66 NavigationControllerImpl* controller) { 66 NavigationControllerImpl* controller) {
67 std::string method = entry.GetHasPostData() ? "POST" : "GET"; 67 std::string method = entry.GetHasPostData() ? "POST" : "GET";
68 68
69 // Copy existing headers and add necessary headers that may not be present 69 // Copy existing headers and add necessary headers that may not be present
70 // in the RequestNavigationParams. 70 // in the RequestNavigationParams.
71 net::HttpRequestHeaders headers; 71 net::HttpRequestHeaders headers;
72 headers.AddHeadersFromString(entry.extra_headers()); 72 headers.AddHeadersFromString(entry.extra_headers());
73 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, 73 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent,
74 GetContentClient()->GetUserAgent()); 74 GetContentClient()->GetUserAgent());
75 // TODO(clamy): match what blink is doing with accept headers. 75 // TODO(clamy): match what blink is doing with accept headers.
76 headers.SetHeaderIfMissing("Accept", "*/*"); 76 headers.SetHeaderIfMissing("Accept", "*/*");
77 77
78 // Fill POST data from the browser in the request body. 78 // Fill POST data from the browser in the request body.
79 scoped_refptr<ResourceRequestBody> request_body; 79 scoped_refptr<ResourceRequestBody> request_body;
80 if (entry.GetHasPostData()) { 80 if (entry.GetHasPostData()) {
81 request_body = new ResourceRequestBody(); 81 request_body = new ResourceRequestBody();
82 request_body->AppendBytes( 82 request_body->AppendBytes(
83 reinterpret_cast<const char *>( 83 reinterpret_cast<const char *>(
84 entry.GetBrowserInitiatedPostData()->front()), 84 entry.GetBrowserInitiatedPostData()->front()),
85 entry.GetBrowserInitiatedPostData()->size()); 85 entry.GetBrowserInitiatedPostData()->size());
86 } 86 }
87 87
88 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( 88 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest(
89 frame_tree_node, 89 frame_tree_node, entry.ConstructCommonNavigationParams(
90 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, 90 dest_url, dest_referrer, frame_entry,
91 frame_entry, navigation_type, 91 navigation_type, LOFI_UNSPECIFIED, navigation_start),
92 LOFI_UNSPECIFIED),
93 BeginNavigationParams(method, headers.ToString(), 92 BeginNavigationParams(method, headers.ToString(),
94 LoadFlagFromNavigationType(navigation_type), 93 LoadFlagFromNavigationType(navigation_type),
95 false, // has_user_gestures 94 false, // has_user_gestures
96 false, // skip_service_worker 95 false, // skip_service_worker
97 REQUEST_CONTEXT_TYPE_LOCATION), 96 REQUEST_CONTEXT_TYPE_LOCATION),
98 entry.ConstructRequestNavigationParams( 97 entry.ConstructRequestNavigationParams(
99 frame_entry, navigation_start, is_same_document_history_load, 98 frame_entry, is_same_document_history_load,
100 frame_tree_node->has_committed_real_load(), 99 frame_tree_node->has_committed_real_load(),
101 controller->GetPendingEntryIndex() == -1, 100 controller->GetPendingEntryIndex() == -1,
102 controller->GetIndexOfEntry(&entry), 101 controller->GetIndexOfEntry(&entry),
103 controller->GetLastCommittedEntryIndex(), 102 controller->GetLastCommittedEntryIndex(),
104 controller->GetEntryCount()), 103 controller->GetEntryCount()),
105 request_body, true, &frame_entry, &entry)); 104 request_body, true, &frame_entry, &entry));
106 return navigation_request.Pass(); 105 return navigation_request.Pass();
107 } 106 }
108 107
109 // static 108 // static
110 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( 109 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
111 FrameTreeNode* frame_tree_node, 110 FrameTreeNode* frame_tree_node,
112 const CommonNavigationParams& common_params, 111 const CommonNavigationParams& common_params,
113 const BeginNavigationParams& begin_params, 112 const BeginNavigationParams& begin_params,
114 scoped_refptr<ResourceRequestBody> body, 113 scoped_refptr<ResourceRequestBody> body,
115 int current_history_list_offset, 114 int current_history_list_offset,
116 int current_history_list_length) { 115 int current_history_list_length) {
117 // TODO(clamy): Check if some PageState should be provided here. 116 // TODO(clamy): Check if some PageState should be provided here.
118 // TODO(clamy): See how we should handle override of the user agent when the 117 // TODO(clamy): See how we should handle override of the user agent when the
119 // navigation may start in a renderer and commit in another one. 118 // navigation may start in a renderer and commit in another one.
120 // TODO(clamy): See if the navigation start time should be measured in the 119 // TODO(clamy): See if the navigation start time should be measured in the
121 // renderer and sent to the browser instead of being measured here. 120 // renderer and sent to the browser instead of being measured here.
122 // TODO(clamy): The pending history list offset should be properly set. 121 // TODO(clamy): The pending history list offset should be properly set.
123 // TODO(clamy): Set has_committed_real_load. 122 // TODO(clamy): Set has_committed_real_load.
124 RequestNavigationParams request_params( 123 RequestNavigationParams request_params(
125 false, // is_overriding_user_agent 124 false, // is_overriding_user_agent
126 base::TimeTicks::Now(), // browser_navigation_start
127 std::vector<GURL>(), // redirects 125 std::vector<GURL>(), // redirects
128 false, // can_load_local_resources 126 false, // can_load_local_resources
129 base::Time::Now(), // request_time 127 base::Time::Now(), // request_time
130 PageState(), // page_state 128 PageState(), // page_state
131 -1, // page_id 129 -1, // page_id
132 0, // nav_entry_id 130 0, // nav_entry_id
133 false, // is_same_document_history_load 131 false, // is_same_document_history_load
134 false, // has_committed_real_load 132 false, // has_committed_real_load
135 false, // intended_as_new_entry 133 false, // intended_as_new_entry
136 -1, // pending_history_list_offset 134 -1, // pending_history_list_offset
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 210
213 // There is no need to make a network request for this navigation, so commit 211 // There is no need to make a network request for this navigation, so commit
214 // it immediately. 212 // it immediately.
215 state_ = RESPONSE_STARTED; 213 state_ = RESPONSE_STARTED;
216 frame_tree_node_->navigator()->CommitNavigation( 214 frame_tree_node_->navigator()->CommitNavigation(
217 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>()); 215 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>());
218 } 216 }
219 217
220 void NavigationRequest::CreateNavigationHandle() { 218 void NavigationRequest::CreateNavigationHandle() {
221 navigation_handle_ = NavigationHandleImpl::Create( 219 navigation_handle_ = NavigationHandleImpl::Create(
222 common_params_.url, frame_tree_node_); 220 common_params_.url, frame_tree_node_, common_params_.navigation_start);
223 } 221 }
224 222
225 void NavigationRequest::TransferNavigationHandleOwnership( 223 void NavigationRequest::TransferNavigationHandleOwnership(
226 RenderFrameHostImpl* render_frame_host) { 224 RenderFrameHostImpl* render_frame_host) {
227 render_frame_host->SetNavigationHandle(navigation_handle_.Pass()); 225 render_frame_host->SetNavigationHandle(navigation_handle_.Pass());
228 render_frame_host->navigation_handle()->ReadyToCommitNavigation( 226 render_frame_host->navigation_handle()->ReadyToCommitNavigation(
229 render_frame_host); 227 render_frame_host);
230 } 228 }
231 229
232 void NavigationRequest::OnRequestRedirected( 230 void NavigationRequest::OnRequestRedirected(
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { 304 if (result == NavigationThrottle::CANCEL_AND_IGNORE) {
307 frame_tree_node_->ResetNavigationRequest(false); 305 frame_tree_node_->ResetNavigationRequest(false);
308 return; 306 return;
309 } 307 }
310 308
311 loader_->FollowRedirect(); 309 loader_->FollowRedirect();
312 navigation_handle_->DidRedirectNavigation(common_params_.url); 310 navigation_handle_->DidRedirectNavigation(common_params_.url);
313 } 311 }
314 312
315 } // namespace content 313 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698