From bdcd2a7aff20eca5832636c4b78df633cab6c61e Mon Sep 17 00:00:00 2001 From: jeremyim Date: Fri, 31 Oct 2014 09:38:04 -0700 Subject: [PATCH] Make the proxy server HostPortPair available in document_state so that we can determine whether the data_reduction_proxy was used or not for PLT UMA. BUG=374264 Committed: https://crrev.com/ac77ecc781ff1860e3344b99d6f5a8e9d672dd73 Cr-Commit-Position: refs/heads/master@{#302150} Review URL: https://codereview.chromium.org/686313002 Cr-Commit-Position: refs/heads/master@{#302280} --- content/browser/loader/resource_loader.cc | 1 + content/child/web_url_loader_impl.cc | 1 + content/child/weburlresponse_extradata_impl.h | 10 ++++++++++ content/common/resource_messages.h | 1 + content/public/common/resource_response.cc | 1 + content/public/common/resource_response_info.h | 4 +++- content/public/renderer/document_state.h | 6 ++++++ content/renderer/render_frame_impl.cc | 2 ++ 8 files changed, 25 insertions(+), 1 deletion(-) diff --git a/content/browser/loader/resource_loader.cc b/content/browser/loader/resource_loader.cc index 21e0b0056130..eae75eb4be53 100644 --- a/content/browser/loader/resource_loader.cc +++ b/content/browser/loader/resource_loader.cc @@ -55,6 +55,7 @@ void PopulateResourceResponse(ResourceRequestInfoImpl* info, response_info.npn_negotiated_protocol; response->head.connection_info = response_info.connection_info; response->head.was_fetched_via_proxy = request->was_fetched_via_proxy(); + response->head.proxy_server = response_info.proxy_server; response->head.socket_address = request->GetSocketAddress(); if (ServiceWorkerRequestHandler* handler = ServiceWorkerRequestHandler::GetHandler(request)) { diff --git a/content/child/web_url_loader_impl.cc b/content/child/web_url_loader_impl.cc index 552bc6fec770..7249d1622923 100644 --- a/content/child/web_url_loader_impl.cc +++ b/content/child/web_url_loader_impl.cc @@ -848,6 +848,7 @@ void WebURLLoaderImpl::PopulateURLResponse(const GURL& url, info.was_alternate_protocol_available); extra_data->set_connection_info(info.connection_info); extra_data->set_was_fetched_via_proxy(info.was_fetched_via_proxy); + extra_data->set_proxy_server(info.proxy_server); // If there's no received headers end time, don't set load timing. This is // the case for non-HTTP requests, requests that don't go over the wire, and diff --git a/content/child/weburlresponse_extradata_impl.h b/content/child/weburlresponse_extradata_impl.h index be4d1bc5527c..719b0693c4c0 100644 --- a/content/child/weburlresponse_extradata_impl.h +++ b/content/child/weburlresponse_extradata_impl.h @@ -35,6 +35,15 @@ class CONTENT_EXPORT WebURLResponseExtraDataImpl : was_fetched_via_proxy_ = was_fetched_via_proxy; } + // The proxy server used if this request was loaded via an explicit proxy + // (HTTP, SOCKS, etc). + net::HostPortPair proxy_server() const { + return proxy_server_; + } + void set_proxy_server(net::HostPortPair proxy_server) { + proxy_server_ = proxy_server; + } + /// Flag whether this request was loaded via the SPDY protocol or not. // SPDY is an experimental web protocol, see http://dev.chromium.org/spdy bool was_fetched_via_spdy() const { @@ -82,6 +91,7 @@ class CONTENT_EXPORT WebURLResponseExtraDataImpl : std::string npn_negotiated_protocol_; bool is_ftp_directory_listing_; bool was_fetched_via_proxy_; + net::HostPortPair proxy_server_; bool was_fetched_via_spdy_; bool was_npn_negotiated_; net::HttpResponseInfo::ConnectionInfo connection_info_; diff --git a/content/common/resource_messages.h b/content/common/resource_messages.h index abaf33426ca6..e35a88e06cac 100644 --- a/content/common/resource_messages.h +++ b/content/common/resource_messages.h @@ -132,6 +132,7 @@ IPC_STRUCT_TRAITS_BEGIN(content::ResourceResponseInfo) IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_start) IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_ready) IPC_STRUCT_TRAITS_MEMBER(service_worker_fetch_end) + IPC_STRUCT_TRAITS_MEMBER(proxy_server) IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_BEGIN(net::RedirectInfo) diff --git a/content/public/common/resource_response.cc b/content/public/common/resource_response.cc index 793498121856..92abfba8e3cf 100644 --- a/content/public/common/resource_response.cc +++ b/content/public/common/resource_response.cc @@ -34,6 +34,7 @@ scoped_refptr ResourceResponse::DeepCopy() const { new_response->head.was_alternate_protocol_available; new_response->head.connection_info = head.connection_info; new_response->head.was_fetched_via_proxy = head.was_fetched_via_proxy; + new_response->head.proxy_server = head.proxy_server; new_response->head.npn_negotiated_protocol = head.npn_negotiated_protocol; new_response->head.socket_address = head.socket_address; new_response->head.was_fetched_via_service_worker = diff --git a/content/public/common/resource_response_info.h b/content/public/common/resource_response_info.h index e5d39d977d4b..42c2a8c8aecb 100644 --- a/content/public/common/resource_response_info.h +++ b/content/public/common/resource_response_info.h @@ -93,8 +93,10 @@ struct ResourceResponseInfo { // True if the response was fetched via an explicit proxy (as opposed to a // transparent proxy). The proxy could be any type of proxy, HTTP or SOCKS. - // Note: we cannot tell if a transparent proxy may have been involved. + // Note: we cannot tell if a transparent proxy may have been involved. If + // true, |proxy_server| contains the name of the proxy server that was used. bool was_fetched_via_proxy; + net::HostPortPair proxy_server; // NPN protocol negotiated with the server. std::string npn_negotiated_protocol; diff --git a/content/public/renderer/document_state.h b/content/public/renderer/document_state.h index 11b7d5e10bfd..d388a8a979ef 100644 --- a/content/public/renderer/document_state.h +++ b/content/public/renderer/document_state.h @@ -161,6 +161,11 @@ class CONTENT_EXPORT DocumentState was_fetched_via_proxy_ = value; } + net::HostPortPair proxy_server() const { return proxy_server_; } + void set_proxy_server(net::HostPortPair proxy_server) { + proxy_server_ = proxy_server; + } + void set_was_prefetcher(bool value) { was_prefetcher_ = value; } bool was_prefetcher() const { return was_prefetcher_; } @@ -204,6 +209,7 @@ class CONTENT_EXPORT DocumentState bool was_alternate_protocol_available_; net::HttpResponseInfo::ConnectionInfo connection_info_; bool was_fetched_via_proxy_; + net::HostPortPair proxy_server_; // A prefetcher is a page that contains link rel=prefetch elements. bool was_prefetcher_; diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index 3e10a4c5fed1..7bbdfdcca736 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -2952,6 +2952,8 @@ void RenderFrameImpl::didReceiveResponse( extra_data->connection_info()); document_state->set_was_fetched_via_proxy( extra_data->was_fetched_via_proxy()); + document_state->set_proxy_server( + extra_data->proxy_server()); } InternalDocumentStateData* internal_data = InternalDocumentStateData::FromDocumentState(document_state); -- 2.11.4.GIT