Commit a0ad227f authored by jeremyim's avatar jeremyim Committed by Commit bot

Remove BooleanPrefMember usage from Data Reduction Proxy IO classes.

The UI objects (specifically DataReductionProxySettings) already creates
a BooleanPrefMember for kDataReductionProxyEnabled and checks for changes
on it, then propagates this information to DataReductionProxyIOData via
DataReductionProxyIOData::SetProxyPrefs.

It also negates the need to pass a BooleanPrefMember to BypassStats when
ultimately all we care about is the boolean value.

BUG=472290

Review URL: https://codereview.chromium.org/1057473003

Cr-Commit-Position: refs/heads/master@{#327138}
parent 9313fe91
...@@ -162,6 +162,7 @@ void AwBrowserContext::PreMainMessageLoopRun() { ...@@ -162,6 +162,7 @@ void AwBrowserContext::PreMainMessageLoopRun() {
url_request_context_getter_->GetNetLog(), url_request_context_getter_->GetNetLog(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
false /* enable */,
false /* enable_quic */, false /* enable_quic */,
GetUserAgent())); GetUserAgent()));
data_reduction_proxy_settings_.reset( data_reduction_proxy_settings_.reset(
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h" #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_io_data.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h" #include "chrome/browser/net/spdyproxy/data_reduction_proxy_chrome_settings.h"
#include "chrome/common/chrome_content_client.h" #include "chrome/common/chrome_content_client.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
#include "base/android/build_info.h" #include "base/android/build_info.h"
...@@ -49,12 +51,16 @@ CreateDataReductionProxyChromeIOData( ...@@ -49,12 +51,16 @@ CreateDataReductionProxyChromeIOData(
} }
#endif #endif
bool enabled = prefs->GetBoolean(
data_reduction_proxy::prefs::kDataReductionProxyEnabled) ||
data_reduction_proxy::DataReductionProxyParams::
ShouldForceEnableDataReductionProxy();
scoped_ptr<data_reduction_proxy::DataReductionProxyIOData> scoped_ptr<data_reduction_proxy::DataReductionProxyIOData>
data_reduction_proxy_io_data( data_reduction_proxy_io_data(
new data_reduction_proxy::DataReductionProxyIOData( new data_reduction_proxy::DataReductionProxyIOData(
DataReductionProxyChromeSettings::GetClient(), flags, net_log, DataReductionProxyChromeSettings::GetClient(), flags, net_log,
io_task_runner, ui_task_runner, enable_quic, GetUserAgent())); io_task_runner, ui_task_runner, enabled, enable_quic,
data_reduction_proxy_io_data->InitOnUIThread(prefs); GetUserAgent()));
#if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING) #if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService> scoped_ptr<data_reduction_proxy::ContentDataReductionProxyDebugUIService>
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "base/callback.h" #include "base/callback.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/metrics/sparse_histogram.h" #include "base/metrics/sparse_histogram.h"
#include "base/prefs/pref_member.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_tamper_detection.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_tamper_detection.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
...@@ -170,7 +169,7 @@ DataReductionProxyBypassStats::GetBypassType() const { ...@@ -170,7 +169,7 @@ DataReductionProxyBypassStats::GetBypassType() const {
void DataReductionProxyBypassStats::RecordBytesHistograms( void DataReductionProxyBypassStats::RecordBytesHistograms(
const net::URLRequest& request, const net::URLRequest& request,
const BooleanPrefMember& data_reduction_proxy_enabled, bool data_reduction_proxy_enabled,
const net::ProxyConfig& data_reduction_proxy_config) { const net::ProxyConfig& data_reduction_proxy_config) {
RecordBypassedBytesHistograms(request, data_reduction_proxy_enabled, RecordBypassedBytesHistograms(request, data_reduction_proxy_enabled,
data_reduction_proxy_config); data_reduction_proxy_config);
...@@ -226,12 +225,12 @@ void DataReductionProxyBypassStats::OnConnectComplete( ...@@ -226,12 +225,12 @@ void DataReductionProxyBypassStats::OnConnectComplete(
void DataReductionProxyBypassStats::RecordBypassedBytesHistograms( void DataReductionProxyBypassStats::RecordBypassedBytesHistograms(
const net::URLRequest& request, const net::URLRequest& request,
const BooleanPrefMember& data_reduction_proxy_enabled, bool data_reduction_proxy_enabled,
const net::ProxyConfig& data_reduction_proxy_config) { const net::ProxyConfig& data_reduction_proxy_config) {
int64 content_length = request.received_response_content_length(); int64 content_length = request.received_response_content_length();
// Only record histograms when the data reduction proxy is enabled. // Only record histograms when the data reduction proxy is enabled.
if (!data_reduction_proxy_enabled.GetValue()) if (!data_reduction_proxy_enabled)
return; return;
// TODO(bengr): Add histogram(s) for byte counts of unsupported schemes, e.g., // TODO(bengr): Add histogram(s) for byte counts of unsupported schemes, e.g.,
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_BYPASS_STATS_H_ #define COMPONENTS_DATA_REDUCTION_PROXY_CORE_BROWSER_DATA_REDUCTION_PROXY_BYPASS_STATS_H_
#include "base/callback.h" #include "base/callback.h"
#include "base/prefs/pref_member.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_headers.h"
#include "net/base/host_port_pair.h" #include "net/base/host_port_pair.h"
#include "net/base/network_change_notifier.h" #include "net/base/network_change_notifier.h"
...@@ -68,7 +67,7 @@ class DataReductionProxyBypassStats ...@@ -68,7 +67,7 @@ class DataReductionProxyBypassStats
// completed URLRequest |request|. // completed URLRequest |request|.
void RecordBytesHistograms( void RecordBytesHistograms(
const net::URLRequest& request, const net::URLRequest& request,
const BooleanPrefMember& data_reduction_proxy_enabled, bool data_reduction_proxy_enabled,
const net::ProxyConfig& data_reduction_proxy_config); const net::ProxyConfig& data_reduction_proxy_config);
// Called by |ChromeNetworkDelegate| when a proxy is put into the bad proxy // Called by |ChromeNetworkDelegate| when a proxy is put into the bad proxy
...@@ -104,7 +103,7 @@ class DataReductionProxyBypassStats ...@@ -104,7 +103,7 @@ class DataReductionProxyBypassStats
// tells us the state of the kDataReductionProxyEnabled preference. // tells us the state of the kDataReductionProxyEnabled preference.
void RecordBypassedBytesHistograms( void RecordBypassedBytesHistograms(
const net::URLRequest& request, const net::URLRequest& request,
const BooleanPrefMember& data_reduction_proxy_enabled, bool data_reduction_proxy_enabled,
const net::ProxyConfig& data_reduction_proxy_config); const net::ProxyConfig& data_reduction_proxy_config);
// Records UMA of the number of response bytes of responses that are expected // Records UMA of the number of response bytes of responses that are expected
......
...@@ -5,11 +5,8 @@ ...@@ -5,11 +5,8 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/prefs/pref_member.h"
#include "base/single_thread_task_runner.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_protocol.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_compression_stats.h"
...@@ -93,13 +90,14 @@ DataReductionProxyIOData::DataReductionProxyIOData( ...@@ -93,13 +90,14 @@ DataReductionProxyIOData::DataReductionProxyIOData(
net::NetLog* net_log, net::NetLog* net_log,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
bool enabled,
bool enable_quic, bool enable_quic,
const std::string& user_agent) const std::string& user_agent)
: client_(client), : client_(client),
net_log_(net_log), net_log_(net_log),
io_task_runner_(io_task_runner), io_task_runner_(io_task_runner),
ui_task_runner_(ui_task_runner), ui_task_runner_(ui_task_runner),
shutdown_on_ui_(false), enabled_(enabled),
url_request_context_getter_(nullptr), url_request_context_getter_(nullptr),
basic_url_request_context_getter_( basic_url_request_context_getter_(
new BasicHTTPURLRequestContextGetter(user_agent, io_task_runner)), new BasicHTTPURLRequestContextGetter(user_agent, io_task_runner)),
...@@ -148,26 +146,14 @@ DataReductionProxyIOData::DataReductionProxyIOData( ...@@ -148,26 +146,14 @@ DataReductionProxyIOData::DataReductionProxyIOData(
} }
DataReductionProxyIOData::DataReductionProxyIOData() DataReductionProxyIOData::DataReductionProxyIOData()
: shutdown_on_ui_(false), : url_request_context_getter_(nullptr), weak_factory_(this) {
url_request_context_getter_(nullptr),
weak_factory_(this) {
} }
DataReductionProxyIOData::~DataReductionProxyIOData() { DataReductionProxyIOData::~DataReductionProxyIOData() {
DCHECK(shutdown_on_ui_);
}
void DataReductionProxyIOData::InitOnUIThread(PrefService* pref_service) {
DCHECK(ui_task_runner_->BelongsToCurrentThread());
enabled_.Init(prefs::kDataReductionProxyEnabled, pref_service);
enabled_.MoveToThread(io_task_runner_);
} }
void DataReductionProxyIOData::ShutdownOnUIThread() { void DataReductionProxyIOData::ShutdownOnUIThread() {
DCHECK(!shutdown_on_ui_);
DCHECK(ui_task_runner_->BelongsToCurrentThread()); DCHECK(ui_task_runner_->BelongsToCurrentThread());
enabled_.Destroy();
shutdown_on_ui_ = true;
} }
void DataReductionProxyIOData::SetDataReductionProxyService( void DataReductionProxyIOData::SetDataReductionProxyService(
...@@ -197,9 +183,7 @@ void DataReductionProxyIOData::InitializeOnIOThread() { ...@@ -197,9 +183,7 @@ void DataReductionProxyIOData::InitializeOnIOThread() {
bool DataReductionProxyIOData::IsEnabled() const { bool DataReductionProxyIOData::IsEnabled() const {
DCHECK(io_task_runner_->BelongsToCurrentThread()); DCHECK(io_task_runner_->BelongsToCurrentThread());
return enabled_.GetValue() || return enabled_;
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableDataReductionProxy);
} }
void DataReductionProxyIOData::RetrieveConfig() { void DataReductionProxyIOData::RetrieveConfig() {
...@@ -225,7 +209,7 @@ DataReductionProxyIOData::CreateNetworkDelegate( ...@@ -225,7 +209,7 @@ DataReductionProxyIOData::CreateNetworkDelegate(
wrapped_network_delegate.Pass(), config_.get(), wrapped_network_delegate.Pass(), config_.get(),
request_options_.get(), configurator_.get())); request_options_.get(), configurator_.get()));
if (track_proxy_bypass_statistics) if (track_proxy_bypass_statistics)
network_delegate->InitIODataAndUMA(this, &enabled_, bypass_stats_.get()); network_delegate->InitIODataAndUMA(this, bypass_stats_.get());
return network_delegate.Pass(); return network_delegate.Pass();
} }
...@@ -233,6 +217,7 @@ void DataReductionProxyIOData::SetProxyPrefs(bool enabled, ...@@ -233,6 +217,7 @@ void DataReductionProxyIOData::SetProxyPrefs(bool enabled,
bool alternative_enabled, bool alternative_enabled,
bool at_startup) { bool at_startup) {
DCHECK(io_task_runner_->BelongsToCurrentThread()); DCHECK(io_task_runner_->BelongsToCurrentThread());
enabled_ = enabled;
config_->SetProxyConfig(enabled, alternative_enabled, at_startup); config_->SetProxyConfig(enabled, alternative_enabled, at_startup);
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/prefs/pref_member.h" #include "base/single_thread_task_runner.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_debug_ui_service.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_debug_ui_service.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_delegate.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_metrics.h"
...@@ -42,23 +42,21 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate { ...@@ -42,23 +42,21 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate {
public: public:
// Constructs a DataReductionProxyIOData object. |param_flags| is used to // Constructs a DataReductionProxyIOData object. |param_flags| is used to
// set information about the DNS names used by the proxy, and allowable // set information about the DNS names used by the proxy, and allowable
// configurations. // configurations. |enabled| sets the initial state of the Data Reduction
// Proxy.
DataReductionProxyIOData( DataReductionProxyIOData(
const Client& client, const Client& client,
int param_flags, int param_flags,
net::NetLog* net_log, net::NetLog* net_log,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, scoped_refptr<base::SingleThreadTaskRunner> io_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
bool enabled,
bool enable_quic, bool enable_quic,
const std::string& user_agent); const std::string& user_agent);
virtual ~DataReductionProxyIOData(); virtual ~DataReductionProxyIOData();
// Initializes preferences, including a preference to track whether the // Performs UI thread specific shutdown logic.
// Data Reduction Proxy is enabled.
void InitOnUIThread(PrefService* pref_service);
// Destroys the statistics preferences.
void ShutdownOnUIThread(); void ShutdownOnUIThread();
// Sets the Data Reduction Proxy service after it has been created. // Sets the Data Reduction Proxy service after it has been created.
...@@ -205,12 +203,9 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate { ...@@ -205,12 +203,9 @@ class DataReductionProxyIOData : public DataReductionProxyEventStorageDelegate {
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
// Used // Whether the Data Reduction Proxy has been enabled or not by the user. In
bool shutdown_on_ui_; // practice, this can be overridden by the command line.
bool enabled_;
// Preference that determines if the Data Reduction Proxy has been enabled
// by the user. In practice, this can be overridden by the command line.
BooleanPrefMember enabled_;
// The net::URLRequestContextGetter used for making URL requests. // The net::URLRequestContextGetter used for making URL requests.
net::URLRequestContextGetter* url_request_context_getter_; net::URLRequestContextGetter* url_request_context_getter_;
......
...@@ -94,8 +94,8 @@ class DataReductionProxyIODataTest : public testing::Test { ...@@ -94,8 +94,8 @@ class DataReductionProxyIODataTest : public testing::Test {
TEST_F(DataReductionProxyIODataTest, TestConstruction) { TEST_F(DataReductionProxyIODataTest, TestConstruction) {
scoped_ptr<DataReductionProxyIOData> io_data(new DataReductionProxyIOData( scoped_ptr<DataReductionProxyIOData> io_data(new DataReductionProxyIOData(
Client::UNKNOWN, DataReductionProxyParams::kAllowed, net_log(), Client::UNKNOWN, DataReductionProxyParams::kAllowed, net_log(),
message_loop_proxy(), message_loop_proxy(), false /* enable_quic */, message_loop_proxy(), message_loop_proxy(), false /* enabled */,
std::string() /* user_agent */)); false /* enable_quic */, std::string() /* user_agent */));
// Check that the SimpleURLRequestContextGetter uses vanilla HTTP. // Check that the SimpleURLRequestContextGetter uses vanilla HTTP.
net::URLRequestContext* request_context = net::URLRequestContext* request_context =
...@@ -141,9 +141,6 @@ TEST_F(DataReductionProxyIODataTest, TestConstruction) { ...@@ -141,9 +141,6 @@ TEST_F(DataReductionProxyIODataTest, TestConstruction) {
true); true);
EXPECT_NE(nullptr, io_data->bypass_stats()); EXPECT_NE(nullptr, io_data->bypass_stats());
// The Data Reduction Proxy isn't actually enabled here.
io_data->InitOnUIThread(prefs());
EXPECT_FALSE(io_data->IsEnabled());
io_data->ShutdownOnUIThread(); io_data->ShutdownOnUIThread();
} }
......
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "base/strings/string_number_conversions.h" #include "base/strings/string_number_conversions.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_bypass_stats.h"
...@@ -81,7 +80,6 @@ DataReductionProxyNetworkDelegate::DataReductionProxyNetworkDelegate( ...@@ -81,7 +80,6 @@ DataReductionProxyNetworkDelegate::DataReductionProxyNetworkDelegate(
: LayeredNetworkDelegate(network_delegate.Pass()), : LayeredNetworkDelegate(network_delegate.Pass()),
received_content_length_(0), received_content_length_(0),
original_content_length_(0), original_content_length_(0),
data_reduction_proxy_enabled_(nullptr),
data_reduction_proxy_config_(config), data_reduction_proxy_config_(config),
data_reduction_proxy_bypass_stats_(nullptr), data_reduction_proxy_bypass_stats_(nullptr),
data_reduction_proxy_request_options_(request_options), data_reduction_proxy_request_options_(request_options),
...@@ -96,12 +94,9 @@ DataReductionProxyNetworkDelegate::~DataReductionProxyNetworkDelegate() { ...@@ -96,12 +94,9 @@ DataReductionProxyNetworkDelegate::~DataReductionProxyNetworkDelegate() {
void DataReductionProxyNetworkDelegate::InitIODataAndUMA( void DataReductionProxyNetworkDelegate::InitIODataAndUMA(
DataReductionProxyIOData* io_data, DataReductionProxyIOData* io_data,
BooleanPrefMember* data_reduction_proxy_enabled,
DataReductionProxyBypassStats* bypass_stats) { DataReductionProxyBypassStats* bypass_stats) {
DCHECK(data_reduction_proxy_enabled);
DCHECK(bypass_stats); DCHECK(bypass_stats);
data_reduction_proxy_io_data_ = io_data; data_reduction_proxy_io_data_ = io_data;
data_reduction_proxy_enabled_ = data_reduction_proxy_enabled;
data_reduction_proxy_bypass_stats_ = bypass_stats; data_reduction_proxy_bypass_stats_ = bypass_stats;
} }
...@@ -191,10 +186,9 @@ void DataReductionProxyNetworkDelegate::OnCompletedInternal( ...@@ -191,10 +186,9 @@ void DataReductionProxyNetworkDelegate::OnCompletedInternal(
original_content_length, original_content_length,
freshness_lifetime); freshness_lifetime);
if (data_reduction_proxy_enabled_ && if (data_reduction_proxy_io_data_ && data_reduction_proxy_bypass_stats_) {
data_reduction_proxy_bypass_stats_) {
data_reduction_proxy_bypass_stats_->RecordBytesHistograms( data_reduction_proxy_bypass_stats_->RecordBytesHistograms(
*request, *data_reduction_proxy_enabled_, *request, data_reduction_proxy_io_data_->IsEnabled(),
configurator_->GetProxyConfig()); configurator_->GetProxyConfig());
} }
DVLOG(2) << __FUNCTION__ DVLOG(2) << __FUNCTION__
...@@ -210,10 +204,10 @@ void DataReductionProxyNetworkDelegate::AccumulateContentLength( ...@@ -210,10 +204,10 @@ void DataReductionProxyNetworkDelegate::AccumulateContentLength(
DataReductionProxyRequestType request_type) { DataReductionProxyRequestType request_type) {
DCHECK_GE(received_content_length, 0); DCHECK_GE(received_content_length, 0);
DCHECK_GE(original_content_length, 0); DCHECK_GE(original_content_length, 0);
if (data_reduction_proxy_enabled_) { if (data_reduction_proxy_io_data_) {
data_reduction_proxy_io_data_->UpdateContentLengths( data_reduction_proxy_io_data_->UpdateContentLengths(
received_content_length, original_content_length, received_content_length, original_content_length,
data_reduction_proxy_enabled_->GetValue(), request_type); data_reduction_proxy_io_data_->IsEnabled(), request_type);
} }
received_content_length_ += received_content_length; received_content_length_ += received_content_length;
original_content_length_ += original_content_length; original_content_length_ += original_content_length;
......
...@@ -13,12 +13,7 @@ ...@@ -13,12 +13,7 @@
#include "net/base/layered_network_delegate.h" #include "net/base/layered_network_delegate.h"
#include "net/proxy/proxy_retry_info.h" #include "net/proxy/proxy_retry_info.h"
template<class T> class PrefMember;
typedef PrefMember<bool> BooleanPrefMember;
class GURL; class GURL;
class PrefService;
namespace net { namespace net {
class HttpResponseHeaders; class HttpResponseHeaders;
...@@ -64,7 +59,6 @@ class DataReductionProxyNetworkDelegate : public net::LayeredNetworkDelegate { ...@@ -64,7 +59,6 @@ class DataReductionProxyNetworkDelegate : public net::LayeredNetworkDelegate {
// report UMA. // report UMA.
void InitIODataAndUMA( void InitIODataAndUMA(
DataReductionProxyIOData* io_data, DataReductionProxyIOData* io_data,
BooleanPrefMember* data_reduction_proxy_enabled,
DataReductionProxyBypassStats* bypass_stats); DataReductionProxyBypassStats* bypass_stats);
// Creates a |Value| summary of the state of the network session. The caller // Creates a |Value| summary of the state of the network session. The caller
...@@ -117,9 +111,6 @@ class DataReductionProxyNetworkDelegate : public net::LayeredNetworkDelegate { ...@@ -117,9 +111,6 @@ class DataReductionProxyNetworkDelegate : public net::LayeredNetworkDelegate {
// Total original size of all content before it was transferred. // Total original size of all content before it was transferred.
int64 original_content_length_; int64 original_content_length_;
// Weak, owned by our owner.
BooleanPrefMember* data_reduction_proxy_enabled_;
// All raw Data Reduction Proxy pointers must outlive |this|. // All raw Data Reduction Proxy pointers must outlive |this|.
DataReductionProxyConfig* data_reduction_proxy_config_; DataReductionProxyConfig* data_reduction_proxy_config_;
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h" #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_service.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_params.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_pref_names.h"
#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h" #include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
...@@ -21,13 +22,6 @@ namespace { ...@@ -21,13 +22,6 @@ namespace {
const char kUMAProxyStartupStateHistogram[] = const char kUMAProxyStartupStateHistogram[] =
"DataReductionProxy.StartupState"; "DataReductionProxy.StartupState";
bool IsEnabledOnCommandLine() {
const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess();
return command_line.HasSwitch(
data_reduction_proxy::switches::kEnableDataReductionProxy);
}
bool IsLoFiEnabledOnCommandLine() { bool IsLoFiEnabledOnCommandLine() {
const base::CommandLine& command_line = const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
...@@ -116,7 +110,8 @@ void DataReductionProxySettings::SetCallbackToRegisterSyntheticFieldTrial( ...@@ -116,7 +110,8 @@ void DataReductionProxySettings::SetCallbackToRegisterSyntheticFieldTrial(
} }
bool DataReductionProxySettings::IsDataReductionProxyEnabled() const { bool DataReductionProxySettings::IsDataReductionProxyEnabled() const {
return spdy_proxy_auth_enabled_.GetValue() || IsEnabledOnCommandLine(); return spdy_proxy_auth_enabled_.GetValue() ||
DataReductionProxyParams::ShouldForceEnableDataReductionProxy();
} }
bool DataReductionProxySettings::CanUseDataReductionProxy( bool DataReductionProxySettings::CanUseDataReductionProxy(
......
...@@ -177,7 +177,8 @@ TestDataReductionProxyIOData::TestDataReductionProxyIOData( ...@@ -177,7 +177,8 @@ TestDataReductionProxyIOData::TestDataReductionProxyIOData(
scoped_ptr<DataReductionProxyEventCreator> event_creator, scoped_ptr<DataReductionProxyEventCreator> event_creator,
scoped_ptr<DataReductionProxyRequestOptions> request_options, scoped_ptr<DataReductionProxyRequestOptions> request_options,
scoped_ptr<DataReductionProxyConfigurator> configurator, scoped_ptr<DataReductionProxyConfigurator> configurator,
scoped_ptr<DataReductionProxyConfigServiceClient> config_client) scoped_ptr<DataReductionProxyConfigServiceClient> config_client,
bool enabled)
: DataReductionProxyIOData() { : DataReductionProxyIOData() {
io_task_runner_ = task_runner; io_task_runner_ = task_runner;
ui_task_runner_ = task_runner; ui_task_runner_ = task_runner;
...@@ -191,10 +192,10 @@ TestDataReductionProxyIOData::TestDataReductionProxyIOData( ...@@ -191,10 +192,10 @@ TestDataReductionProxyIOData::TestDataReductionProxyIOData(
base::Unretained(this)))); base::Unretained(this))));
io_task_runner_ = task_runner; io_task_runner_ = task_runner;
ui_task_runner_ = task_runner; ui_task_runner_ = task_runner;
enabled_ = enabled;
} }
TestDataReductionProxyIOData::~TestDataReductionProxyIOData() { TestDataReductionProxyIOData::~TestDataReductionProxyIOData() {
shutdown_on_ui_ = true;
} }
DataReductionProxyTestContext::Builder::Builder() DataReductionProxyTestContext::Builder::Builder()
...@@ -386,8 +387,8 @@ DataReductionProxyTestContext::Builder::Build() { ...@@ -386,8 +387,8 @@ DataReductionProxyTestContext::Builder::Build() {
scoped_ptr<TestDataReductionProxyIOData> io_data( scoped_ptr<TestDataReductionProxyIOData> io_data(
new TestDataReductionProxyIOData( new TestDataReductionProxyIOData(
task_runner, config.Pass(), event_creator.Pass(), task_runner, config.Pass(), event_creator.Pass(),
request_options.Pass(), configurator.Pass(), config_client.Pass())); request_options.Pass(), configurator.Pass(), config_client.Pass(),
io_data->InitOnUIThread(pref_service.get()); true /* enabled */));
io_data->SetSimpleURLRequestContextGetter(request_context_getter); io_data->SetSimpleURLRequestContextGetter(request_context_getter);
scoped_ptr<DataReductionProxyTestContext> test_context( scoped_ptr<DataReductionProxyTestContext> test_context(
......
...@@ -167,7 +167,8 @@ class TestDataReductionProxyIOData : public DataReductionProxyIOData { ...@@ -167,7 +167,8 @@ class TestDataReductionProxyIOData : public DataReductionProxyIOData {
scoped_ptr<DataReductionProxyEventCreator> event_creator, scoped_ptr<DataReductionProxyEventCreator> event_creator,
scoped_ptr<DataReductionProxyRequestOptions> request_options, scoped_ptr<DataReductionProxyRequestOptions> request_options,
scoped_ptr<DataReductionProxyConfigurator> configurator, scoped_ptr<DataReductionProxyConfigurator> configurator,
scoped_ptr<DataReductionProxyConfigServiceClient> config_client); scoped_ptr<DataReductionProxyConfigServiceClient> config_client,
bool enabled);
~TestDataReductionProxyIOData() override; ~TestDataReductionProxyIOData() override;
DataReductionProxyConfigurator* configurator() const { DataReductionProxyConfigurator* configurator() const {
......
...@@ -102,7 +102,6 @@ bool DataReductionProxyParams::IsIncludedInAndroidOnePromoFieldTrial( ...@@ -102,7 +102,6 @@ bool DataReductionProxyParams::IsIncludedInAndroidOnePromoFieldTrial(
bool DataReductionProxyParams::IsLoFiEnabled() { bool DataReductionProxyParams::IsLoFiEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch( return base::CommandLine::ForCurrentProcess()->HasSwitch(
data_reduction_proxy::switches::kEnableDataReductionProxyLoFi); data_reduction_proxy::switches::kEnableDataReductionProxyLoFi);
} }
//static //static
...@@ -136,6 +135,12 @@ bool DataReductionProxyParams::IsConfigClientEnabled() { ...@@ -136,6 +135,12 @@ bool DataReductionProxyParams::IsConfigClientEnabled() {
data_reduction_proxy::switches::kEnableDataReductionProxyConfigClient); data_reduction_proxy::switches::kEnableDataReductionProxyConfigClient);
} }
// static
bool DataReductionProxyParams::ShouldForceEnableDataReductionProxy() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
data_reduction_proxy::switches::kEnableDataReductionProxy);
}
void DataReductionProxyParams::EnableQuic(bool enable) { void DataReductionProxyParams::EnableQuic(bool enable) {
quic_enabled_ = enable; quic_enabled_ = enable;
DCHECK(!quic_enabled_ || IsIncludedInQuicFieldTrial()); DCHECK(!quic_enabled_ || IsIncludedInQuicFieldTrial());
......
...@@ -116,6 +116,10 @@ class DataReductionProxyParams : public DataReductionProxyConfigValues { ...@@ -116,6 +116,10 @@ class DataReductionProxyParams : public DataReductionProxyConfigValues {
// Returns true if the Data Reduction Proxy config client should be used. // Returns true if the Data Reduction Proxy config client should be used.
static bool IsConfigClientEnabled(); static bool IsConfigClientEnabled();
// Returns true if the Data Reduction Proxy is forced to be enabled from the
// command line.
static bool ShouldForceEnableDataReductionProxy();
// Constructs configuration parameters. If |kAllowed|, then the standard // Constructs configuration parameters. If |kAllowed|, then the standard
// data reduction proxy configuration is allowed to be used. If // data reduction proxy configuration is allowed to be used. If
// |kfallbackAllowed| a fallback proxy can be used if the primary proxy is // |kfallbackAllowed| a fallback proxy can be used if the primary proxy is
......
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