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

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

Issue 577543002: Revert of Revert CL 117933003. Re-add resource speculative prefetching code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | Annotate | Revision Log
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"
20 #include "chrome/browser/prefetch/prefetch.h" 19 #include "chrome/browser/prefetch/prefetch.h"
21 #include "chrome/browser/prerender/prerender_manager.h" 20 #include "chrome/browser/prerender/prerender_manager.h"
22 #include "chrome/browser/prerender/prerender_manager_factory.h" 21 #include "chrome/browser/prerender/prerender_manager_factory.h"
23 #include "chrome/browser/prerender/prerender_pending_swap_throttle.h" 22 #include "chrome/browser/prerender/prerender_pending_swap_throttle.h"
24 #include "chrome/browser/prerender/prerender_resource_throttle.h" 23 #include "chrome/browser/prerender/prerender_resource_throttle.h"
25 #include "chrome/browser/prerender/prerender_tracker.h" 24 #include "chrome/browser/prerender/prerender_tracker.h"
26 #include "chrome/browser/prerender/prerender_util.h" 25 #include "chrome/browser/prerender/prerender_util.h"
27 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/browser/profiles/profile_io_data.h" 27 #include "chrome/browser/profiles/profile_io_data.h"
29 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h " 28 #include "chrome/browser/renderer_host/safe_browsing_resource_throttle_factory.h "
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 resource_type, 403 resource_type,
405 throttles); 404 throttles);
406 #if !defined(DISABLE_NACL) 405 #if !defined(DISABLE_NACL)
407 if (!is_prerendering) { 406 if (!is_prerendering) {
408 AppendComponentUpdaterThrottles(request, 407 AppendComponentUpdaterThrottles(request,
409 resource_context, 408 resource_context,
410 resource_type, 409 resource_type,
411 throttles); 410 throttles);
412 } 411 }
413 #endif 412 #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 }
419 } 413 }
420 414
421 void ChromeResourceDispatcherHostDelegate::DownloadStarting( 415 void ChromeResourceDispatcherHostDelegate::DownloadStarting(
422 net::URLRequest* request, 416 net::URLRequest* request,
423 content::ResourceContext* resource_context, 417 content::ResourceContext* resource_context,
424 int child_id, 418 int child_id,
425 int route_id, 419 int route_id,
426 int request_id, 420 int request_id,
427 bool is_content_initiated, 421 bool is_content_initiated,
428 bool must_download, 422 bool must_download,
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 GURL webstore_url(extension_urls::GetWebstoreLaunchURL()); 664 GURL webstore_url(extension_urls::GetWebstoreLaunchURL());
671 if (request->url().DomainIs(webstore_url.host().c_str())) { 665 if (request->url().DomainIs(webstore_url.host().c_str())) {
672 net::HttpResponseHeaders* response_headers = request->response_headers(); 666 net::HttpResponseHeaders* response_headers = request->response_headers();
673 if (!response_headers->HasHeaderValue("x-frame-options", "deny") && 667 if (!response_headers->HasHeaderValue("x-frame-options", "deny") &&
674 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) { 668 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) {
675 response_headers->RemoveHeader("x-frame-options"); 669 response_headers->RemoveHeader("x-frame-options");
676 response_headers->AddHeader("x-frame-options: sameorigin"); 670 response_headers->AddHeader("x-frame-options: sameorigin");
677 } 671 }
678 } 672 }
679 673
680 if (io_data->resource_prefetch_predictor_observer())
681 io_data->resource_prefetch_predictor_observer()->OnResponseStarted(request);
682
683 // Ignores x-frame-options for the chrome signin UI. 674 // Ignores x-frame-options for the chrome signin UI.
684 const std::string request_spec( 675 const std::string request_spec(
685 request->first_party_for_cookies().GetOrigin().spec()); 676 request->first_party_for_cookies().GetOrigin().spec());
686 #if defined(OS_CHROMEOS) 677 #if defined(OS_CHROMEOS)
687 if (request_spec == chrome::kChromeUIOobeURL || 678 if (request_spec == chrome::kChromeUIOobeURL ||
688 request_spec == chrome::kChromeUIChromeSigninURL) { 679 request_spec == chrome::kChromeUIChromeSigninURL) {
689 #else 680 #else
690 if (request_spec == chrome::kChromeUIChromeSigninURL) { 681 if (request_spec == chrome::kChromeUIChromeSigninURL) {
691 #endif 682 #endif
692 net::HttpResponseHeaders* response_headers = request->response_headers(); 683 net::HttpResponseHeaders* response_headers = request->response_headers();
(...skipping 23 matching lines...) Expand all
716 AppendChromeSyncGaiaHeader(request, resource_context); 707 AppendChromeSyncGaiaHeader(request, resource_context);
717 #endif 708 #endif
718 709
719 // In the Mirror world, Chrome should append a X-Chrome-Connected header to 710 // In the Mirror world, Chrome should append a X-Chrome-Connected header to
720 // all Gaia requests from a connected profile so Gaia could return a 204 711 // all Gaia requests from a connected profile so Gaia could return a 204
721 // response and let Chrome handle the action with native UI. The only 712 // response and let Chrome handle the action with native UI. The only
722 // exception is requests from gaia webview, since the native profile 713 // exception is requests from gaia webview, since the native profile
723 // management UI is built on top of it. 714 // management UI is built on top of it.
724 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data); 715 signin::AppendMirrorRequestHeaderIfPossible(request, redirect_url, io_data);
725 716
726 if (io_data->resource_prefetch_predictor_observer()) {
727 io_data->resource_prefetch_predictor_observer()->OnRequestRedirected(
728 redirect_url, request);
729 }
730
731 #if defined(ENABLE_CONFIGURATION_POLICY) 717 #if defined(ENABLE_CONFIGURATION_POLICY)
732 if (io_data->policy_header_helper()) 718 if (io_data->policy_header_helper())
733 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request); 719 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request);
734 #endif 720 #endif
735 } 721 }
736 722
737 // Notification that a request has completed. 723 // Notification that a request has completed.
738 void ChromeResourceDispatcherHostDelegate::RequestComplete( 724 void ChromeResourceDispatcherHostDelegate::RequestComplete(
739 net::URLRequest* url_request) { 725 net::URLRequest* url_request) {
740 // Jump on the UI thread and inform the prerender about the bytes. 726 // Jump on the UI thread and inform the prerender about the bytes.
741 const ResourceRequestInfo* info = 727 const ResourceRequestInfo* info =
742 ResourceRequestInfo::ForRequest(url_request); 728 ResourceRequestInfo::ForRequest(url_request);
743 if (url_request && !url_request->was_cached()) { 729 if (url_request && !url_request->was_cached()) {
744 BrowserThread::PostTask(BrowserThread::UI, 730 BrowserThread::PostTask(BrowserThread::UI,
745 FROM_HERE, 731 FROM_HERE,
746 base::Bind(&UpdatePrerenderNetworkBytesCallback, 732 base::Bind(&UpdatePrerenderNetworkBytesCallback,
747 info->GetChildID(), 733 info->GetChildID(),
748 info->GetRouteID(), 734 info->GetRouteID(),
749 url_request->GetTotalReceivedBytes())); 735 url_request->GetTotalReceivedBytes()));
750 } 736 }
751 } 737 }
752 738
753 // static 739 // static
754 void ChromeResourceDispatcherHostDelegate:: 740 void ChromeResourceDispatcherHostDelegate::
755 SetExternalProtocolHandlerDelegateForTesting( 741 SetExternalProtocolHandlerDelegateForTesting(
756 ExternalProtocolHandler::Delegate* delegate) { 742 ExternalProtocolHandler::Delegate* delegate) {
757 g_external_protocol_handler_delegate = delegate; 743 g_external_protocol_handler_delegate = delegate;
758 } 744 }
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