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

Side by Side Diff: chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate.cc

Issue 576313002: Re-add resource speculative prefetching code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase to fix patch failure Created 6 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h" 5 #include "chrome/browser/renderer_host/chrome_resource_dispatcher_host_delegate. h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
11 #include "base/guid.h" 11 #include "base/guid.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "chrome/browser/browser_process.h" 13 #include "chrome/browser/browser_process.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/component_updater/component_updater_resource_throttle.h " 15 #include "chrome/browser/component_updater/component_updater_resource_throttle.h "
16 #include "chrome/browser/content_settings/host_content_settings_map.h" 16 #include "chrome/browser/content_settings/host_content_settings_map.h"
17 #include "chrome/browser/download/download_request_limiter.h" 17 #include "chrome/browser/download/download_request_limiter.h"
18 #include "chrome/browser/download/download_resource_throttle.h" 18 #include "chrome/browser/download/download_resource_throttle.h"
19 #include "chrome/browser/net/resource_prefetch_predictor_observer.h"
19 #include "chrome/browser/prefetch/prefetch.h" 20 #include "chrome/browser/prefetch/prefetch.h"
20 #include "chrome/browser/prerender/prerender_manager.h" 21 #include "chrome/browser/prerender/prerender_manager.h"
21 #include "chrome/browser/prerender/prerender_manager_factory.h" 22 #include "chrome/browser/prerender/prerender_manager_factory.h"
22 #include "chrome/browser/prerender/prerender_pending_swap_throttle.h" 23 #include "chrome/browser/prerender/prerender_pending_swap_throttle.h"
23 #include "chrome/browser/prerender/prerender_resource_throttle.h" 24 #include "chrome/browser/prerender/prerender_resource_throttle.h"
24 #include "chrome/browser/prerender/prerender_tracker.h" 25 #include "chrome/browser/prerender/prerender_tracker.h"
25 #include "chrome/browser/prerender/prerender_util.h" 26 #include "chrome/browser/prerender/prerender_util.h"
26 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/profiles/profile_io_data.h" 28 #include "chrome/browser/profiles/profile_io_data.h"
28 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h " 29 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h "
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 resource_type, 404 resource_type,
404 throttles); 405 throttles);
405 #if !defined(DISABLE_NACL) 406 #if !defined(DISABLE_NACL)
406 if (!is_prerendering) { 407 if (!is_prerendering) {
407 AppendComponentUpdaterThrottles(request, 408 AppendComponentUpdaterThrottles(request,
408 resource_context, 409 resource_context,
409 resource_type, 410 resource_type,
410 throttles); 411 throttles);
411 } 412 }
412 #endif 413 #endif
414
415 if (io_data->resource_prefetch_predictor_observer()) {
416 io_data->resource_prefetch_predictor_observer()->OnRequestStarted(
417 request, resource_type, info->GetChildID(), info->GetRenderFrameID());
418 }
413 } 419 }
414 420
415 void ChromeResourceDispatcherHostDelegate::DownloadStarting( 421 void ChromeResourceDispatcherHostDelegate::DownloadStarting(
416 net::URLRequest* request, 422 net::URLRequest* request,
417 content::ResourceContext* resource_context, 423 content::ResourceContext* resource_context,
418 int child_id, 424 int child_id,
419 int route_id, 425 int route_id,
420 int request_id, 426 int request_id,
421 bool is_content_initiated, 427 bool is_content_initiated,
422 bool must_download, 428 bool must_download,
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 if (request->url().DomainIs(webstore_url.host().c_str())) { 672 if (request->url().DomainIs(webstore_url.host().c_str())) {
667 net::HttpResponseHeaders* response_headers = request->response_headers(); 673 net::HttpResponseHeaders* response_headers = request->response_headers();
668 if (!response_headers->HasHeaderValue("x-frame-options", "deny") && 674 if (!response_headers->HasHeaderValue("x-frame-options", "deny") &&
669 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) { 675 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) {
670 response_headers->RemoveHeader("x-frame-options"); 676 response_headers->RemoveHeader("x-frame-options");
671 response_headers->AddHeader("x-frame-options: sameorigin"); 677 response_headers->AddHeader("x-frame-options: sameorigin");
672 } 678 }
673 } 679 }
674 #endif 680 #endif
675 681
682 if (io_data->resource_prefetch_predictor_observer())
683 io_data->resource_prefetch_predictor_observer()->OnResponseStarted(request);
684
676 // Ignores x-frame-options for the chrome signin UI. 685 // Ignores x-frame-options for the chrome signin UI.
677 const std::string request_spec( 686 const std::string request_spec(
678 request->first_party_for_cookies().GetOrigin().spec()); 687 request->first_party_for_cookies().GetOrigin().spec());
679 #if defined(OS_CHROMEOS) 688 #if defined(OS_CHROMEOS)
680 if (request_spec == chrome::kChromeUIOobeURL || 689 if (request_spec == chrome::kChromeUIOobeURL ||
681 request_spec == chrome::kChromeUIChromeSigninURL) { 690 request_spec == chrome::kChromeUIChromeSigninURL) {
682 #else 691 #else
683 if (request_spec == chrome::kChromeUIChromeSigninURL) { 692 if (request_spec == chrome::kChromeUIChromeSigninURL) {
684 #endif 693 #endif
685 net::HttpResponseHeaders* response_headers = request->response_headers(); 694 net::HttpResponseHeaders* response_headers = request->response_headers();
(...skipping 23 matching lines...) Expand all
709 AppendChromeSyncGaiaHeader(request, resource_context); 718 AppendChromeSyncGaiaHeader(request, resource_context);
710 #endif 719 #endif
711 720
712 // In the Mirror world, Chrome should append a X-Chrome-Connected header to 721 // In the Mirror world, Chrome should append a X-Chrome-Connected header to
713 // all Gaia requests from a connected profile so Gaia could return a 204 722 // all Gaia requests from a connected profile so Gaia could return a 204
714 // response and let Chrome handle the action with native UI. The only 723 // response and let Chrome handle the action with native UI. The only
715 // exception is requests from gaia webview, since the native profile 724 // exception is requests from gaia webview, since the native profile
716 // management UI is built on top of it. 725 // management UI is built on top of it.
717 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data); 726 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data);
718 727
728 if (io_data->resource_prefetch_predictor_observer()) {
729 io_data->resource_prefetch_predictor_observer()->OnRequestRedirected(
730 redirect_url, request);
731 }
732
719 #if defined(ENABLE_CONFIGURATION_POLICY) 733 #if defined(ENABLE_CONFIGURATION_POLICY)
720 if (io_data->policy_header_helper()) 734 if (io_data->policy_header_helper())
721 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request); 735 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request);
722 #endif 736 #endif
723 } 737 }
724 738
725 // Notification that a request has completed. 739 // Notification that a request has completed.
726 void ChromeResourceDispatcherHostDelegate::RequestComplete( 740 void ChromeResourceDispatcherHostDelegate::RequestComplete(
727 net::URLRequest* url_request) { 741 net::URLRequest* url_request) {
728 // Jump on the UI thread and inform the prerender about the bytes. 742 // Jump on the UI thread and inform the prerender about the bytes.
729 const ResourceRequestInfo* info = 743 const ResourceRequestInfo* info =
730 ResourceRequestInfo::ForRequest(url_request); 744 ResourceRequestInfo::ForRequest(url_request);
731 if (url_request && !url_request->was_cached()) { 745 if (url_request && !url_request->was_cached()) {
732 BrowserThread::PostTask(BrowserThread::UI, 746 BrowserThread::PostTask(BrowserThread::UI,
733 FROM_HERE, 747 FROM_HERE,
734 base::Bind(&UpdatePrerenderNetworkBytesCallback, 748 base::Bind(&UpdatePrerenderNetworkBytesCallback,
735 info->GetChildID(), 749 info->GetChildID(),
736 info->GetRouteID(), 750 info->GetRouteID(),
737 url_request->GetTotalReceivedBytes())); 751 url_request->GetTotalReceivedBytes()));
738 } 752 }
739 } 753 }
740 754
741 // static 755 // static
742 void ChromeResourceDispatcherHostDelegate:: 756 void ChromeResourceDispatcherHostDelegate::
743 SetExternalProtocolHandlerDelegateForTesting( 757 SetExternalProtocolHandlerDelegateForTesting(
744 ExternalProtocolHandler::Delegate* delegate) { 758 ExternalProtocolHandler::Delegate* delegate) {
745 g_external_protocol_handler_delegate = delegate; 759 g_external_protocol_handler_delegate = delegate;
746 } 760 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_io_data.cc ('k') | chrome/browser/resources/predictors/predictors.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698