From 4e254a6cef98f089a02123d32a22672b3e900aa7 Mon Sep 17 00:00:00 2001 From: ryansturm Date: Mon, 29 Feb 2016 16:13:21 -0800 Subject: Passing in a Data Reduction Proxy Delegate from Cronet with Data Reduction Proxy Enabled The Cronet test, CronetUrlRequestContextTest#testDataReductionProxyEnabled started to fail as a result of https://codereview.chromium.org/1680893002 This fix creates a DataReductionProxyDelegate for Cronet when built with the data_reduction build flag. The test relied on having DataReductionProxyNetworkDelegate handle the proxy resolution before, but that work is now handled by DataReductionProxyDelegate. BUG=589600 Review URL: https://codereview.chromium.org/1725123005 Cr-Commit-Position: refs/heads/master@{#378337} --- components/cronet/android/cronet_data_reduction_proxy.cc | 5 +++++ components/cronet/android/cronet_data_reduction_proxy.h | 5 +++++ components/cronet/android/cronet_url_request_context_adapter.cc | 2 ++ 3 files changed, 12 insertions(+) (limited to 'components/cronet/android') diff --git a/components/cronet/android/cronet_data_reduction_proxy.cc b/components/cronet/android/cronet_data_reduction_proxy.cc index 360862fb..76321be 100644 --- a/components/cronet/android/cronet_data_reduction_proxy.cc +++ b/components/cronet/android/cronet_data_reduction_proxy.cc @@ -11,6 +11,7 @@ #include "base/single_thread_task_runner.h" #include "components/cronet/android/cronet_in_memory_pref_store.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_network_delegate.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h" @@ -106,6 +107,10 @@ CronetDataReductionProxy::CreateNetworkDelegate( false /* No bypass UMA */); } +scoped_ptr CronetDataReductionProxy::CreateProxyDelegate() { + return io_data_->CreateProxyDelegate(); +} + scoped_ptr CronetDataReductionProxy::CreateInterceptor() { return io_data_->CreateInterceptor(); diff --git a/components/cronet/android/cronet_data_reduction_proxy.h b/components/cronet/android/cronet_data_reduction_proxy.h index ff4fa5f..c67ed78 100644 --- a/components/cronet/android/cronet_data_reduction_proxy.h +++ b/components/cronet/android/cronet_data_reduction_proxy.h @@ -25,6 +25,7 @@ class DataReductionProxySettings; namespace net { class NetLog; class NetworkDelegate; +class ProxyDelegate; class URLRequestContext; class URLRequestContextGetter; class URLRequestInterceptor; @@ -57,6 +58,10 @@ class CronetDataReductionProxy { scoped_ptr CreateNetworkDelegate( scoped_ptr wrapped_network_delegate); + // Constructs a proxy delegate suitable for adding Data Reduction Proxy + // proxy resolution. + scoped_ptr CreateProxyDelegate(); + // Constructs a URLRequestInterceptor suitable for carrying out the Data // Reduction Proxy's bypass protocol. scoped_ptr CreateInterceptor(); diff --git a/components/cronet/android/cronet_url_request_context_adapter.cc b/components/cronet/android/cronet_url_request_context_adapter.cc index 776fec7..e42ed20 100644 --- a/components/cronet/android/cronet_url_request_context_adapter.cc +++ b/components/cronet/android/cronet_url_request_context_adapter.cc @@ -418,6 +418,8 @@ void CronetURLRequestContextAdapter::InitializeOnNetworkThread( GetNetworkTaskRunner(), net_log_.get())); network_delegate = data_reduction_proxy_->CreateNetworkDelegate( std::move(network_delegate)); + context_builder.set_proxy_delegate( + data_reduction_proxy_->CreateProxyDelegate()); std::vector> interceptors; interceptors.push_back(data_reduction_proxy_->CreateInterceptor()); context_builder.SetInterceptors(std::move(interceptors)); -- cgit v1.1