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

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

Issue 1399363004: PlzNavigate: Make ServiceWorker work with PlzNavigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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_navigation_handle.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"
24 #include "third_party/WebKit/public/web/WebSandboxFlags.h"
23 25
24 namespace content { 26 namespace content {
25 27
26 namespace { 28 namespace {
27 29
28 // Returns the net load flags to use based on the navigation type. 30 // Returns the net load flags to use based on the navigation type.
29 // TODO(clamy): unify the code with what is happening on the renderer side. 31 // TODO(clamy): unify the code with what is happening on the renderer side.
30 int LoadFlagFromNavigationType(FrameMsg_Navigate_Type::Value navigation_type) { 32 int LoadFlagFromNavigationType(FrameMsg_Navigate_Type::Value navigation_type) {
31 int load_flags = net::LOAD_NORMAL; 33 int load_flags = net::LOAD_NORMAL;
32 switch (navigation_type) { 34 switch (navigation_type) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 begin_params_.has_user_gesture, common_params_.transition, false); 206 begin_params_.has_user_gesture, common_params_.transition, false);
205 207
206 // Abort the request if needed. This will destroy the NavigationRequest. 208 // Abort the request if needed. This will destroy the NavigationRequest.
207 if (result == NavigationThrottle::CANCEL_AND_IGNORE) { 209 if (result == NavigationThrottle::CANCEL_AND_IGNORE) {
208 frame_tree_node_->ResetNavigationRequest(false); 210 frame_tree_node_->ResetNavigationRequest(false);
209 return false; 211 return false;
210 } 212 }
211 213
212 loader_ = NavigationURLLoader::Create( 214 loader_ = NavigationURLLoader::Create(
213 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), 215 frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
214 info_.Pass(), this); 216 info_.Pass(), navigation_handle_->service_worker_handle(), this);
215 return true; 217 return true;
216 } 218 }
217 219
218 // There is no need to make a network request for this navigation, so commit 220 // There is no need to make a network request for this navigation, so commit
219 // it immediately. 221 // it immediately.
220 state_ = RESPONSE_STARTED; 222 state_ = RESPONSE_STARTED;
221 frame_tree_node_->navigator()->CommitNavigation( 223 frame_tree_node_->navigator()->CommitNavigation(
222 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>()); 224 frame_tree_node_, nullptr, scoped_ptr<StreamHandle>());
223 return false; 225 return false;
224 226
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 loader_->FollowRedirect(); 264 loader_->FollowRedirect();
263 265
264 navigation_handle_->DidRedirectNavigation(redirect_info.new_url); 266 navigation_handle_->DidRedirectNavigation(redirect_info.new_url);
265 } 267 }
266 268
267 void NavigationRequest::OnResponseStarted( 269 void NavigationRequest::OnResponseStarted(
268 const scoped_refptr<ResourceResponse>& response, 270 const scoped_refptr<ResourceResponse>& response,
269 scoped_ptr<StreamHandle> body) { 271 scoped_ptr<StreamHandle> body) {
270 DCHECK(state_ == STARTED); 272 DCHECK(state_ == STARTED);
271 state_ = RESPONSE_STARTED; 273 state_ = RESPONSE_STARTED;
274
275 // Update the service worker params of the request params.
276 request_params_.should_create_service_worker =
277 (frame_tree_node_->current_replication_state().sandbox_flags &
michaeln 2015/10/20 22:12:53 i'm wondering about potential errors stemming from
nasko 2015/10/20 23:07:42 There is important behavior here. Sandbox flags up
clamy 2015/10/21 16:33:48 So should I change to checking against effective_s
nasko 2015/10/21 22:28:08 I can't say for certain which one should be used,
kinuko 2015/10/22 12:16:02 In the latter case the first main resource load ma
278 blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin;
279 if (navigation_handle_->service_worker_handle()) {
280 request_params_.service_worker_provider_id =
281 navigation_handle_->service_worker_handle()
282 ->service_worker_provider_host_id();
283 }
284
272 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_, 285 frame_tree_node_->navigator()->CommitNavigation(frame_tree_node_,
273 response.get(), body.Pass()); 286 response.get(), body.Pass());
274 } 287 }
275 288
276 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache, 289 void NavigationRequest::OnRequestFailed(bool has_stale_copy_in_cache,
277 int net_error) { 290 int net_error) {
278 DCHECK(state_ == STARTED); 291 DCHECK(state_ == STARTED);
279 state_ = FAILED; 292 state_ = FAILED;
280 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error)); 293 navigation_handle_->set_net_error_code(static_cast<net::Error>(net_error));
281 frame_tree_node_->navigator()->FailedNavigation( 294 frame_tree_node_->navigator()->FailedNavigation(
282 frame_tree_node_, has_stale_copy_in_cache, net_error); 295 frame_tree_node_, has_stale_copy_in_cache, net_error);
283 } 296 }
284 297
285 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) { 298 void NavigationRequest::OnRequestStarted(base::TimeTicks timestamp) {
286 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp, 299 frame_tree_node_->navigator()->LogResourceRequestTime(timestamp,
287 common_params_.url); 300 common_params_.url);
288 } 301 }
289 302
290 } // namespace content 303 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698