Commit f2b6eadf authored by Clark DuVall's avatar Clark DuVall Committed by Commit Bot

Disable data reduction proxy when network service is enabled

This also prevents any crashes if we remove the legacy URLRequestContext
getter in the network service.

Bug: 855621
Cq-Include-Trybots: luci.chromium.try:linux_mojo
Change-Id: Ie14b64b803c8563ecae355dc220c9e56d11b4e7b
Reviewed-on: https://chromium-review.googlesource.com/1176117Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Commit-Queue: Clark DuVall <cduvall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#583388}
parent b476a3a7
...@@ -82,6 +82,7 @@ ...@@ -82,6 +82,7 @@
#include "net/url_request/url_request_context_builder.h" #include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_intercepting_job_factory.h" #include "net/url_request/url_request_intercepting_job_factory.h"
#include "net/url_request/url_request_job_factory_impl.h" #include "net/url_request/url_request_job_factory_impl.h"
#include "services/network/public/cpp/features.h"
#include "services/network/public/cpp/shared_url_loader_factory.h" #include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/mojom/network_service.mojom.h" #include "services/network/public/mojom/network_service.mojom.h"
#include "storage/browser/quota/special_storage_policy.h" #include "storage/browser/quota/special_storage_policy.h"
...@@ -247,7 +248,11 @@ ProfileImplIOData::Handle::CreateMainRequestContextGetter( ...@@ -247,7 +248,11 @@ ProfileImplIOData::Handle::CreateMainRequestContextGetter(
DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile_) DataReductionProxyChromeSettingsFactory::GetForBrowserContext(profile_)
->InitDataReductionProxySettings( ->InitDataReductionProxySettings(
io_data_->data_reduction_proxy_io_data(), profile_->GetPrefs(), io_data_->data_reduction_proxy_io_data(), profile_->GetPrefs(),
main_request_context_getter_.get(), // TODO(crbug.com/721403) Switch DRP to mojo. For now it is disabled
// with network service.
base::FeatureList::IsEnabled(network::features::kNetworkService)
? nullptr
: main_request_context_getter_.get(),
content::BrowserContext::GetDefaultStoragePartition(profile_) content::BrowserContext::GetDefaultStoragePartition(profile_)
->GetURLLoaderFactoryForBrowserProcess(), ->GetURLLoaderFactoryForBrowserProcess(),
std::move(store), std::move(store),
......
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include "net/traffic_annotation/network_traffic_annotation.h" #include "net/traffic_annotation/network_traffic_annotation.h"
#include "net/url_request/url_fetcher.h" #include "net/url_request/url_fetcher.h"
#include "net/url_request/url_request_status.h" #include "net/url_request/url_request_status.h"
#include "services/network/public/cpp/features.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "net/android/network_library.h" #include "net/android/network_library.h"
...@@ -221,7 +222,11 @@ DataReductionProxyConfigServiceClient::CalculateNextConfigRefreshTime( ...@@ -221,7 +222,11 @@ DataReductionProxyConfigServiceClient::CalculateNextConfigRefreshTime(
void DataReductionProxyConfigServiceClient::InitializeOnIOThread( void DataReductionProxyConfigServiceClient::InitializeOnIOThread(
net::URLRequestContextGetter* url_request_context_getter) { net::URLRequestContextGetter* url_request_context_getter) {
DCHECK(url_request_context_getter); // TODO(crbug.com/721403): DRP is disabled with network service enabled. When
// DRP is switched to mojo, we won't need URLRequestContext.
if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
DCHECK(url_request_context_getter);
}
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// It is okay to use Unretained here because |app_status_listener| would be // It is okay to use Unretained here because |app_status_listener| would be
// destroyed before |this|. // destroyed before |this|.
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_builder.h" #include "net/url_request/url_request_context_builder.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "services/network/public/cpp/features.h"
namespace data_reduction_proxy { namespace data_reduction_proxy {
...@@ -297,7 +298,12 @@ DataReductionProxyIOData::CreateProxyDelegate() const { ...@@ -297,7 +298,12 @@ DataReductionProxyIOData::CreateProxyDelegate() const {
// Bug http://crbug/488190. // Bug http://crbug/488190.
void DataReductionProxyIOData::SetProxyPrefs(bool enabled, bool at_startup) { void DataReductionProxyIOData::SetProxyPrefs(bool enabled, bool at_startup) {
DCHECK(io_task_runner_->BelongsToCurrentThread()); DCHECK(io_task_runner_->BelongsToCurrentThread());
DCHECK(url_request_context_getter_->GetURLRequestContext()->proxy_resolution_service()); // TODO(crbug.com/721403): DRP is disabled with network service enabled. When
// DRP is switched to mojo, we won't need URLRequestContext.
if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
DCHECK(url_request_context_getter_->GetURLRequestContext()
->proxy_resolution_service());
}
enabled_ = enabled; enabled_ = enabled;
config_->SetProxyConfig(enabled, at_startup); config_->SetProxyConfig(enabled, at_startup);
if (config_client_) { if (config_client_) {
...@@ -308,9 +314,14 @@ void DataReductionProxyIOData::SetProxyPrefs(bool enabled, bool at_startup) { ...@@ -308,9 +314,14 @@ void DataReductionProxyIOData::SetProxyPrefs(bool enabled, bool at_startup) {
// If Data Saver is disabled, reset data reduction proxy state. // If Data Saver is disabled, reset data reduction proxy state.
if (!enabled) { if (!enabled) {
net::ProxyResolutionService* proxy_resolution_service = // TODO(crbug.com/721403): Make DRP work with network service.
url_request_context_getter_->GetURLRequestContext()->proxy_resolution_service(); if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
proxy_resolution_service->ClearBadProxiesCache(); net::ProxyResolutionService* proxy_resolution_service =
url_request_context_getter_->GetURLRequestContext()
->proxy_resolution_service();
proxy_resolution_service->ClearBadProxiesCache();
}
bypass_stats_->ClearRequestCounts(); bypass_stats_->ClearRequestCounts();
bypass_stats_->NotifyUnavailabilityIfChanged(); bypass_stats_->NotifyUnavailabilityIfChanged();
} }
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "components/prefs/pref_member.h" #include "components/prefs/pref_member.h"
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
#include "services/network/public/cpp/features.h"
namespace { namespace {
...@@ -114,6 +115,10 @@ void DataReductionProxySettings::SetCallbackToRegisterSyntheticFieldTrial( ...@@ -114,6 +115,10 @@ void DataReductionProxySettings::SetCallbackToRegisterSyntheticFieldTrial(
} }
bool DataReductionProxySettings::IsDataReductionProxyEnabled() const { bool DataReductionProxySettings::IsDataReductionProxyEnabled() const {
// TODO(crbug.com/721403): Make DRP work with network service.
if (base::FeatureList::IsEnabled(network::features::kNetworkService))
return false;
if (spdy_proxy_auth_enabled_.GetPrefName().empty()) if (spdy_proxy_auth_enabled_.GetPrefName().empty())
return false; return false;
return spdy_proxy_auth_enabled_.GetValue() || return spdy_proxy_auth_enabled_.GetValue() ||
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "net/url_request/url_request_status.h" #include "net/url_request/url_request_status.h"
#include "services/network/public/cpp/features.h"
namespace data_reduction_proxy { namespace data_reduction_proxy {
...@@ -34,7 +35,11 @@ WarmupURLFetcher::WarmupURLFetcher( ...@@ -34,7 +35,11 @@ WarmupURLFetcher::WarmupURLFetcher(
url_request_context_getter_(url_request_context_getter), url_request_context_getter_(url_request_context_getter),
callback_(callback), callback_(callback),
get_http_rtt_callback_(get_http_rtt_callback) { get_http_rtt_callback_(get_http_rtt_callback) {
DCHECK(url_request_context_getter_); // TODO(crbug.com/721403): DRP is disabled with network service enabled. When
// DRP is switched to mojo, we won't need URLRequestContext.
if (!base::FeatureList::IsEnabled(network::features::kNetworkService)) {
DCHECK(url_request_context_getter_);
}
} }
WarmupURLFetcher::~WarmupURLFetcher() {} WarmupURLFetcher::~WarmupURLFetcher() {}
......
...@@ -185,6 +185,9 @@ ...@@ -185,6 +185,9 @@
# Requires checking Origin headers on requests made after extension unload. # Requires checking Origin headers on requests made after extension unload.
-ExtensionUnloadBrowserTest.UnloadWithContentScripts -ExtensionUnloadBrowserTest.UnloadWithContentScripts
# https://crbug.com/721403
-ContextMenuBrowserTest.DataSaverOpenOrigImageInNewTab
# NOTE: if adding an exclusion for an existing failure (e.g. additional test for # NOTE: if adding an exclusion for an existing failure (e.g. additional test for
# feature X that is already not working), please add it beside the existing # feature X that is already not working), please add it beside the existing
# failures. Otherwise please reach out to network-service-dev@. # failures. Otherwise please reach out to network-service-dev@.
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