diff options
11 files changed, 145 insertions, 154 deletions
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc index e29759a..9ee5108 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.cc @@ -11,14 +11,10 @@ #include "base/single_thread_task_runner.h" #include "base/strings/string_util.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_configurator.h" +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_config_values.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_event_store.h" -#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" -#include "net/base/load_flags.h" -#include "net/http/http_network_layer.h" #include "net/proxy/proxy_server.h" -#include "net/url_request/url_fetcher.h" -#include "net/url_request/url_fetcher_delegate.h" #include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_status.h" @@ -50,82 +46,9 @@ void RecordNetworkChangeEvent(DataReductionProxyNetworkChangeEvent event) { namespace data_reduction_proxy { -// Checks if the secure proxy is allowed by the carrier by sending a probe. -class SecureProxyChecker : public net::URLFetcherDelegate { - public: - SecureProxyChecker(net::URLRequestContext* url_request_context, - scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) - : io_task_runner_(io_task_runner) { - DCHECK(io_task_runner_->BelongsToCurrentThread()); - - url_request_context_.reset(new net::URLRequestContext()); - url_request_context_->CopyFrom(url_request_context); - - net::HttpNetworkSession::Params params_modified = - *(url_request_context_->GetNetworkSessionParams()); - params_modified.enable_quic = false; - params_modified.next_protos = net::NextProtosWithSpdyAndQuic(false, false); - - http_network_layer_.reset(new net::HttpNetworkLayer( - new net::HttpNetworkSession(params_modified))); - url_request_context_->set_http_transaction_factory( - http_network_layer_.get()); - - url_request_context_getter_ = new net::TrivialURLRequestContextGetter( - url_request_context_.get(), io_task_runner_); - } - - void OnURLFetchComplete(const net::URLFetcher* source) override { - DCHECK(io_task_runner_->BelongsToCurrentThread()); - DCHECK_EQ(source, fetcher_.get()); - net::URLRequestStatus status = source->GetStatus(); - - std::string response; - source->GetResponseAsString(&response); - - fetcher_callback_.Run(response, status); - } - - void CheckIfSecureProxyIsAllowed(const GURL& secure_proxy_check_url, - FetcherResponseCallback fetcher_callback) { - DCHECK(io_task_runner_->BelongsToCurrentThread()); - fetcher_.reset(net::URLFetcher::Create(secure_proxy_check_url, - net::URLFetcher::GET, this)); - fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE | net::LOAD_BYPASS_PROXY); - fetcher_->SetRequestContext(url_request_context_getter_.get()); - // Configure max retries to be at most kMaxRetries times for 5xx errors. - static const int kMaxRetries = 5; - fetcher_->SetMaxRetriesOn5xx(kMaxRetries); - fetcher_->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); - // The secure proxy check should not be redirected. Since the secure proxy - // check will inevitably fail if it gets redirected somewhere else (e.g. by - // a captive portal), short circuit that by giving up on the secure proxy - // check if it gets redirected. - fetcher_->SetStopOnRedirect(true); - - fetcher_callback_ = fetcher_callback; - - fetcher_->Start(); - } - - ~SecureProxyChecker() override {} - - private: - scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; - - scoped_refptr<net::URLRequestContextGetter> url_request_context_getter_; - scoped_ptr<net::URLRequestContext> url_request_context_; - scoped_ptr<net::HttpNetworkLayer> http_network_layer_; - - // The URLFetcher being used for the secure proxy check. - scoped_ptr<net::URLFetcher> fetcher_; - FetcherResponseCallback fetcher_callback_; - - DISALLOW_COPY_AND_ASSIGN(SecureProxyChecker); -}; - DataReductionProxyConfig::DataReductionProxyConfig( scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, net::NetLog* net_log, scoped_ptr<DataReductionProxyConfigValues> config_values, DataReductionProxyConfigurator* configurator, @@ -137,11 +60,13 @@ DataReductionProxyConfig::DataReductionProxyConfig( alternative_enabled_by_user_(false), config_values_(config_values.Pass()), io_task_runner_(io_task_runner), + ui_task_runner_(ui_task_runner), net_log_(net_log), configurator_(configurator), event_store_(event_store), url_request_context_getter_(nullptr) { DCHECK(io_task_runner); + DCHECK(ui_task_runner); DCHECK(configurator); DCHECK(event_store); } @@ -150,15 +75,15 @@ DataReductionProxyConfig::~DataReductionProxyConfig() { net::NetworkChangeNotifier::RemoveIPAddressObserver(this); } +void DataReductionProxyConfig::SetDataReductionProxyService( + base::WeakPtr<DataReductionProxyService> data_reduction_proxy_service) { + data_reduction_proxy_service_ = data_reduction_proxy_service; +} + void DataReductionProxyConfig::InitializeOnIOThread( net::URLRequestContextGetter* url_request_context_getter) { DCHECK(url_request_context_getter); url_request_context_getter_ = url_request_context_getter; - - DCHECK(url_request_context_getter_->GetURLRequestContext()); - secure_proxy_checker_.reset(new SecureProxyChecker( - url_request_context_getter_->GetURLRequestContext(), io_task_runner_)); - if (!config_values_->allowed()) return; @@ -331,13 +256,9 @@ void DataReductionProxyConfig::SetProxyConfig( if (enabled && !(alternative_enabled && !config_values_->alternative_fallback_allowed())) { - // It is safe to use base::Unretained here, since it gets executed - // synchronously on the IO thread, and |this| outlives - // |secure_proxy_checker_|. - SecureProxyCheck( - config_values_->secure_proxy_check_url(), - base::Bind(&DataReductionProxyConfig::HandleSecureProxyCheckResponse, - base::Unretained(this))); + ui_task_runner_->PostTask( + FROM_HERE, base::Bind(&DataReductionProxyConfig::StartSecureProxyCheck, + base::Unretained(this))); } } @@ -401,7 +322,16 @@ void DataReductionProxyConfig::LogProxyState(bool enabled, void DataReductionProxyConfig::HandleSecureProxyCheckResponse( const std::string& response, const net::URLRequestStatus& status) { - DCHECK(io_task_runner_->BelongsToCurrentThread()); + DCHECK(ui_task_runner_->BelongsToCurrentThread()); + io_task_runner_->PostTask( + FROM_HERE, + base::Bind( + &DataReductionProxyConfig::HandleSecureProxyCheckResponseOnIOThread, + base::Unretained(this), response, status)); +} + +void DataReductionProxyConfig::HandleSecureProxyCheckResponseOnIOThread( + const std::string& response, const net::URLRequestStatus& status) { if (event_store_) { event_store_->EndSecureProxyCheck(bound_net_log_, status.error()); } @@ -464,13 +394,9 @@ void DataReductionProxyConfig::OnIPAddressChanged() { return; } - // It is safe to use base::Unretained here, since it gets executed - // synchronously on the IO thread, and |this| outlives - // |secure_proxy_checker_|. - SecureProxyCheck( - config_values_->secure_proxy_check_url(), - base::Bind(&DataReductionProxyConfig::HandleSecureProxyCheckResponse, - base::Unretained(this))); + ui_task_runner_->PostTask( + FROM_HERE, base::Bind(&DataReductionProxyConfig::StartSecureProxyCheck, + base::Unretained(this))); } } @@ -506,21 +432,21 @@ void DataReductionProxyConfig::RecordSecureProxyCheckFetchResult( SECURE_PROXY_CHECK_FETCH_RESULT_COUNT); } -void DataReductionProxyConfig::SecureProxyCheck( - const GURL& secure_proxy_check_url, - FetcherResponseCallback fetcher_callback) { - DCHECK(io_task_runner_->BelongsToCurrentThread()); +void DataReductionProxyConfig::StartSecureProxyCheck() { + DCHECK(ui_task_runner_->BelongsToCurrentThread()); bound_net_log_ = net::BoundNetLog::Make( net_log_, net::NetLog::SOURCE_DATA_REDUCTION_PROXY); + if (data_reduction_proxy_service_) { + if (event_store_) { + event_store_->BeginSecureProxyCheck( + bound_net_log_, config_values_->secure_proxy_check_url()); + } - if (event_store_) { - event_store_->BeginSecureProxyCheck( - bound_net_log_, config_values_->secure_proxy_check_url()); + data_reduction_proxy_service_->SecureProxyCheck( + config_values_->secure_proxy_check_url(), + base::Bind(&DataReductionProxyConfig::HandleSecureProxyCheckResponse, + base::Unretained(this))); } - - DCHECK(secure_proxy_checker_); - secure_proxy_checker_->CheckIfSecureProxyIsAllowed(secure_proxy_check_url, - fetcher_callback); } void DataReductionProxyConfig::GetNetworkList( diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h index 9acf691..770c032 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h @@ -5,9 +5,6 @@ #ifndef COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIG_H_ #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_CONFIG_H_ -#include <string> - -#include "base/callback.h" #include "base/gtest_prod_util.h" #include "base/macros.h" #include "base/memory/ref_counted.h" @@ -20,8 +17,6 @@ #include "net/proxy/proxy_config.h" #include "net/proxy/proxy_retry_info.h" -class GURL; - namespace base { class SingleThreadTaskRunner; class TimeDelta; @@ -30,7 +25,6 @@ class TimeDelta; namespace net { class HostPortPair; class NetLog; -class URLFetcher; class URLRequest; class URLRequestContextGetter; class URLRequestStatus; @@ -38,14 +32,10 @@ class URLRequestStatus; namespace data_reduction_proxy { -typedef base::Callback<void(const std::string&, const net::URLRequestStatus&)> - FetcherResponseCallback; - class DataReductionProxyConfigValues; class DataReductionProxyConfigurator; class DataReductionProxyEventStore; class DataReductionProxyService; -class SecureProxyChecker; struct DataReductionProxyTypeInfo; // Values of the UMA DataReductionProxy.ProbeURL histogram. @@ -85,12 +75,16 @@ class DataReductionProxyConfig // which this instance will own. DataReductionProxyConfig( scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, net::NetLog* net_log, scoped_ptr<DataReductionProxyConfigValues> config_values, DataReductionProxyConfigurator* configurator, DataReductionProxyEventStore* event_store); ~DataReductionProxyConfig() override; + void SetDataReductionProxyService( + base::WeakPtr<DataReductionProxyService> data_reduction_proxy_service); + // Performs initialization on the IO thread. void InitializeOnIOThread( net::URLRequestContextGetter* url_request_context_getter); @@ -221,16 +215,16 @@ class DataReductionProxyConfig bool restricted, bool at_startup); - // Requests the given |secure_proxy_check_url|. Upon completion, returns the - // results to the caller via the |fetcher_callback|. Virtualized for unit - // testing. - virtual void SecureProxyCheck(const GURL& secure_proxy_check_url, - FetcherResponseCallback fetcher_callback); + // Begins a secure proxy check to determine if the Data Reduction Proxy is + // permitted to use the HTTPS proxy servers. + void StartSecureProxyCheck(); // Parses the secure proxy check responses and appropriately configures the // Data Reduction Proxy rules. virtual void HandleSecureProxyCheckResponse( const std::string& response, const net::URLRequestStatus& status); + virtual void HandleSecureProxyCheckResponseOnIOThread( + const std::string& response, const net::URLRequestStatus& status); // Adds the default proxy bypass rules for the Data Reduction Proxy. void AddDefaultProxyBypassRules(); @@ -252,8 +246,6 @@ class DataReductionProxyConfig bool is_https, base::TimeDelta* min_retry_delay) const; - scoped_ptr<SecureProxyChecker> secure_proxy_checker_; - bool restricted_by_carrier_; bool disabled_on_vpn_; bool unreachable_; @@ -267,6 +259,10 @@ class DataReductionProxyConfig // IO thread. scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; + // |ui_task_runner_| should be the task runner for running operations on the + // UI thread. + scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; + // The caller must ensure that the |net_log_|, if set, outlives this instance. // It is used to create new instances of |bound_net_log_| on secure proxy // checks. |bound_net_log_| permits the correlation of the begin and end @@ -287,6 +283,11 @@ class DataReductionProxyConfig // Enforce usage on the IO thread. base::ThreadChecker thread_checker_; + // A weak pointer to a |DataReductionProxyService| to perform secure proxy + // checks. The weak pointer is required since the |DataReductionProxyService| + // is destroyed before this instance of the |DataReductionProxyConfig|. + base::WeakPtr<DataReductionProxyService> data_reduction_proxy_service_; + DISALLOW_COPY_AND_ASSIGN(DataReductionProxyConfig); }; diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.cc index dbbde52..f6e836c 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.cc @@ -39,6 +39,7 @@ TestDataReductionProxyConfig::TestDataReductionProxyConfig( DataReductionProxyConfigurator* configurator, DataReductionProxyEventStore* event_store) : DataReductionProxyConfig(task_runner, + task_runner, net_log, config_values.Pass(), configurator, diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h index 759b29c..fba88ee 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_test_utils.h @@ -116,9 +116,6 @@ class MockDataReductionProxyConfig : public TestDataReductionProxyConfig { bool(const net::URLRequest& request, const net::ProxyConfig& data_reduction_proxy_config, base::TimeDelta* min_retry_delay)); - MOCK_METHOD2(SecureProxyCheck, - void(const GURL& secure_proxy_check_url, - FetcherResponseCallback fetcher_callback)); // UpdateConfigurator should always call LogProxyState exactly once. void UpdateConfigurator(bool enabled, diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc index 7b61eed..44746c1 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_config_unittest.cc @@ -127,11 +127,13 @@ class DataReductionProxyConfigTest : public testing::Test { !config()->restricted_by_carrier_, request_succeeded && (response == "OK")), request_succeeded, 1); + MockDataReductionProxyService* service = + test_context_->mock_data_reduction_proxy_service(); TestResponder responder; responder.response = response; responder.status = net::URLRequestStatus(net::URLRequestStatus::SUCCESS, net::OK); - EXPECT_CALL(*config(), SecureProxyCheck(_, _)) + EXPECT_CALL(*service, SecureProxyCheck(_, _)) .Times(1) .WillRepeatedly(testing::WithArgs<1>( testing::Invoke(&responder, &TestResponder::ExecuteCallback))); @@ -159,8 +161,9 @@ class DataReductionProxyConfigTest : public testing::Test { scoped_ptr<DataReductionProxyParams> params) { params->EnableQuic(false); return make_scoped_ptr(new DataReductionProxyConfig( - test_context_->task_runner(), test_context_->net_log(), params.Pass(), - test_context_->configurator(), test_context_->event_store())); + test_context_->task_runner(), test_context_->task_runner(), + test_context_->net_log(), params.Pass(), test_context_->configurator(), + test_context_->event_store())); } MockDataReductionProxyConfig* config() { diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc index 9034bae..52340f7 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.cc @@ -58,12 +58,12 @@ DataReductionProxyIOData::DataReductionProxyIOData( DataReductionProxyMutableConfigValues::CreateFromParams(params.get()); raw_mutable_config = mutable_config.get(); config_.reset(new DataReductionProxyConfig( - io_task_runner_, net_log, mutable_config.Pass(), configurator_.get(), - event_store_.get())); + io_task_runner_, ui_task_runner_, net_log, mutable_config.Pass(), + configurator_.get(), event_store_.get())); } else { - config_.reset( - new DataReductionProxyConfig(io_task_runner_, net_log, params.Pass(), - configurator_.get(), event_store_.get())); + config_.reset(new DataReductionProxyConfig( + io_task_runner_, ui_task_runner_, net_log, params.Pass(), + configurator_.get(), event_store_.get())); } // It is safe to use base::Unretained here, since it gets executed @@ -113,6 +113,7 @@ void DataReductionProxyIOData::SetDataReductionProxyService( DCHECK(ui_task_runner_->BelongsToCurrentThread()); service_ = data_reduction_proxy_service; url_request_context_getter_ = service_->url_request_context_getter(); + config()->SetDataReductionProxyService(data_reduction_proxy_service); // Using base::Unretained is safe here, unless the browser is being shut down // before the Initialize task can be executed. The task is only created as // part of class initialization. diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc index 1b90a14..3c17aa2 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.cc @@ -11,6 +11,9 @@ #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service_observer.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h" +#include "net/base/load_flags.h" +#include "net/url_request/url_fetcher.h" +#include "net/url_request/url_request_status.h" namespace data_reduction_proxy { @@ -106,4 +109,47 @@ DataReductionProxyService::GetWeakPtr() { return weak_factory_.GetWeakPtr(); } +void DataReductionProxyService::OnURLFetchComplete( + const net::URLFetcher* source) { + DCHECK(source == fetcher_.get()); + net::URLRequestStatus status = source->GetStatus(); + + std::string response; + source->GetResponseAsString(&response); + + fetcher_callback_.Run(response, status); +} + +net::URLFetcher* DataReductionProxyService::GetURLFetcherForSecureProxyCheck( + const GURL& secure_proxy_check_url) { + net::URLFetcher* fetcher = net::URLFetcher::Create( + secure_proxy_check_url, net::URLFetcher::GET, this); + fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE | net::LOAD_BYPASS_PROXY); + DCHECK(url_request_context_getter_); + fetcher->SetRequestContext(url_request_context_getter_); + // Configure max retries to be at most kMaxRetries times for 5xx errors. + static const int kMaxRetries = 5; + fetcher->SetMaxRetriesOn5xx(kMaxRetries); + fetcher->SetAutomaticallyRetryOnNetworkChanges(kMaxRetries); + // The secure proxy check should not be redirected. Since the secure proxy + // check will inevitably fail if it gets redirected somewhere else (e.g. by a + // captive portal), short circuit that by giving up on the secure proxy check + // if it gets redirected. + fetcher->SetStopOnRedirect(true); + return fetcher; +} + +void DataReductionProxyService::SecureProxyCheck( + const GURL& secure_proxy_check_url, + FetcherResponseCallback fetcher_callback) { + DCHECK(CalledOnValidThread()); + net::URLFetcher* fetcher = + GetURLFetcherForSecureProxyCheck(secure_proxy_check_url); + if (!fetcher) + return; + fetcher_.reset(fetcher); + fetcher_callback_ = fetcher_callback; + fetcher_->Start(); +} + } // namespace data_reduction_proxy diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h index ed39307..0f9aed7 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h @@ -14,6 +14,7 @@ #include "base/single_thread_task_runner.h" #include "base/threading/non_thread_safe.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h" +#include "net/url_request/url_fetcher_delegate.h" class GURL; class PrefService; @@ -24,11 +25,16 @@ class TimeDelta; } namespace net { +class URLFetcher; class URLRequestContextGetter; +class URLRequestStatus; } namespace data_reduction_proxy { +typedef base::Callback<void(const std::string&, const net::URLRequestStatus&)> + FetcherResponseCallback; + class DataReductionProxyCompressionStats; class DataReductionProxyIOData; class DataReductionProxyServiceObserver; @@ -36,7 +42,8 @@ class DataReductionProxySettings; // Contains and initializes all Data Reduction Proxy objects that have a // lifetime based on the UI thread. -class DataReductionProxyService : public base::NonThreadSafe { +class DataReductionProxyService : public base::NonThreadSafe, + public net::URLFetcherDelegate { public: // The caller must ensure that |settings| and |request_context| remain alive // for the lifetime of the |DataReductionProxyService| instance. This instance @@ -49,7 +56,7 @@ class DataReductionProxyService : public base::NonThreadSafe { net::URLRequestContextGetter* request_context_getter, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); - virtual ~DataReductionProxyService(); + ~DataReductionProxyService() override; // Sets the DataReductionProxyIOData weak pointer. void SetIOData(base::WeakPtr<DataReductionProxyIOData> io_data); @@ -60,6 +67,12 @@ class DataReductionProxyService : public base::NonThreadSafe { // final step in initialization. bool Initialized() const; + // Requests the given |secure_proxy_check_url|. Upon completion, returns the + // results to the caller via the |fetcher_callback|. Virtualized for unit + // testing. + virtual void SecureProxyCheck(const GURL& secure_proxy_check_url, + FetcherResponseCallback fetcher_callback); + // Constructs compression stats. This should not be called if a valid // compression stats is passed into the constructor. void EnableCompressionStatisticsLogging( @@ -101,9 +114,22 @@ class DataReductionProxyService : public base::NonThreadSafe { base::WeakPtr<DataReductionProxyService> GetWeakPtr(); + protected: + // Virtualized for testing. Returns a fetcher to check if it is permitted to + // use the secure proxy. + virtual net::URLFetcher* GetURLFetcherForSecureProxyCheck( + const GURL& secure_proxy_check_url); + private: + // net::URLFetcherDelegate: + void OnURLFetchComplete(const net::URLFetcher* source) override; + net::URLRequestContextGetter* url_request_context_getter_; + // The URLFetcher being used for the secure proxy check. + scoped_ptr<net::URLFetcher> fetcher_; + FetcherResponseCallback fetcher_callback_; + // Tracks compression statistics to be displayed to the user. scoped_ptr<DataReductionProxyCompressionStats> compression_stats_; diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc index 1d64a4c..0b404ad 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_settings_unittest.cc @@ -194,18 +194,6 @@ TEST(DataReductionProxySettingsStandaloneTest, TestEndToEndSecureProxyCheck) { .SkipSettingsInitialization() .Build(); - // Enabling QUIC should have no effect since secure proxy should not - // use QUIC. If secure proxy check incorrectly uses QUIC, the tests will - // fail because Mock sockets do not speak QUIC. - scoped_ptr<net::HttpNetworkSession::Params> params( - new net::HttpNetworkSession::Params()); - params->use_alternate_protocols = true; - params->enable_quic = true; - params->origin_to_force_quic_on = net::HostPortPair::FromString( - TestDataReductionProxyParams::DefaultSecureProxyCheckURL()); - - context.set_http_network_session_params(params.Pass()); - context.set_net_log(drp_test_context->net_log()); net::MockClientSocketFactory mock_socket_factory; context.set_client_socket_factory(&mock_socket_factory); diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h index 4993ffe..7b2add4 100644 --- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h +++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_test_utils.h @@ -156,6 +156,9 @@ class MockDataReductionProxyService : public DataReductionProxyService { scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); ~MockDataReductionProxyService() override; + MOCK_METHOD2(SecureProxyCheck, + void(const GURL& secure_proxy_check_url, + FetcherResponseCallback fetcher_callback)); MOCK_METHOD3(SetProxyPrefs, void(bool enabled, bool alternative_enabled, bool at_startup)); }; diff --git a/net/url_request/url_request_test_util.h b/net/url_request/url_request_test_util.h index c856c98..0208b43 100644 --- a/net/url_request/url_request_test_util.h +++ b/net/url_request/url_request_test_util.h @@ -70,8 +70,7 @@ class TestURLRequestContext : public URLRequestContext { } void set_http_network_session_params( - scoped_ptr<HttpNetworkSession::Params> params) { - http_network_session_params_ = params.Pass(); + const HttpNetworkSession::Params& params) { } void SetSdchManager(scoped_ptr<SdchManager> sdch_manager) { |