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

Side by Side Diff: content/browser/loader/resource_loader.cc

Issue 2213683003: Update Effective Connection Type only on main frame requests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use enum Created 4 years, 4 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 | « content/browser/loader/DEPS ('k') | content/browser/loader/resource_loader_unittest.cc » ('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 "content/browser/loader/resource_loader.h" 5 #include "content/browser/loader/resource_loader.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/browser/ssl/ssl_client_auth_handler.h" 25 #include "content/browser/ssl/ssl_client_auth_handler.h"
26 #include "content/browser/ssl/ssl_manager.h" 26 #include "content/browser/ssl/ssl_manager.h"
27 #include "content/browser/ssl/ssl_policy.h" 27 #include "content/browser/ssl/ssl_policy.h"
28 #include "content/common/ssl_status_serialization.h" 28 #include "content/common/ssl_status_serialization.h"
29 #include "content/public/browser/cert_store.h" 29 #include "content/public/browser/cert_store.h"
30 #include "content/public/browser/resource_dispatcher_host_login_delegate.h" 30 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
31 #include "content/public/common/content_client.h" 31 #include "content/public/common/content_client.h"
32 #include "content/public/common/content_switches.h" 32 #include "content/public/common/content_switches.h"
33 #include "content/public/common/process_type.h" 33 #include "content/public/common/process_type.h"
34 #include "content/public/common/resource_response.h" 34 #include "content/public/common/resource_response.h"
35 #include "content/public/common/resource_type.h"
35 #include "content/public/common/security_style.h" 36 #include "content/public/common/security_style.h"
36 #include "net/base/io_buffer.h" 37 #include "net/base/io_buffer.h"
37 #include "net/base/load_flags.h" 38 #include "net/base/load_flags.h"
38 #include "net/http/http_response_headers.h" 39 #include "net/http/http_response_headers.h"
39 #include "net/nqe/effective_connection_type.h" 40 #include "net/nqe/effective_connection_type.h"
40 #include "net/nqe/network_quality_estimator.h" 41 #include "net/nqe/network_quality_estimator.h"
41 #include "net/ssl/client_cert_store.h" 42 #include "net/ssl/client_cert_store.h"
42 #include "net/ssl/ssl_platform_key.h" 43 #include "net/ssl/ssl_platform_key.h"
43 #include "net/ssl/ssl_private_key.h" 44 #include "net/ssl/ssl_private_key.h"
44 #include "net/url_request/redirect_info.h" 45 #include "net/url_request/redirect_info.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 response->head.was_fetched_via_proxy = request->was_fetched_via_proxy(); 84 response->head.was_fetched_via_proxy = request->was_fetched_via_proxy();
84 response->head.proxy_server = response_info.proxy_server; 85 response->head.proxy_server = response_info.proxy_server;
85 response->head.socket_address = response_info.socket_address; 86 response->head.socket_address = response_info.socket_address;
86 const content::ResourceRequestInfo* request_info = 87 const content::ResourceRequestInfo* request_info =
87 content::ResourceRequestInfo::ForRequest(request); 88 content::ResourceRequestInfo::ForRequest(request);
88 if (request_info) 89 if (request_info)
89 response->head.is_using_lofi = request_info->IsUsingLoFi(); 90 response->head.is_using_lofi = request_info->IsUsingLoFi();
90 91
91 response->head.effective_connection_type = 92 response->head.effective_connection_type =
92 net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN; 93 net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN;
93 if (info->IsMainFrame()) { 94
95 if (info->GetResourceType() == RESOURCE_TYPE_MAIN_FRAME) {
96 DCHECK(info->IsMainFrame());
94 net::NetworkQualityEstimator* estimator = 97 net::NetworkQualityEstimator* estimator =
95 request->context()->network_quality_estimator(); 98 request->context()->network_quality_estimator();
96 if (estimator) { 99 if (estimator) {
97 response->head.effective_connection_type = 100 response->head.effective_connection_type =
98 estimator->GetEffectiveConnectionType(); 101 estimator->GetEffectiveConnectionType();
99 } 102 }
100 } 103 }
101 104
102 const ServiceWorkerResponseInfo* service_worker_info = 105 const ServiceWorkerResponseInfo* service_worker_info =
103 ServiceWorkerResponseInfo::ForRequest(request); 106 ServiceWorkerResponseInfo::ForRequest(request);
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 } 739 }
737 740
738 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX); 741 UMA_HISTOGRAM_ENUMERATION("Net.Prefetch.Pattern", status, STATUS_MAX);
739 } else if (request_->response_info().unused_since_prefetch) { 742 } else if (request_->response_info().unused_since_prefetch) {
740 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time(); 743 TimeDelta total_time = base::TimeTicks::Now() - request_->creation_time();
741 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentOnPrefetchHit", total_time); 744 UMA_HISTOGRAM_TIMES("Net.Prefetch.TimeSpentOnPrefetchHit", total_time);
742 } 745 }
743 } 746 }
744 747
745 } // namespace content 748 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/DEPS ('k') | content/browser/loader/resource_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698