| Index: android_webview/browser/aw_browser_context.cc
|
| diff --git a/android_webview/browser/aw_browser_context.cc b/android_webview/browser/aw_browser_context.cc
|
| index 016f35e30e6366be7943585da64800006ec944b5..57403b34ac6a44d6f1acf1ca12e49ad21a344bc5 100644
|
| --- a/android_webview/browser/aw_browser_context.cc
|
| +++ b/android_webview/browser/aw_browser_context.cc
|
| @@ -19,9 +19,9 @@
|
| #include "base/prefs/pref_service_factory.h"
|
| #include "components/autofill/core/common/autofill_pref_names.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_config_service.h"
|
| +#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_data.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h"
|
| #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_settings.h"
|
| -#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.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 "components/user_prefs/user_prefs.h"
|
| @@ -36,9 +36,10 @@
|
|
|
| using base::FilePath;
|
| using content::BrowserThread;
|
| -using data_reduction_proxy::DataReductionProxyConfigService;
|
| -using data_reduction_proxy::DataReductionProxyEventStore;
|
| -using data_reduction_proxy::DataReductionProxySettings;
|
| +
|
| +namespace data_reduction_proxy {
|
| +class DataReductionProxyStatisticsPrefs;
|
| +}
|
|
|
| namespace android_webview {
|
|
|
| @@ -117,14 +118,16 @@ void AwBrowserContext::SetDataReductionProxyEnabled(bool enabled) {
|
| // Can't enable Data reduction proxy if user pref service is not ready.
|
| if (context == NULL || context->user_pref_service_.get() == NULL)
|
| return;
|
| - DataReductionProxySettings* proxy_settings =
|
| + data_reduction_proxy::DataReductionProxySettings* proxy_settings =
|
| context->GetDataReductionProxySettings();
|
| if (proxy_settings == NULL)
|
| return;
|
| -
|
| + // At this point, context->PreMainMessageLoopRun() has run, so
|
| + // context->data_reduction_proxy_io_data() is valid.
|
| + DCHECK(context->GetDataReductionProxyIOData());
|
| context->CreateDataReductionProxyStatisticsIfNecessary();
|
| proxy_settings->SetDataReductionProxyStatisticsPrefs(
|
| - context->data_reduction_proxy_statistics_.get());
|
| + context->GetDataReductionProxyIOData()->statistics_prefs());
|
| proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_);
|
| }
|
|
|
| @@ -136,28 +139,41 @@ void AwBrowserContext::SetLegacyCacheRemovalDelayForTest(int delay_ms) {
|
| void AwBrowserContext::PreMainMessageLoopRun() {
|
| cookie_store_ = CreateCookieStore(this);
|
| data_reduction_proxy_settings_.reset(
|
| - new DataReductionProxySettings(
|
| + new data_reduction_proxy::DataReductionProxySettings(
|
| new data_reduction_proxy::DataReductionProxyParams(
|
| data_reduction_proxy::DataReductionProxyParams::kAllowed)));
|
| - data_reduction_proxy_event_store_.reset(
|
| - new DataReductionProxyEventStore(
|
| - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)));
|
| - scoped_ptr<DataReductionProxyConfigService>
|
| + scoped_ptr<data_reduction_proxy::DataReductionProxyConfigService>
|
| data_reduction_proxy_config_service(
|
| - new DataReductionProxyConfigService(
|
| + new data_reduction_proxy::DataReductionProxyConfigService(
|
| scoped_ptr<net::ProxyConfigService>(
|
| CreateProxyConfigService()).Pass()));
|
| - if (data_reduction_proxy_settings_.get()) {
|
| - data_reduction_proxy_configurator_.reset(
|
| - new data_reduction_proxy::DataReductionProxyConfigTracker(
|
| - base::Bind(&DataReductionProxyConfigService::UpdateProxyConfig,
|
| - base::Unretained(
|
| - data_reduction_proxy_config_service.get())),
|
| - BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
|
| - data_reduction_proxy_settings_->SetProxyConfigurator(
|
| - data_reduction_proxy_configurator_.get());
|
| - }
|
| -
|
| + data_reduction_proxy_io_data_.reset(
|
| + new data_reduction_proxy::DataReductionProxyIOData(
|
| + data_reduction_proxy::Client::WEBVIEW_ANDROID,
|
| + data_reduction_proxy_settings_->params()->Clone(),
|
| + make_scoped_ptr(
|
| + new data_reduction_proxy::DataReductionProxyConfigTracker(
|
| + base::Bind(
|
| + &data_reduction_proxy::DataReductionProxyConfigService::
|
| + UpdateProxyConfig,
|
| + base::Unretained(
|
| + data_reduction_proxy_config_service.get())),
|
| + BrowserThread::GetMessageLoopProxyForThread(
|
| + BrowserThread::IO))),
|
| + scoped_ptr<
|
| + data_reduction_proxy::DataReductionProxyStatisticsPrefs>(),
|
| + make_scoped_ptr(
|
| + new data_reduction_proxy::DataReductionProxyEventStore(
|
| + BrowserThread::GetMessageLoopProxyForThread(
|
| + BrowserThread::UI))),
|
| + data_reduction_proxy::DataReductionProxyNetworkDelegate::
|
| + ProxyConfigGetter(),
|
| + base::Callback<void(bool)>(),
|
| + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO),
|
| + BrowserThread::GetMessageLoopProxyForThread(
|
| + BrowserThread::UI)));
|
| + data_reduction_proxy_settings_->SetProxyConfigurator(
|
| + data_reduction_proxy_io_data_->configurator());
|
| FilePath cache_path;
|
| const FilePath fallback_cache_dir =
|
| GetPath().Append(FILE_PATH_LITERAL("Cache"));
|
| @@ -227,13 +243,14 @@ AwFormDatabaseService* AwBrowserContext::GetFormDatabaseService() {
|
| return form_database_service_.get();
|
| }
|
|
|
| -DataReductionProxySettings* AwBrowserContext::GetDataReductionProxySettings() {
|
| +data_reduction_proxy::DataReductionProxySettings*
|
| +AwBrowserContext::GetDataReductionProxySettings() {
|
| return data_reduction_proxy_settings_.get();
|
| }
|
|
|
| -DataReductionProxyEventStore*
|
| - AwBrowserContext::GetDataReductionProxyEventStore() {
|
| - return data_reduction_proxy_event_store_.get();
|
| +data_reduction_proxy::DataReductionProxyIOData*
|
| +AwBrowserContext::GetDataReductionProxyIOData() {
|
| + return data_reduction_proxy_io_data_.get();
|
| }
|
|
|
| AwURLRequestContextGetter* AwBrowserContext::GetAwURLRequestContext() {
|
| @@ -269,7 +286,7 @@ void AwBrowserContext::CreateUserPrefServiceIfNecessary() {
|
| user_pref_service_.get(),
|
| GetRequestContext(),
|
| GetAwURLRequestContext()->GetNetLog(),
|
| - GetDataReductionProxyEventStore());
|
| + data_reduction_proxy_io_data_->event_store());
|
| data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true);
|
|
|
| SetDataReductionProxyEnabled(data_reduction_proxy_enabled_);
|
| @@ -363,17 +380,13 @@ void AwBrowserContext::RebuildTable(
|
|
|
| void AwBrowserContext::CreateDataReductionProxyStatisticsIfNecessary() {
|
| DCHECK(user_pref_service_.get());
|
| -
|
| - if (!data_reduction_proxy_statistics_.get()) {
|
| - // We don't care about commit_delay for now. It is just a dummy value.
|
| - base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60);
|
| - data_reduction_proxy_statistics_ =
|
| - scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>(
|
| - new data_reduction_proxy::DataReductionProxyStatisticsPrefs(
|
| - user_pref_service_.get(),
|
| - base::MessageLoopProxy::current(),
|
| - commit_delay));
|
| - }
|
| + DCHECK(GetDataReductionProxyIOData());
|
| + if (GetDataReductionProxyIOData()->statistics_prefs())
|
| + return;
|
| + // We don't care about commit_delay for now. It is just a dummy value.
|
| + base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60);
|
| + GetDataReductionProxyIOData()->CreateStatisticsPrefs(
|
| + user_pref_service_.get(), commit_delay);
|
| }
|
|
|
| } // namespace android_webview
|
|
|