Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.cc

Issue 1010083002: Flag to clear data savings when Chrome starts up. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sync to head Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.cc
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.cc
index 57247f600c6724c5ed9268d8fcaecba4436e9788..281cd962207b2096a54cf3203a961725a74fbabd 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.cc
@@ -5,6 +5,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h"
#include "base/bind.h"
+#include "base/command_line.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/prefs/pref_change_registrar.h"
@@ -14,6 +15,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/time/time.h"
#include "base/values.h"
+#include "components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h"
namespace data_reduction_proxy {
@@ -70,6 +72,11 @@ void DataReductionProxyStatisticsPrefs::Init() {
InitListPref(data_reduction_proxy::prefs::
kDailyOriginalContentLengthWithDataReductionProxyEnabled);
+ if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+ data_reduction_proxy::switches::kClearDataReductionProxyDataSavings)) {
+ ClearDataSavingStatistics();
+ }
+
pref_change_registrar_->Init(pref_service_);
pref_change_registrar_->Add(prefs::kUpdateDailyReceivedContentLengths,
base::Bind(&DataReductionProxyStatisticsPrefs::OnUpdateContentLengths,
@@ -199,6 +206,32 @@ int64 DataReductionProxyStatisticsPrefs::GetListPrefInt64Value(
return value;
}
+void DataReductionProxyStatisticsPrefs::ClearDataSavingStatistics() {
+ list_pref_map_.get(data_reduction_proxy::prefs::
+ kDailyContentLengthHttpsWithDataReductionProxyEnabled)->Clear();
+ list_pref_map_.get(data_reduction_proxy::prefs::
+ kDailyContentLengthLongBypassWithDataReductionProxyEnabled)->Clear();
+ list_pref_map_.get(data_reduction_proxy::prefs::
+ kDailyContentLengthShortBypassWithDataReductionProxyEnabled)->Clear();
+ list_pref_map_.get(data_reduction_proxy::prefs::
+ kDailyContentLengthUnknownWithDataReductionProxyEnabled)->Clear();
+ list_pref_map_.get(
+ data_reduction_proxy::prefs::kDailyContentLengthViaDataReductionProxy)->
+ Clear();
+ list_pref_map_.get(data_reduction_proxy::prefs::
+ kDailyContentLengthWithDataReductionProxyEnabled)->Clear();
+ list_pref_map_.get(data_reduction_proxy::prefs::
+ kDailyHttpOriginalContentLength)->Clear();
+ list_pref_map_.get(data_reduction_proxy::prefs::
+ kDailyHttpReceivedContentLength)->Clear();
+ list_pref_map_.get(data_reduction_proxy::prefs::
+ kDailyOriginalContentLengthViaDataReductionProxy)->Clear();
+ list_pref_map_.get(data_reduction_proxy::prefs::
+ kDailyOriginalContentLengthWithDataReductionProxyEnabled)->Clear();
+
+ WritePrefs();
+}
+
base::WeakPtr<DataReductionProxyStatisticsPrefs>
DataReductionProxyStatisticsPrefs::GetWeakPtr() {
return weak_factory_.GetWeakPtr();

Powered by Google App Engine
This is Rietveld 408576698