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

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.cc

Issue 2833523002: Adding opt out and previews type information to DRP pingback (Closed)
Patch Set: bengr comments Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
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 3e79f4a6a98b8f89b3cf574a21d12b2d73c861a1..6752c415e7861dbec641209707bdcbf868b57226 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
@@ -297,14 +297,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());
+ }
}
}
@@ -414,6 +417,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) {

Powered by Google App Engine
This is Rietveld 408576698