Commit cdd8a239 authored by Antonio Gomes's avatar Antonio Gomes Committed by Commit Bot

[DRP] Remove BasicHTTPURLRequestContextGetter

In [1], DataReductionProxyConfigServiceClient [2] switched from using
URLFetcher to SimpleURLLoader for making URL requests.

During the discussion phase with tbansal and cduvall, it was mentioned
that the URLRequestContext specialization used by DataReductionProxyConfigServiceClient
was originally needed to obey two criterias:

(i) Use of SPDY and QUIC protocols is explicitly disabled;
(ii) Use of any proxies is also disabled.

Today, (i) isn't needed and (ii) can be obtained with a specific load
flag: net::LOAD_BYPASS_PROXY. Hence, the URLRequestContext specialization
(namely BasicHTTPURLRequestContextGetter) became unneeded, since (ii)
can be easily respected with the default network context.

This CL removes the left over BasicHTTPURLRequestContextGetter and
associated code.

[1] https://crrev.com/c/1274405
[2] components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service_client.cc

Bug=879784

Change-Id: Ib46fecbbe03c57f0fc9375cb8986da62d77bb525
Reviewed-on: https://chromium-review.googlesource.com/c/1284169Reviewed-by: default avatarrajendrant <rajendrant@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Cr-Commit-Position: refs/heads/master@{#600133}
parent a22250ff
......@@ -48,7 +48,6 @@
#include "net/url_request/url_fetcher_delegate.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#if defined(OS_ANDROID)
......@@ -208,8 +207,6 @@ DataReductionProxyConfig::~DataReductionProxyConfig() {
}
void DataReductionProxyConfig::InitializeOnIOThread(
const scoped_refptr<net::URLRequestContextGetter>&
basic_url_request_context_getter,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
NetworkPropertiesManager* manager) {
DCHECK(thread_checker_.CalledOnValidThread());
......
......@@ -37,7 +37,6 @@ class SingleThreadTaskRunner;
namespace net {
class ProxyServer;
class URLRequest;
class URLRequestContextGetter;
} // namespace net
namespace data_reduction_proxy {
......@@ -95,13 +94,9 @@ class DataReductionProxyConfig
~DataReductionProxyConfig() override;
// Performs initialization on the IO thread.
// |basic_url_request_context_getter| is the net::URLRequestContextGetter that
// disables the use of alternative protocols and proxies.
// |url_request_context_getter| is the default net::URLRequestContextGetter
// used for making URL requests.
// |url_loader_factory| is the network::URLLoaderFactory instance used for
// making URL requests. The requests disable the use of proxies.
void InitializeOnIOThread(
const scoped_refptr<net::URLRequestContextGetter>&
basic_url_request_context_getter,
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
NetworkPropertiesManager* manager);
......
......@@ -426,8 +426,7 @@ TEST_F(DataReductionProxyConfigTest, WarmupURL) {
NetworkPropertiesManager network_properties_manager(
base::DefaultClock::GetInstance(), test_context_->pref_service(),
test_context_->task_runner());
config.InitializeOnIOThread(test_context_->request_context_getter(),
test_context_->url_loader_factory(),
config.InitializeOnIOThread(test_context_->url_loader_factory(),
&network_properties_manager);
RunUntilIdle();
......
......@@ -39,58 +39,6 @@
namespace data_reduction_proxy {
// A |net::URLRequestContextGetter| which uses only vanilla HTTP/HTTPS for
// performing requests. This is used by the secure proxy check to prevent the
// use of SPDY and QUIC which may be used by the primary request contexts.
class BasicHTTPURLRequestContextGetter : public net::URLRequestContextGetter {
public:
BasicHTTPURLRequestContextGetter(
const std::string& user_agent,
const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner);
// Overridden from net::URLRequestContextGetter:
net::URLRequestContext* GetURLRequestContext() override;
scoped_refptr<base::SingleThreadTaskRunner> GetNetworkTaskRunner()
const override;
private:
~BasicHTTPURLRequestContextGetter() override;
scoped_refptr<base::SingleThreadTaskRunner> network_task_runner_;
std::unique_ptr<net::HttpUserAgentSettings> user_agent_settings_;
std::unique_ptr<net::URLRequestContext> url_request_context_;
DISALLOW_COPY_AND_ASSIGN(BasicHTTPURLRequestContextGetter);
};
BasicHTTPURLRequestContextGetter::BasicHTTPURLRequestContextGetter(
const std::string& user_agent,
const scoped_refptr<base::SingleThreadTaskRunner>& network_task_runner)
: network_task_runner_(network_task_runner),
user_agent_settings_(
new net::StaticHttpUserAgentSettings(std::string(), user_agent)) {
}
net::URLRequestContext*
BasicHTTPURLRequestContextGetter::GetURLRequestContext() {
if (!url_request_context_) {
net::URLRequestContextBuilder builder;
builder.set_proxy_resolution_service(net::ProxyResolutionService::CreateDirect());
builder.SetSpdyAndQuicEnabled(false, false);
url_request_context_ = builder.Build();
}
return url_request_context_.get();
}
scoped_refptr<base::SingleThreadTaskRunner>
BasicHTTPURLRequestContextGetter::GetNetworkTaskRunner() const {
return network_task_runner_;
}
BasicHTTPURLRequestContextGetter::~BasicHTTPURLRequestContextGetter() {
}
DataReductionProxyIOData::DataReductionProxyIOData(
Client client,
PrefService* prefs,
......@@ -107,8 +55,6 @@ DataReductionProxyIOData::DataReductionProxyIOData(
data_use_observer_(nullptr),
enabled_(enabled),
url_request_context_getter_(nullptr),
basic_url_request_context_getter_(
new BasicHTTPURLRequestContextGetter(user_agent, io_task_runner)),
channel_(channel),
effective_connection_type_(net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN),
weak_factory_(this) {
......@@ -212,8 +158,7 @@ void DataReductionProxyIOData::InitializeOnIOThread() {
auto url_loader_factory = network::SharedURLLoaderFactory::Create(
std::move(url_loader_factory_info_));
config_->InitializeOnIOThread(basic_url_request_context_getter_.get(),
url_loader_factory,
config_->InitializeOnIOThread(url_loader_factory,
network_properties_manager_.get());
bypass_stats_->InitializeOnIOThread();
proxy_delegate_->InitializeOnIOThread(this);
......
......@@ -291,10 +291,6 @@ class DataReductionProxyIOData {
// The net::URLRequestContextGetter used for making URL requests.
net::URLRequestContextGetter* url_request_context_getter_;
// A net::URLRequestContextGetter used for making secure proxy checks. It
// does not use alternate protocols.
scoped_refptr<net::URLRequestContextGetter> basic_url_request_context_getter_;
// The network::SharedURLLoaderFactoryInfo used for making URL requests.
std::unique_ptr<network::SharedURLLoaderFactoryInfo> url_loader_factory_info_;
......
......@@ -110,14 +110,6 @@ TEST_F(DataReductionProxyIODataTest, TestConstruction) {
false /* enabled */, std::string() /* user_agent */,
std::string() /* channel */));
// Check that the SimpleURLRequestContextGetter uses vanilla HTTP.
net::URLRequestContext* request_context =
io_data->basic_url_request_context_getter_->GetURLRequestContext();
const net::HttpNetworkSession::Params* http_params =
request_context->GetNetworkSessionParams();
EXPECT_FALSE(http_params->enable_http2);
EXPECT_FALSE(http_params->enable_quic);
// Check that io_data creates an interceptor. Such an interceptor is
// thoroughly tested by DataReductionProxyInterceptoTest.
std::unique_ptr<net::URLRequestInterceptor> interceptor =
......
......@@ -518,7 +518,6 @@ DataReductionProxyTestContext::Builder::Build() {
pref_service.get(), task_runner, std::move(config),
std::move(request_options), std::move(configurator),
test_network_connection_tracker, true /* enabled */));
io_data->SetSimpleURLRequestContextGetter(request_context_getter);
if (use_test_config_client_) {
test_context_flags |= USE_TEST_CONFIG_CLIENT;
......
......@@ -247,11 +247,6 @@ class TestDataReductionProxyIOData : public DataReductionProxyIOData {
proxy_delegate_ = std::move(proxy_delegate);
}
void SetSimpleURLRequestContextGetter(
const scoped_refptr<net::URLRequestContextGetter> context_getter) {
basic_url_request_context_getter_ = context_getter;
}
base::WeakPtr<DataReductionProxyIOData> GetWeakPtr() {
return weak_factory_.GetWeakPtr();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment