Commit 4441cc1d authored by hush's avatar hush Committed by Commit bot

Use no-op statistics collecting object for WebView.

WebView does not gather data_reduction_proxy related
statistics at the moment. WebView's statistics object writes
the data to pref service which does not upload the data to
anywhere.

BUG=b/17998706

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

Cr-Commit-Position: refs/heads/master@{#300613}
parent 80aa80ba
......@@ -20,6 +20,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_params.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/user_prefs/user_prefs.h"
#include "components/visitedlink/browser/visitedlink_master.h"
#include "content/public/browser/browser_thread.h"
......@@ -94,6 +95,10 @@ void AwBrowserContext::SetDataReductionProxyEnabled(bool enabled) {
context->GetDataReductionProxySettings();
if (proxy_settings == NULL)
return;
context->CreateDataReductionProxyStatisticsIfNecessary();
proxy_settings->SetDataReductionProxyStatisticsPrefs(
context->data_reduction_proxy_statistics_.get());
proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_);
}
......@@ -293,4 +298,19 @@ void AwBrowserContext::RebuildTable(
enumerator->OnComplete(true);
}
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));
}
}
} // namespace android_webview
......@@ -30,6 +30,7 @@ class WebContents;
namespace data_reduction_proxy {
class DataReductionProxyConfigurator;
class DataReductionProxySettings;
class DataReductionProxyStatisticsPrefs;
}
namespace net {
......@@ -116,6 +117,7 @@ class AwBrowserContext : public content::BrowserContext,
const scoped_refptr<URLEnumerator>& enumerator) override;
private:
void CreateDataReductionProxyStatisticsIfNecessary();
static bool data_reduction_proxy_enabled_;
// The file path where data for this context is persisted.
......@@ -136,6 +138,8 @@ class AwBrowserContext : public content::BrowserContext,
scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator>
data_reduction_proxy_configurator_;
scoped_ptr<data_reduction_proxy::DataReductionProxyStatisticsPrefs>
data_reduction_proxy_statistics_;
scoped_ptr<data_reduction_proxy::DataReductionProxySettings>
data_reduction_proxy_settings_;
......
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