Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc |
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc |
index f232e945e03ec905fc9263f217c6114737cf8c69..12d8b56770d96dbed2a97558fce9dca3fc8bce8d 100644 |
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc |
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc |
@@ -290,14 +290,17 @@ void DataReductionProxyNetworkDelegate::OnBeforeSendHeadersInternal( |
data = DataReductionProxyData::GetDataAndCreateIfNecessary(request); |
if (data) { |
data->set_used_data_reduction_proxy(true); |
- data->set_session_key( |
- data_reduction_proxy_request_options_->GetSecureSession()); |
- data->set_request_url(request->url()); |
- if ((request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) && |
- request->context()->network_quality_estimator()) { |
- data->set_effective_connection_type(request->context() |
- ->network_quality_estimator() |
- ->GetEffectiveConnectionType()); |
+ // Only set GURL, NQE and session key string for main frame requests since |
+ // they are not needed for sub-resources. |
+ if (request->load_flags() & net::LOAD_MAIN_FRAME_DEPRECATED) { |
+ data->set_session_key( |
+ data_reduction_proxy_request_options_->GetSecureSession()); |
+ data->set_request_url(request->url()); |
+ if (request->context()->network_quality_estimator()) { |
+ data->set_effective_connection_type(request->context() |
+ ->network_quality_estimator() |
+ ->GetEffectiveConnectionType()); |
+ } |
} |
} |
@@ -407,6 +410,25 @@ void DataReductionProxyNetworkDelegate::OnCompletedInternal( |
RecordContentLength(*request, request_type, original_content_length); |
} |
+void DataReductionProxyNetworkDelegate::OnHeadersReceivedInternal( |
+ net::URLRequest* request, |
+ const net::CompletionCallback& callback, |
+ const net::HttpResponseHeaders* original_response_headers, |
+ scoped_refptr<net::HttpResponseHeaders>* override_response_headers, |
+ GURL* allowed_unsafe_redirect_url) { |
+ if (!original_response_headers) |
+ return; |
+ if (IsEmptyImagePreview(*original_response_headers)) { |
+ DataReductionProxyData* data = |
+ DataReductionProxyData::GetDataAndCreateIfNecessary(request); |
+ data->set_lofi_received(true); |
+ } else if (IsLitePagePreview(*original_response_headers)) { |
+ DataReductionProxyData* data = |
+ DataReductionProxyData::GetDataAndCreateIfNecessary(request); |
+ data->set_lite_page_received(true); |
+ } |
+} |
+ |
void DataReductionProxyNetworkDelegate::CalculateAndRecordDataUsage( |
const net::URLRequest& request, |
DataReductionProxyRequestType request_type) { |