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

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

Issue 971653004: Remove the FrameMsg_Navigate_Params (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@history-params
Patch Set: Addressed Nasko's comments Created 5 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
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_request_info.h" 10 #include "content/browser/frame_host/navigation_request_info.h"
10 #include "content/browser/frame_host/navigator.h" 11 #include "content/browser/frame_host/navigator.h"
11 #include "content/browser/loader/navigation_url_loader.h" 12 #include "content/browser/loader/navigation_url_loader.h"
12 #include "content/browser/site_instance_impl.h" 13 #include "content/browser/site_instance_impl.h"
13 #include "content/common/resource_request_body.h" 14 #include "content/common/resource_request_body.h"
14 #include "content/public/browser/navigation_controller.h" 15 #include "content/public/browser/navigation_controller.h"
15 #include "content/public/browser/stream_handle.h" 16 #include "content/public/browser/stream_handle.h"
16 #include "content/public/common/content_client.h" 17 #include "content/public/common/content_client.h"
17 #include "net/base/load_flags.h" 18 #include "net/base/load_flags.h"
18 #include "net/http/http_request_headers.h" 19 #include "net/http/http_request_headers.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // TODO(clamy): same document navigations should not make network requests. 56 // TODO(clamy): same document navigations should not make network requests.
56 return !url.SchemeIs(url::kDataScheme); 57 return !url.SchemeIs(url::kDataScheme);
57 } 58 }
58 59
59 // static 60 // static
60 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( 61 scoped_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated(
61 FrameTreeNode* frame_tree_node, 62 FrameTreeNode* frame_tree_node,
62 const NavigationEntryImpl& entry, 63 const NavigationEntryImpl& entry,
63 FrameMsg_Navigate_Type::Value navigation_type, 64 FrameMsg_Navigate_Type::Value navigation_type,
64 base::TimeTicks navigation_start, 65 base::TimeTicks navigation_start,
65 const HistoryNavigationParams& history_params) { 66 NavigationControllerImpl* controller) {
66 std::string method = entry.GetHasPostData() ? "POST" : "GET"; 67 std::string method = entry.GetHasPostData() ? "POST" : "GET";
67 68
68 // 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
69 // in the RequestNavigationParams. 70 // in the RequestNavigationParams.
70 net::HttpRequestHeaders headers; 71 net::HttpRequestHeaders headers;
71 headers.AddHeadersFromString(entry.extra_headers()); 72 headers.AddHeadersFromString(entry.extra_headers());
72 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, 73 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent,
73 GetContentClient()->GetUserAgent()); 74 GetContentClient()->GetUserAgent());
74 // TODO(clamy): match what blink is doing with accept headers. 75 // TODO(clamy): match what blink is doing with accept headers.
75 headers.SetHeaderIfMissing("Accept", "*/*"); 76 headers.SetHeaderIfMissing("Accept", "*/*");
76 77
77 // Fill POST data from the browser in the request body. 78 // Fill POST data from the browser in the request body.
78 scoped_refptr<ResourceRequestBody> request_body; 79 scoped_refptr<ResourceRequestBody> request_body;
79 if (entry.GetHasPostData()) { 80 if (entry.GetHasPostData()) {
80 request_body = new ResourceRequestBody(); 81 request_body = new ResourceRequestBody();
81 request_body->AppendBytes( 82 request_body->AppendBytes(
82 reinterpret_cast<const char *>( 83 reinterpret_cast<const char *>(
83 entry.GetBrowserInitiatedPostData()->front()), 84 entry.GetBrowserInitiatedPostData()->front()),
84 entry.GetBrowserInitiatedPostData()->size()); 85 entry.GetBrowserInitiatedPostData()->size());
85 } 86 }
86 87
87 FrameMsg_UILoadMetricsReportType::Value report_type =
88 FrameMsg_UILoadMetricsReportType::NO_REPORT;
89 base::TimeTicks ui_timestamp = base::TimeTicks();
90 #if defined(OS_ANDROID)
91 if (!entry.intent_received_timestamp().is_null())
92 report_type = FrameMsg_UILoadMetricsReportType::REPORT_INTENT;
93 ui_timestamp = entry.intent_received_timestamp();
94 #endif
95
96 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( 88 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest(
97 frame_tree_node, 89 frame_tree_node, entry.ConstructCommonNavigationParams(navigation_type),
98 CommonNavigationParams(
99 entry.GetURL(), entry.GetReferrer(), entry.GetTransitionType(),
100 navigation_type, !entry.IsViewSourceMode(), ui_timestamp, report_type,
101 entry.GetBaseURLForDataURL(), entry.GetHistoryURLForDataURL()),
102 BeginNavigationParams(method, headers.ToString(), 90 BeginNavigationParams(method, headers.ToString(),
103 LoadFlagFromNavigationType(navigation_type), false), 91 LoadFlagFromNavigationType(navigation_type), false),
104 CommitNavigationParams(entry.GetIsOverridingUserAgent(), 92 entry.ConstructCommitNavigationParams(navigation_start),
105 navigation_start), 93 entry.ConstructHistoryNavigationParams(controller), request_body, true,
106 history_params, request_body, true, &entry)); 94 &entry));
107 return navigation_request.Pass(); 95 return navigation_request.Pass();
108 } 96 }
109 97
110 // static 98 // static
111 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( 99 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
112 FrameTreeNode* frame_tree_node, 100 FrameTreeNode* frame_tree_node,
113 const CommonNavigationParams& common_params, 101 const CommonNavigationParams& common_params,
114 const BeginNavigationParams& begin_params, 102 const BeginNavigationParams& begin_params,
115 scoped_refptr<ResourceRequestBody> body, 103 scoped_refptr<ResourceRequestBody> body,
116 int current_history_list_offset, 104 int current_history_list_offset,
117 int current_history_list_length) { 105 int current_history_list_length) {
118 // TODO(clamy): Check if some PageState should be provided here. 106 // TODO(clamy): Check if some PageState should be provided here.
119 // TODO(clamy): See how we should handle override of the user agent when the 107 // TODO(clamy): See how we should handle override of the user agent when the
120 // navigation may start in a renderer and commit in another one. 108 // navigation may start in a renderer and commit in another one.
121 // TODO(clamy): See if the navigation start time should be measured in the 109 // TODO(clamy): See if the navigation start time should be measured in the
122 // renderer and sent to the browser instead of being measured here. 110 // renderer and sent to the browser instead of being measured here.
123 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( 111 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest(
124 frame_tree_node, common_params, begin_params, 112 frame_tree_node, common_params, begin_params, CommitNavigationParams(),
nasko 2015/03/11 13:59:00 This looks much nicer this way!
125 CommitNavigationParams(false, base::TimeTicks::Now()),
126 HistoryNavigationParams(PageState(), -1, -1, current_history_list_offset, 113 HistoryNavigationParams(PageState(), -1, -1, current_history_list_offset,
127 current_history_list_length, false), 114 current_history_list_length, false),
128 body, false, nullptr)); 115 body, false, nullptr));
129 return navigation_request.Pass(); 116 return navigation_request.Pass();
130 } 117 }
131 118
132 NavigationRequest::NavigationRequest( 119 NavigationRequest::NavigationRequest(
133 FrameTreeNode* frame_tree_node, 120 FrameTreeNode* frame_tree_node,
134 const CommonNavigationParams& common_params, 121 const CommonNavigationParams& common_params,
135 const BeginNavigationParams& begin_params, 122 const BeginNavigationParams& begin_params,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 // TODO(davidben): Network failures should display a network error page. 207 // TODO(davidben): Network failures should display a network error page.
221 NOTIMPLEMENTED() << " where net_error=" << net_error; 208 NOTIMPLEMENTED() << " where net_error=" << net_error;
222 } 209 }
223 210
224 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { 211 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) {
225 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, 212 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp,
226 common_params_.url); 213 common_params_.url);
227 } 214 }
228 215
229 } // namespace content 216 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698