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

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

Issue 1294243004: PlzNavigate: Make ServiceWorker work with PlzNavigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 5 years, 2 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_controller_impl.h"
10 #include "content/browser/frame_host/navigation_handle_impl.h" 10 #include "content/browser/frame_host/navigation_handle_impl.h"
11 #include "content/browser/frame_host/navigation_request_info.h" 11 #include "content/browser/frame_host/navigation_request_info.h"
12 #include "content/browser/frame_host/navigator.h" 12 #include "content/browser/frame_host/navigator.h"
13 #include "content/browser/loader/navigation_url_loader.h" 13 #include "content/browser/loader/navigation_url_loader.h"
14 #include "content/browser/service_worker/service_worker_provider_host.h"
14 #include "content/browser/site_instance_impl.h" 15 #include "content/browser/site_instance_impl.h"
15 #include "content/common/resource_request_body.h" 16 #include "content/common/resource_request_body.h"
16 #include "content/public/browser/navigation_controller.h" 17 #include "content/public/browser/navigation_controller.h"
17 #include "content/public/browser/navigation_throttle.h" 18 #include "content/public/browser/navigation_throttle.h"
18 #include "content/public/browser/stream_handle.h" 19 #include "content/public/browser/stream_handle.h"
19 #include "content/public/common/content_client.h" 20 #include "content/public/common/content_client.h"
20 #include "net/base/load_flags.h" 21 #include "net/base/load_flags.h"
21 #include "net/http/http_request_headers.h" 22 #include "net/http/http_request_headers.h"
22 #include "net/url_request/redirect_info.h" 23 #include "net/url_request/redirect_info.h"
23 24
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest( 88 scoped_ptr<NavigationRequest> navigation_request(new NavigationRequest(
88 frame_tree_node, 89 frame_tree_node,
89 entry.ConstructCommonNavigationParams(dest_url, dest_referrer, 90 entry.ConstructCommonNavigationParams(
90 frame_entry, navigation_type), 91 dest_url, dest_referrer, frame_entry, navigation_type),
91 BeginNavigationParams(method, headers.ToString(), 92 BeginNavigationParams(method,
92 LoadFlagFromNavigationType(navigation_type), false), 93 headers.ToString(),
94 LoadFlagFromNavigationType(navigation_type),
95 false, // has_user_gestures
96 false, // skip_service_worker
97 REQUEST_CONTEXT_TYPE_HYPERLINK),
93 entry.ConstructRequestNavigationParams( 98 entry.ConstructRequestNavigationParams(
94 frame_entry, navigation_start, is_same_document_history_load, 99 frame_entry, navigation_start, is_same_document_history_load,
95 frame_tree_node->has_committed_real_load(), 100 frame_tree_node->has_committed_real_load(),
96 controller->GetPendingEntryIndex() == -1, 101 controller->GetPendingEntryIndex() == -1,
97 controller->GetIndexOfEntry(&entry), 102 controller->GetIndexOfEntry(&entry),
98 controller->GetLastCommittedEntryIndex(), 103 controller->GetLastCommittedEntryIndex(),
99 controller->GetEntryCount()), 104 controller->GetEntryCount(),
105 ServiceWorkerProviderHost::GetNextNavigationProviderId()),
100 request_body, true, &frame_entry, &entry)); 106 request_body, true, &frame_entry, &entry));
101 return navigation_request.Pass(); 107 return navigation_request.Pass();
102 } 108 }
103 109
104 // static 110 // static
105 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( 111 scoped_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated(
106 FrameTreeNode* frame_tree_node, 112 FrameTreeNode* frame_tree_node,
107 const CommonNavigationParams& common_params, 113 const CommonNavigationParams& common_params,
108 const BeginNavigationParams& begin_params, 114 const BeginNavigationParams& begin_params,
109 scoped_refptr<ResourceRequestBody> body, 115 scoped_refptr<ResourceRequestBody> body,
110 int current_history_list_offset, 116 int current_history_list_offset,
111 int current_history_list_length) { 117 int current_history_list_length) {
112 // TODO(clamy): Check if some PageState should be provided here. 118 // TODO(clamy): Check if some PageState should be provided here.
113 // TODO(clamy): See how we should handle override of the user agent when the 119 // TODO(clamy): See how we should handle override of the user agent when the
114 // navigation may start in a renderer and commit in another one. 120 // navigation may start in a renderer and commit in another one.
115 // TODO(clamy): See if the navigation start time should be measured in the 121 // TODO(clamy): See if the navigation start time should be measured in the
116 // renderer and sent to the browser instead of being measured here. 122 // renderer and sent to the browser instead of being measured here.
117 // TODO(clamy): The pending history list offset should be properly set. 123 // TODO(clamy): The pending history list offset should be properly set.
118 // TODO(clamy): Set has_committed_real_load. 124 // TODO(clamy): Set has_committed_real_load.
119 RequestNavigationParams request_params; 125 RequestNavigationParams request_params;
clamy 2015/10/01 12:41:27 We should switch to instantiating the RequestParam
Fabrice (no longer in Chrome) 2015/10/01 18:29:55 Done.
120 request_params.current_history_list_offset = current_history_list_offset; 126 request_params.current_history_list_offset = current_history_list_offset;
121 request_params.current_history_list_length = current_history_list_length; 127 request_params.current_history_list_length = current_history_list_length;
128 request_params.service_worker_provider_id =
129 ServiceWorkerProviderHost::GetNextNavigationProviderId();
clamy 2015/10/01 12:41:27 It seems very weird to me that we should be using
Fabrice (no longer in Chrome) 2015/10/01 18:29:55 Since it is only called here, I moved it in the an
122 scoped_ptr<NavigationRequest> navigation_request( 130 scoped_ptr<NavigationRequest> navigation_request(
123 new NavigationRequest(frame_tree_node, common_params, begin_params, 131 new NavigationRequest(frame_tree_node, common_params, begin_params,
124 request_params, body, false, nullptr, nullptr)); 132 request_params, body, false, nullptr, nullptr));
125 return navigation_request.Pass(); 133 return navigation_request.Pass();
126 } 134 }
127 135
128 NavigationRequest::NavigationRequest( 136 NavigationRequest::NavigationRequest(
129 FrameTreeNode* frame_tree_node, 137 FrameTreeNode* frame_tree_node,
130 const CommonNavigationParams& common_params, 138 const CommonNavigationParams& common_params,
131 const BeginNavigationParams& begin_params, 139 const BeginNavigationParams& begin_params,
(...skipping 27 matching lines...) Expand all
159 frame_tree_node->current_frame_host()->GetSiteInstance(); 167 frame_tree_node->current_frame_host()->GetSiteInstance();
160 } 168 }
161 169
162 const GURL& first_party_for_cookies = 170 const GURL& first_party_for_cookies =
163 frame_tree_node->IsMainFrame() 171 frame_tree_node->IsMainFrame()
164 ? common_params.url 172 ? common_params.url
165 : frame_tree_node->frame_tree()->root()->current_url(); 173 : frame_tree_node->frame_tree()->root()->current_url();
166 bool parent_is_main_frame = !frame_tree_node->parent() ? 174 bool parent_is_main_frame = !frame_tree_node->parent() ?
167 false : frame_tree_node->parent()->IsMainFrame(); 175 false : frame_tree_node->parent()->IsMainFrame();
168 info_.reset(new NavigationRequestInfo( 176 info_.reset(new NavigationRequestInfo(
169 common_params, begin_params, first_party_for_cookies, 177 common_params, begin_params, request_params, first_party_for_cookies,
170 frame_tree_node->IsMainFrame(), parent_is_main_frame, 178 frame_tree_node->IsMainFrame(), parent_is_main_frame,
171 frame_tree_node->frame_tree_node_id(), body)); 179 frame_tree_node->frame_tree_node_id(), body));
172 } 180 }
173 181
174 NavigationRequest::~NavigationRequest() { 182 NavigationRequest::~NavigationRequest() {
175 } 183 }
176 184
177 bool NavigationRequest::BeginNavigation() { 185 bool NavigationRequest::BeginNavigation() {
178 DCHECK(!loader_); 186 DCHECK(!loader_);
179 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE); 187 DCHECK(state_ == NOT_STARTED || state_ == WAITING_FOR_RENDERER_RESPONSE);
(...skipping 26 matching lines...) Expand all
206 frame_tree_node_->navigator()->CommitNavigation( 214 frame_tree_node_->navigator()->CommitNavigation(
207 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>()); 215 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>());
208 return false; 216 return false;
209 217
210 // TODO(davidben): Fire (and add as necessary) observer methods such as 218 // TODO(davidben): Fire (and add as necessary) observer methods such as
211 // DidStartProvisionalLoadForFrame for the navigation. 219 // DidStartProvisionalLoadForFrame for the navigation.
212 } 220 }
213 221
214 void NavigationRequest::CreateNavigationHandle(NavigatorDelegate* delegate) { 222 void NavigationRequest::CreateNavigationHandle(NavigatorDelegate* delegate) {
215 navigation_handle_ = NavigationHandleImpl::Create( 223 navigation_handle_ = NavigationHandleImpl::Create(
216 common_params_.url, frame_tree_node_->IsMainFrame(), delegate); 224 common_params_.url, frame_tree_node_->IsMainFrame(), delegate,
225 request_params_.service_worker_provider_id);
217 } 226 }
218 227
219 void NavigationRequest::TransferNavigationHandleOwnership( 228 void NavigationRequest::TransferNavigationHandleOwnership(
220 RenderFrameHostImpl* render_frame_host) { 229 RenderFrameHostImpl* render_frame_host) {
221 render_frame_host->SetNavigationHandle(navigation_handle_.Pass()); 230 render_frame_host->SetNavigationHandle(navigation_handle_.Pass());
222 render_frame_host->navigation_handle()->ReadyToCommitNavigation( 231 render_frame_host->navigation_handle()->ReadyToCommitNavigation(
223 render_frame_host); 232 render_frame_host);
224 } 233 }
225 234
226 void NavigationRequest::OnRequestRedirected( 235 void NavigationRequest::OnRequestRedirected(
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 frame_tree_node_->navigator()->FailedNavigation( 275 frame_tree_node_->navigator()->FailedNavigation(
267 frame_tree_node_, has_stale_copy_in_cache, net_error); 276 frame_tree_node_, has_stale_copy_in_cache, net_error);
268 } 277 }
269 278
270 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { 279 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) {
271 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, 280 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp,
272 common_params_.url); 281 common_params_.url);
273 } 282 }
274 283
275 } // namespace content 284 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698