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

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

Issue 1432583002: Move browser_navigation_start to CommonNavigationParams (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nasko review 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,
90 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, 90 entry.ConstructCommonNavigationParams(dest_url, dest_referrer,
91 frame_entry, navigation_type, 91 frame_entry, navigation_type,
92 LOFI_UNSPECIFIED), 92 LOFI_UNSPECIFIED, navigation_start),
93 BeginNavigationParams(method, headers.ToString(), 93 BeginNavigationParams(method, headers.ToString(),
94 LoadFlagFromNavigationType(navigation_type), 94 LoadFlagFromNavigationType(navigation_type),
95 false, // has_user_gestures 95 false, // has_user_gestures
96 false, // skip_service_worker 96 false, // skip_service_worker
97 REQUEST_CONTEXT_TYPE_LOCATION), 97 REQUEST_CONTEXT_TYPE_LOCATION),
98 entry.ConstructRequestNavigationParams( 98 entry.ConstructRequestNavigationParams(
99 frame_entry, navigation_start, is_same_document_history_load, 99 frame_entry, is_same_document_history_load,
100 frame_tree_node->has_committed_real_load(), 100 frame_tree_node->has_committed_real_load(),
101 controller->GetPendingEntryIndex() == -1, 101 controller->GetPendingEntryIndex() == -1,
102 controller->GetIndexOfEntry(&entry), 102 controller->GetIndexOfEntry(&entry),
103 controller->GetLastCommittedEntryIndex(), 103 controller->GetLastCommittedEntryIndex(),
104 controller->GetEntryCount()), 104 controller->GetEntryCount()),
105 request_body, true, &frame_entry, &entry)); 105 request_body, true, &frame_entry, &entry));
106 return navigation_request.Pass(); 106 return navigation_request.Pass();
107 } 107 }
108 108
109 // static 109 // static
110 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( 110 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
111 FrameTreeNode* frame_tree_node, 111 FrameTreeNode* frame_tree_node,
112 const CommonNavigationParams& common_params, 112 const CommonNavigationParams& common_params,
113 const BeginNavigationParams& begin_params, 113 const BeginNavigationParams& begin_params,
114 scoped_refptr<ResourceRequestBody> body, 114 scoped_refptr<ResourceRequestBody> body,
115 int current_history_list_offset, 115 int current_history_list_offset,
116 int current_history_list_length) { 116 int current_history_list_length) {
117 // TODO(clamy): Check if some PageState should be provided here. 117 // 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 118 // 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. 119 // 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 120 // 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. 121 // renderer and sent to the browser instead of being measured here.
122 // TODO(clamy): The pending history list offset should be properly set. 122 // TODO(clamy): The pending history list offset should be properly set.
123 // TODO(clamy): Set has_committed_real_load. 123 // TODO(clamy): Set has_committed_real_load.
124 RequestNavigationParams request_params( 124 RequestNavigationParams request_params(
125 false, // is_overriding_user_agent 125 false, // is_overriding_user_agent
126 base::TimeTicks::Now(), // browser_navigation_start
127 std::vector<GURL>(), // redirects 126 std::vector<GURL>(), // redirects
128 false, // can_load_local_resources 127 false, // can_load_local_resources
129 base::Time::Now(), // request_time 128 base::Time::Now(), // request_time
130 PageState(), // page_state 129 PageState(), // page_state
131 -1, // page_id 130 -1, // page_id
132 0, // nav_entry_id 131 0, // nav_entry_id
133 false, // is_same_document_history_load 132 false, // is_same_document_history_load
134 false, // has_committed_real_load 133 false, // has_committed_real_load
135 false, // intended_as_new_entry 134 false, // intended_as_new_entry
136 -1, // pending_history_list_offset 135 -1, // pending_history_list_offset
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { 305 if (result == NavigationThrottle::CANCEL_AND_IGNORE) {
307 frame_tree_node_->ResetNavigationRequest(false); 306 frame_tree_node_->ResetNavigationRequest(false);
308 return; 307 return;
309 } 308 }
310 309
311 loader_->FollowRedirect(); 310 loader_->FollowRedirect();
312 navigation_handle_->DidRedirectNavigation(common_params_.url); 311 navigation_handle_->DidRedirectNavigation(common_params_.url);
313 } 312 }
314 313
315 } // namespace content 314 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_request.h ('k') | content/browser/frame_host/navigator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698