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

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

Issue 2887133003: predictors: Refactor resource_prefetch_predictor triggering. (Closed)
Patch Set: . Created 3 years, 6 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
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/net/loading_predictor_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/loader/chrome_resource_dispatcher_host_delegate.h" 5 #include "chrome/browser/loader/chrome_resource_dispatcher_host_delegate.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/base64.h" 12 #include "base/base64.h"
13 #include "base/guid.h" 13 #include "base/guid.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/metrics/field_trial.h" 16 #include "base/metrics/field_trial.h"
17 #include "base/metrics/histogram_macros.h" 17 #include "base/metrics/histogram_macros.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chrome_notification_types.h" 21 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/component_updater/component_updater_resource_throttle.h " 22 #include "chrome/browser/component_updater/component_updater_resource_throttle.h "
23 #include "chrome/browser/download/download_request_limiter.h" 23 #include "chrome/browser/download/download_request_limiter.h"
24 #include "chrome/browser/download/download_resource_throttle.h" 24 #include "chrome/browser/download/download_resource_throttle.h"
25 #include "chrome/browser/loader/chrome_navigation_data.h" 25 #include "chrome/browser/loader/chrome_navigation_data.h"
26 #include "chrome/browser/loader/predictor_resource_throttle.h" 26 #include "chrome/browser/loader/predictor_resource_throttle.h"
27 #include "chrome/browser/loader/safe_browsing_resource_throttle.h" 27 #include "chrome/browser/loader/safe_browsing_resource_throttle.h"
28 #include "chrome/browser/mod_pagespeed/mod_pagespeed_metrics.h" 28 #include "chrome/browser/mod_pagespeed/mod_pagespeed_metrics.h"
29 #include "chrome/browser/net/resource_prefetch_predictor_observer.h" 29 #include "chrome/browser/net/loading_predictor_observer.h"
30 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h" 30 #include "chrome/browser/page_load_metrics/metrics_web_contents_observer.h"
31 #include "chrome/browser/plugins/plugin_prefs.h" 31 #include "chrome/browser/plugins/plugin_prefs.h"
32 #include "chrome/browser/prerender/prerender_manager.h" 32 #include "chrome/browser/prerender/prerender_manager.h"
33 #include "chrome/browser/prerender/prerender_manager_factory.h" 33 #include "chrome/browser/prerender/prerender_manager_factory.h"
34 #include "chrome/browser/prerender/prerender_resource_throttle.h" 34 #include "chrome/browser/prerender/prerender_resource_throttle.h"
35 #include "chrome/browser/prerender/prerender_util.h" 35 #include "chrome/browser/prerender/prerender_util.h"
36 #include "chrome/browser/profiles/profile.h" 36 #include "chrome/browser/profiles/profile.h"
37 #include "chrome/browser/profiles/profile_io_data.h" 37 #include "chrome/browser/profiles/profile_io_data.h"
38 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 38 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
39 #include "chrome/browser/search/search.h" 39 #include "chrome/browser/search/search.h"
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 529
530 AppendStandardResourceThrottles(request, 530 AppendStandardResourceThrottles(request,
531 resource_context, 531 resource_context,
532 resource_type, 532 resource_type,
533 throttles); 533 throttles);
534 #if !defined(DISABLE_NACL) 534 #if !defined(DISABLE_NACL)
535 AppendComponentUpdaterThrottles(request, *info, resource_context, 535 AppendComponentUpdaterThrottles(request, *info, resource_context,
536 resource_type, throttles); 536 resource_type, throttles);
537 #endif // !defined(DISABLE_NACL) 537 #endif // !defined(DISABLE_NACL)
538 538
539 if (io_data->resource_prefetch_predictor_observer()) { 539 if (io_data->loading_predictor_observer()) {
540 io_data->resource_prefetch_predictor_observer()->OnRequestStarted( 540 io_data->loading_predictor_observer()->OnRequestStarted(
541 request, resource_type, info->GetWebContentsGetterForRequest()); 541 request, resource_type, info->GetWebContentsGetterForRequest());
542 } 542 }
543 } 543 }
544 544
545 void ChromeResourceDispatcherHostDelegate::DownloadStarting( 545 void ChromeResourceDispatcherHostDelegate::DownloadStarting(
546 net::URLRequest* request, 546 net::URLRequest* request,
547 content::ResourceContext* resource_context, 547 content::ResourceContext* resource_context,
548 bool is_content_initiated, 548 bool is_content_initiated,
549 bool must_download, 549 bool must_download,
550 bool is_new_request, 550 bool is_new_request,
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 net::HttpResponseHeaders* response_headers = request->response_headers(); 804 net::HttpResponseHeaders* response_headers = request->response_headers();
805 if (response_headers && 805 if (response_headers &&
806 !response_headers->HasHeaderValue("x-frame-options", "deny") && 806 !response_headers->HasHeaderValue("x-frame-options", "deny") &&
807 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) { 807 !response_headers->HasHeaderValue("x-frame-options", "sameorigin")) {
808 response_headers->RemoveHeader("x-frame-options"); 808 response_headers->RemoveHeader("x-frame-options");
809 response_headers->AddHeader("x-frame-options: sameorigin"); 809 response_headers->AddHeader("x-frame-options: sameorigin");
810 } 810 }
811 } 811 }
812 #endif 812 #endif
813 813
814 if (io_data->resource_prefetch_predictor_observer()) 814 if (io_data->loading_predictor_observer())
815 io_data->resource_prefetch_predictor_observer()->OnResponseStarted( 815 io_data->loading_predictor_observer()->OnResponseStarted(
816 request, info->GetWebContentsGetterForRequest()); 816 request, info->GetWebContentsGetterForRequest());
817 817
818 mod_pagespeed::RecordMetrics(info->GetResourceType(), request->url(), 818 mod_pagespeed::RecordMetrics(info->GetResourceType(), request->url(),
819 request->response_headers()); 819 request->response_headers());
820 } 820 }
821 821
822 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected( 822 void ChromeResourceDispatcherHostDelegate::OnRequestRedirected(
823 const GURL& redirect_url, 823 const GURL& redirect_url,
824 net::URLRequest* request, 824 net::URLRequest* request,
825 content::ResourceContext* resource_context, 825 content::ResourceContext* resource_context,
826 content::ResourceResponse* response) { 826 content::ResourceResponse* response) {
827 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context); 827 ProfileIOData* io_data = ProfileIOData::FromResourceContext(resource_context);
828 828
829 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); 829 const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request);
830 830
831 // In the Mirror world (for users that are signed in to the browser on 831 // In the Mirror world (for users that are signed in to the browser on
832 // Android, the identity is mirrored into the content area), Chrome should 832 // Android, the identity is mirrored into the content area), Chrome should
833 // append a X-Chrome-Connected header to all Gaia requests from a connected 833 // append a X-Chrome-Connected header to all Gaia requests from a connected
834 // profile so Gaia could return a 204 response and let Chrome handle the 834 // profile so Gaia could return a 204 response and let Chrome handle the
835 // action with native UI. The only exception is requests from gaia webview, 835 // action with native UI. The only exception is requests from gaia webview,
836 // since the native profile management UI is built on top of it. 836 // since the native profile management UI is built on top of it.
837 signin::FixMirrorRequestHeaderHelper(request, redirect_url, io_data, 837 signin::FixMirrorRequestHeaderHelper(request, redirect_url, io_data,
838 info->GetChildID(), info->GetRouteID()); 838 info->GetChildID(), info->GetRouteID());
839 839
840 if (io_data->resource_prefetch_predictor_observer()) { 840 if (io_data->loading_predictor_observer()) {
841 io_data->resource_prefetch_predictor_observer()->OnRequestRedirected( 841 io_data->loading_predictor_observer()->OnRequestRedirected(
842 request, redirect_url, info->GetWebContentsGetterForRequest()); 842 request, redirect_url, info->GetWebContentsGetterForRequest());
843 } 843 }
844 844
845 if (io_data->policy_header_helper()) 845 if (io_data->policy_header_helper())
846 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request); 846 io_data->policy_header_helper()->AddPolicyHeaders(redirect_url, request);
847 } 847 }
848 848
849 // Notification that a request has completed. 849 // Notification that a request has completed.
850 void ChromeResourceDispatcherHostDelegate::RequestComplete( 850 void ChromeResourceDispatcherHostDelegate::RequestComplete(
851 net::URLRequest* url_request) { 851 net::URLRequest* url_request) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad, 965 &ChromeResourceDispatcherHostDelegate::OnAbortedFrameLoad,
966 base::Unretained(this), url, request_loading_time)); 966 base::Unretained(this), url, request_loading_time));
967 return; 967 return;
968 } 968 }
969 969
970 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ? 970 std::string metric_name = (request_loading_time.InMilliseconds() < 100 ?
971 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow"); 971 "Net.ErrAborted.Fast" : "Net.ErrAborted.Slow");
972 rappor::SampleDomainAndRegistryFromGURL( 972 rappor::SampleDomainAndRegistryFromGURL(
973 g_browser_process->rappor_service(), metric_name, url); 973 g_browser_process->rappor_service(), metric_name, url);
974 } 974 }
OLDNEW
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/net/loading_predictor_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698