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

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

Issue 2501343003: PlzNavigate: AppCache support. (Closed)
Patch Set: Maintain a refcounted instance of ChromeAppCacheService in the AppCacheNavigationHandleCore instanc… Created 4 years 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 <utility> 7 #include <utility>
8 8
9 #include "content/browser/appcache/appcache_navigation_handle.h"
10 #include "content/browser/appcache/chrome_appcache_service.h"
9 #include "content/browser/child_process_security_policy_impl.h" 11 #include "content/browser/child_process_security_policy_impl.h"
10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" 12 #include "content/browser/devtools/render_frame_devtools_agent_host.h"
11 #include "content/browser/frame_host/frame_tree.h" 13 #include "content/browser/frame_host/frame_tree.h"
12 #include "content/browser/frame_host/frame_tree_node.h" 14 #include "content/browser/frame_host/frame_tree_node.h"
13 #include "content/browser/frame_host/navigation_controller_impl.h" 15 #include "content/browser/frame_host/navigation_controller_impl.h"
14 #include "content/browser/frame_host/navigation_handle_impl.h" 16 #include "content/browser/frame_host/navigation_handle_impl.h"
15 #include "content/browser/frame_host/navigation_request_info.h" 17 #include "content/browser/frame_host/navigation_request_info.h"
16 #include "content/browser/frame_host/navigator.h" 18 #include "content/browser/frame_host/navigator.h"
17 #include "content/browser/frame_host/navigator_impl.h" 19 #include "content/browser/frame_host/navigator_impl.h"
18 #include "content/browser/loader/navigation_url_loader.h" 20 #include "content/browser/loader/navigation_url_loader.h"
19 #include "content/browser/renderer_host/render_process_host_impl.h" 21 #include "content/browser/renderer_host/render_process_host_impl.h"
20 #include "content/browser/service_worker/service_worker_context_wrapper.h" 22 #include "content/browser/service_worker/service_worker_context_wrapper.h"
21 #include "content/browser/service_worker/service_worker_navigation_handle.h" 23 #include "content/browser/service_worker/service_worker_navigation_handle.h"
22 #include "content/browser/site_instance_impl.h" 24 #include "content/browser/site_instance_impl.h"
23 #include "content/common/resource_request_body_impl.h" 25 #include "content/common/resource_request_body_impl.h"
24 #include "content/public/browser/browser_context.h" 26 #include "content/public/browser/browser_context.h"
25 #include "content/public/browser/content_browser_client.h" 27 #include "content/public/browser/content_browser_client.h"
26 #include "content/public/browser/navigation_controller.h" 28 #include "content/public/browser/navigation_controller.h"
27 #include "content/public/browser/navigation_data.h" 29 #include "content/public/browser/navigation_data.h"
28 #include "content/public/browser/navigation_ui_data.h" 30 #include "content/public/browser/navigation_ui_data.h"
29 #include "content/public/browser/storage_partition.h" 31 #include "content/public/browser/storage_partition.h"
30 #include "content/public/browser/stream_handle.h" 32 #include "content/public/browser/stream_handle.h"
33 #include "content/public/common/appcache_info.h"
31 #include "content/public/common/content_client.h" 34 #include "content/public/common/content_client.h"
32 #include "content/public/common/request_context_type.h" 35 #include "content/public/common/request_context_type.h"
33 #include "content/public/common/resource_response.h" 36 #include "content/public/common/resource_response.h"
34 #include "content/public/common/url_constants.h" 37 #include "content/public/common/url_constants.h"
35 #include "net/base/load_flags.h" 38 #include "net/base/load_flags.h"
36 #include "net/base/url_util.h" 39 #include "net/base/url_util.h"
37 #include "net/http/http_request_headers.h" 40 #include "net/http/http_request_headers.h"
38 #include "net/url_request/redirect_info.h" 41 #include "net/url_request/redirect_info.h"
39 #include "third_party/WebKit/public/web/WebSandboxFlags.h" 42 #include "third_party/WebKit/public/web/WebSandboxFlags.h"
40 43
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 navigation_handle_->service_worker_handle() && 399 navigation_handle_->service_worker_handle() &&
397 navigation_handle_->service_worker_handle() 400 navigation_handle_->service_worker_handle()
398 ->service_worker_provider_host_id() != 401 ->service_worker_provider_host_id() !=
399 kInvalidServiceWorkerProviderId; 402 kInvalidServiceWorkerProviderId;
400 request_params_.service_worker_provider_id = 403 request_params_.service_worker_provider_id =
401 did_create_service_worker_host 404 did_create_service_worker_host
402 ? navigation_handle_->service_worker_handle() 405 ? navigation_handle_->service_worker_handle()
403 ->service_worker_provider_host_id() 406 ->service_worker_provider_host_id()
404 : kInvalidServiceWorkerProviderId; 407 : kInvalidServiceWorkerProviderId;
405 408
409 request_params_.appcache_host_id =
410 navigation_handle_->appcache_handle()
411 ? navigation_handle_->appcache_handle()->appcache_host_id()
412 : kAppCacheNoHostId;
413
406 // Update the lofi state of the request. 414 // Update the lofi state of the request.
407 if (response->head.is_using_lofi) 415 if (response->head.is_using_lofi)
408 common_params_.lofi_state = LOFI_ON; 416 common_params_.lofi_state = LOFI_ON;
409 else 417 else
410 common_params_.lofi_state = LOFI_OFF; 418 common_params_.lofi_state = LOFI_OFF;
411 419
412 // Select an appropriate renderer to commit the navigation. 420 // Select an appropriate renderer to commit the navigation.
413 RenderFrameHostImpl* render_frame_host = 421 RenderFrameHostImpl* render_frame_host =
414 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); 422 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this);
415 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, 423 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 (frame_tree_node_->pending_sandbox_flags() & 511 (frame_tree_node_->pending_sandbox_flags() &
504 blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin; 512 blink::WebSandboxFlags::Origin) != blink::WebSandboxFlags::Origin;
505 request_params_.should_create_service_worker = can_create_service_worker; 513 request_params_.should_create_service_worker = can_create_service_worker;
506 if (can_create_service_worker) { 514 if (can_create_service_worker) {
507 ServiceWorkerContextWrapper* service_worker_context = 515 ServiceWorkerContextWrapper* service_worker_context =
508 static_cast<ServiceWorkerContextWrapper*>( 516 static_cast<ServiceWorkerContextWrapper*>(
509 partition->GetServiceWorkerContext()); 517 partition->GetServiceWorkerContext());
510 navigation_handle_->InitServiceWorkerHandle(service_worker_context); 518 navigation_handle_->InitServiceWorkerHandle(service_worker_context);
511 } 519 }
512 520
521 if (common_params_.url.scheme() == url::kHttpScheme ||
clamy 2016/11/25 13:32:24 I'd prefer you use GURL::SchemeIsHTTPOrHTTPS().
ananta 2016/11/28 21:36:53 Done.
522 common_params_.url.scheme() == url::kHttpsScheme) {
523 navigation_handle_->InitAppCacheHandle(
524 static_cast<ChromeAppCacheService*>(partition->GetAppCacheService()));
525 }
526
513 // Mark the fetch_start (Navigation Timing API). 527 // Mark the fetch_start (Navigation Timing API).
514 request_params_.navigation_timing.fetch_start = base::TimeTicks::Now(); 528 request_params_.navigation_timing.fetch_start = base::TimeTicks::Now();
515 529
516 // TODO(mkwst): This is incorrect. It ought to use the definition from 530 // TODO(mkwst): This is incorrect. It ought to use the definition from
517 // 'Document::firstPartyForCookies()' in Blink, which walks the ancestor tree 531 // 'Document::firstPartyForCookies()' in Blink, which walks the ancestor tree
518 // and verifies that all origins are PSL-matches (and special-cases extension 532 // and verifies that all origins are PSL-matches (and special-cases extension
519 // URLs). 533 // URLs).
520 const GURL& first_party_for_cookies = 534 const GURL& first_party_for_cookies =
521 frame_tree_node_->IsMainFrame() 535 frame_tree_node_->IsMainFrame()
522 ? common_params_.url 536 ? common_params_.url
(...skipping 15 matching lines...) Expand all
538 552
539 loader_ = NavigationURLLoader::Create( 553 loader_ = NavigationURLLoader::Create(
540 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), 554 frame_tree_node_->navigator()->GetController()->GetBrowserContext(),
541 base::MakeUnique<NavigationRequestInfo>( 555 base::MakeUnique<NavigationRequestInfo>(
542 common_params_, begin_params_, first_party_for_cookies, 556 common_params_, begin_params_, first_party_for_cookies,
543 frame_tree_node_->current_origin(), frame_tree_node_->IsMainFrame(), 557 frame_tree_node_->current_origin(), frame_tree_node_->IsMainFrame(),
544 parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()), 558 parent_is_main_frame, IsSecureFrame(frame_tree_node_->parent()),
545 frame_tree_node_->frame_tree_node_id(), is_for_guests_only, 559 frame_tree_node_->frame_tree_node_id(), is_for_guests_only,
546 report_raw_headers), 560 report_raw_headers),
547 std::move(navigation_ui_data), 561 std::move(navigation_ui_data),
548 navigation_handle_->service_worker_handle(), this); 562 navigation_handle_->service_worker_handle(),
563 navigation_handle_->appcache_handle(), this);
549 } 564 }
550 565
551 void NavigationRequest::OnRedirectChecksComplete( 566 void NavigationRequest::OnRedirectChecksComplete(
552 NavigationThrottle::ThrottleCheckResult result) { 567 NavigationThrottle::ThrottleCheckResult result) {
553 CHECK(result != NavigationThrottle::DEFER); 568 CHECK(result != NavigationThrottle::DEFER);
554 569
555 // Abort the request if needed. This will destroy the NavigationRequest. 570 // Abort the request if needed. This will destroy the NavigationRequest.
556 if (result == NavigationThrottle::CANCEL_AND_IGNORE || 571 if (result == NavigationThrottle::CANCEL_AND_IGNORE ||
557 result == NavigationThrottle::CANCEL) { 572 result == NavigationThrottle::CANCEL) {
558 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE. 573 // TODO(clamy): distinguish between CANCEL and CANCEL_AND_IGNORE.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); 616 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture);
602 617
603 render_frame_host->CommitNavigation(response_.get(), std::move(body_), 618 render_frame_host->CommitNavigation(response_.get(), std::move(body_),
604 common_params_, request_params_, 619 common_params_, request_params_,
605 is_view_source_); 620 is_view_source_);
606 621
607 frame_tree_node_->ResetNavigationRequest(true); 622 frame_tree_node_->ResetNavigationRequest(true);
608 } 623 }
609 624
610 } // namespace content 625 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698