diff options
author | Bartosz Fabianowski <bartfab@chromium.org> | 2015-04-16 12:27:51 +0200 |
---|---|---|
committer | Bartosz Fabianowski <bartfab@chromium.org> | 2015-04-16 10:28:32 +0000 |
commit | 85a8238181175de195158bf1554f530cd0f6e3f1 (patch) | |
tree | 72b0b33ece151dc9cdb2e7af36e8d554ec64350e /components/data_reduction_proxy | |
parent | 919dce4400651813d5ff6e8a85b944a5987adcb7 (diff) | |
download | chromium_src-85a8238181175de195158bf1554f530cd0f6e3f1.zip chromium_src-85a8238181175de195158bf1554f530cd0f6e3f1.tar.gz chromium_src-85a8238181175de195158bf1554f530cd0f6e3f1.tar.bz2 |
Revert "Speculative revert by sheriff"
This reverts commit 919dce4400651813d5ff6e8a85b944a5987adcb7.
BUG=None
TBR=akuegel
Review URL: https://codereview.chromium.org/1094553002
Cr-Commit-Position: refs/heads/master@{#325412}
Diffstat (limited to 'components/data_reduction_proxy')
10 files changed, 152 insertions, 144 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 9ee5108..e29759a 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,10 +11,14 @@ #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" @@ -46,9 +50,82 @@ 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, @@ -60,13 +137,11 @@ 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); } @@ -75,15 +150,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; @@ -256,9 +331,13 @@ void DataReductionProxyConfig::SetProxyConfig( if (enabled && !(alternative_enabled && !config_values_->alternative_fallback_allowed())) { - ui_task_runner_->PostTask( - FROM_HERE, base::Bind(&DataReductionProxyConfig::StartSecureProxyCheck, - base::Unretained(this))); + // 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))); } } @@ -322,16 +401,7 @@ void DataReductionProxyConfig::LogProxyState(bool enabled, void DataReductionProxyConfig::HandleSecureProxyCheckResponse( const std::string& response, const net::URLRequestStatus& status) { - 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) { + DCHECK(io_task_runner_->BelongsToCurrentThread()); if (event_store_) { event_store_->EndSecureProxyCheck(bound_net_log_, status.error()); } @@ -394,9 +464,13 @@ void DataReductionProxyConfig::OnIPAddressChanged() { return; } - ui_task_runner_->PostTask( - FROM_HERE, base::Bind(&DataReductionProxyConfig::StartSecureProxyCheck, - base::Unretained(this))); + // 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))); } } @@ -432,21 +506,21 @@ void DataReductionProxyConfig::RecordSecureProxyCheckFetchResult( SECURE_PROXY_CHECK_FETCH_RESULT_COUNT); } -void DataReductionProxyConfig::StartSecureProxyCheck() { - DCHECK(ui_task_runner_->BelongsToCurrentThread()); +void DataReductionProxyConfig::SecureProxyCheck( + const GURL& secure_proxy_check_url, + FetcherResponseCallback fetcher_callback) { + DCHECK(io_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()); - } - data_reduction_proxy_service_->SecureProxyCheck( - config_values_->secure_proxy_check_url(), - base::Bind(&DataReductionProxyConfig::HandleSecureProxyCheckResponse, - base::Unretained(this))); + if (event_store_) { + event_store_->BeginSecureProxyCheck( + bound_net_log_, config_values_->secure_proxy_check_url()); } + + 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 770c032..9acf691 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,6 +5,9 @@ #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" @@ -17,6 +20,8 @@ #include "net/proxy/proxy_config.h" #include "net/proxy/proxy_retry_info.h" +class GURL; + namespace base { class SingleThreadTaskRunner; class TimeDelta; @@ -25,6 +30,7 @@ class TimeDelta; namespace net { class HostPortPair; class NetLog; +class URLFetcher; class URLRequest; class URLRequestContextGetter; class URLRequestStatus; @@ -32,10 +38,14 @@ 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. @@ -75,16 +85,12 @@ 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); @@ -215,16 +221,16 @@ class DataReductionProxyConfig bool restricted, bool at_startup); - // Begins a secure proxy check to determine if the Data Reduction Proxy is - // permitted to use the HTTPS proxy servers. - void StartSecureProxyCheck(); + // 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); // 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(); @@ -246,6 +252,8 @@ 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_; @@ -259,10 +267,6 @@ 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 @@ -283,11 +287,6 @@ 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 f6e836c..dbbde52 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,7 +39,6 @@ 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 fba88ee..759b29c 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,6 +116,9 @@ 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 44746c1..7b61eed 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,13 +127,11 @@ 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(*service, SecureProxyCheck(_, _)) + EXPECT_CALL(*config(), SecureProxyCheck(_, _)) .Times(1) .WillRepeatedly(testing::WithArgs<1>( testing::Invoke(&responder, &TestResponder::ExecuteCallback))); @@ -161,9 +159,8 @@ class DataReductionProxyConfigTest : public testing::Test { scoped_ptr<DataReductionProxyParams> params) { params->EnableQuic(false); return make_scoped_ptr(new DataReductionProxyConfig( - test_context_->task_runner(), test_context_->task_runner(), - test_context_->net_log(), params.Pass(), test_context_->configurator(), - test_context_->event_store())); + 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 52340f7..9034bae 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_, ui_task_runner_, net_log, mutable_config.Pass(), - configurator_.get(), event_store_.get())); + io_task_runner_, net_log, mutable_config.Pass(), configurator_.get(), + event_store_.get())); } else { - config_.reset(new DataReductionProxyConfig( - io_task_runner_, ui_task_runner_, net_log, params.Pass(), - configurator_.get(), event_store_.get())); + config_.reset( + new DataReductionProxyConfig(io_task_runner_, net_log, params.Pass(), + configurator_.get(), event_store_.get())); } // It is safe to use base::Unretained here, since it gets executed @@ -113,7 +113,6 @@ 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 3c17aa2..1b90a14 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,9 +11,6 @@ #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 { @@ -109,47 +106,4 @@ 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 0f9aed7..ed39307 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,7 +14,6 @@ #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; @@ -25,16 +24,11 @@ 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; @@ -42,8 +36,7 @@ class DataReductionProxySettings; // Contains and initializes all Data Reduction Proxy objects that have a // lifetime based on the UI thread. -class DataReductionProxyService : public base::NonThreadSafe, - public net::URLFetcherDelegate { +class DataReductionProxyService : public base::NonThreadSafe { public: // The caller must ensure that |settings| and |request_context| remain alive // for the lifetime of the |DataReductionProxyService| instance. This instance @@ -56,7 +49,7 @@ class DataReductionProxyService : public base::NonThreadSafe, net::URLRequestContextGetter* request_context_getter, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner); - ~DataReductionProxyService() override; + virtual ~DataReductionProxyService(); // Sets the DataReductionProxyIOData weak pointer. void SetIOData(base::WeakPtr<DataReductionProxyIOData> io_data); @@ -67,12 +60,6 @@ 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( @@ -114,22 +101,9 @@ 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 0b404ad..1d64a4c 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,6 +194,18 @@ 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 7b2add4..4993ffe 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,9 +156,6 @@ 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)); }; |