summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/browser/about_flags.cc8
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.cc33
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h3
-rw-r--r--components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs_unittest.cc40
-rw-r--r--components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc4
-rw-r--r--components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h2
-rw-r--r--tools/metrics/histograms/histograms.xml10
8 files changed, 100 insertions, 6 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 63124e6..d6feaa8 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6532,6 +6532,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_FLAGS_ENABLE_DATA_REDUCTION_PROXY_LO_FI_DESCRIPTION" desc="Describes an about::flags experiment to enable/disable Data Saver Lo-Fi">
Puts the Data Saver in Lo-Fi mode when enabled.
</message>
+ <message name="IDS_FLAGS_DATA_REDUCTION_PROXY_RESET_SAVINGS_NAME" desc="Title in about::flags to clear data savings obtained with data reduction proxy when Chrome restarts">
+ Clear data savings on startup
+ </message>
+ <message name="IDS_FLAGS_DATA_REDUCTION_PROXY_RESET_SAVINGS_DESCRIPTION" desc="Description in about::flags to clear data savings obtained with data reduction proxy when Chrome restarts">
+ Clears data savings obtained by using data reduction proxy when chrome starts.
+ </message>
<message name="IDS_FLAGS_LCD_TEXT_NAME" desc="Name of about:flags option for LCD text.">
LCD text antialiasing
</message>
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index cd0a3aa..8c9e85e 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -2202,6 +2202,14 @@ const Experiment kExperiments[] = {
SINGLE_VALUE_TYPE(data_reduction_proxy::switches::
kEnableDataReductionProxyLoFi)
},
+ {
+ "clear-data-reduction-proxy-data-savings",
+ IDS_FLAGS_DATA_REDUCTION_PROXY_RESET_SAVINGS_NAME,
+ IDS_FLAGS_DATA_REDUCTION_PROXY_RESET_SAVINGS_DESCRIPTION,
+ kOsAll,
+ SINGLE_VALUE_TYPE(data_reduction_proxy::switches::
+ kClearDataReductionProxyDataSavings)
+ },
#if defined(ENABLE_DATA_REDUCTION_PROXY_DEBUGGING)
{
"enable-data-reduction-proxy-bypass-warnings",
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 57247f6..281cd96 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();
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h b/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h
index 7c5070b..2da0361 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.h
@@ -98,6 +98,9 @@ private:
// index.
int64 GetListPrefInt64Value(const base::ListValue& list_update, size_t index);
+ // Clears all data saving statistics.
+ void ClearDataSavingStatistics();
+
PrefService* pref_service_;
scoped_refptr<base::SequencedTaskRunner> task_runner_;
const base::TimeDelta delay_;
diff --git a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs_unittest.cc b/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs_unittest.cc
index ba72593..004e96b5 100644
--- a/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs_unittest.cc
+++ b/components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs_unittest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/command_line.h"
#include "base/memory/scoped_ptr.h"
#include "base/prefs/pref_registry_simple.h"
#include "base/prefs/testing_pref_service.h"
@@ -12,6 +13,7 @@
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_prefs.h"
#include "components/data_reduction_proxy/core/browser/data_reduction_proxy_statistics_prefs.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 "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -221,4 +223,42 @@ TEST_F(DataReductionProxyStatisticsPrefsTest,
VerifyPrefs(dict);
}
+TEST_F(DataReductionProxyStatisticsPrefsTest,
+ ClearPrefsOnRestartEnabled) {
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ command_line->AppendSwitch(
+ data_reduction_proxy::switches::kClearDataReductionProxyDataSavings);
+
+ base::ListValue list_value;
+ list_value.Insert(0, new base::StringValue(base::Int64ToString(1234)));
+ simple_pref_service_.Set(prefs::kDailyHttpOriginalContentLength, list_value);
+
+ statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs(
+ &simple_pref_service_,
+ task_runner_,
+ base::TimeDelta::FromMinutes(kWriteDelayMinutes)));
+
+ const base::ListValue* value = simple_pref_service_.GetList(
+ prefs::kDailyHttpOriginalContentLength);
+ EXPECT_EQ(0u, value->GetSize());
+}
+
+TEST_F(DataReductionProxyStatisticsPrefsTest,
+ ClearPrefsOnRestartDisabled) {
+ base::ListValue list_value;
+ list_value.Insert(0, new base::StringValue(base::Int64ToString(1234)));
+ simple_pref_service_.Set(prefs::kDailyHttpOriginalContentLength, list_value);
+
+ statistics_prefs_.reset(new DataReductionProxyStatisticsPrefs(
+ &simple_pref_service_,
+ task_runner_,
+ base::TimeDelta::FromMinutes(kWriteDelayMinutes)));
+
+ const base::ListValue* value = simple_pref_service_.GetList(
+ prefs::kDailyHttpOriginalContentLength);
+ std::string string_value;
+ value->GetString(0, &string_value);
+ EXPECT_EQ("1234", string_value);
+}
+
} // namespace data_reduction_proxy
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc b/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc
index 7f3e03a..bab8af0 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.cc
@@ -66,5 +66,9 @@ const char kEnableDataReductionProxyLoFi[] =
const char kEnableDataReductionProxyBypassWarning[] =
"enable-data-reduction-proxy-bypass-warning";
+// Clear data savings on Chrome startup.
+const char kClearDataReductionProxyDataSavings[] =
+ "clear-data-reduction-proxy-data-savings";
+
} // namespace switches
} // namespace data_reduction_proxy
diff --git a/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h b/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h
index 87d09fa..cd6d08d 100644
--- a/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h
+++ b/components/data_reduction_proxy/core/common/data_reduction_proxy_switches.h
@@ -27,7 +27,7 @@ extern const char kEnableDataReductionProxy[];
extern const char kEnableDataReductionProxyAlt[];
extern const char kEnableDataReductionProxyLoFi[];
extern const char kEnableDataReductionProxyBypassWarning[];
-
+extern const char kClearDataReductionProxyDataSavings[];
} // namespace switches
} // namespace data_reduction_proxy
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 35c3c07..f2d5cba 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -8895,9 +8895,8 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<histogram name="Extensions.FeatureProviderStaticInitTime" units="milliseconds">
<owner>rkaplow@chromium.org</owner>
<summary>
- The amount of time that elapsed during
- extensions::FeatureProvider::Static. Only measured while in the browser
- process.
+ The amount of time that elapsed during extensions::FeatureProvider::Static.
+ Only measured while in the browser process.
</summary>
</histogram>
@@ -19607,8 +19606,8 @@ Therefore, the affected-histogram name has to have at least one dot in it.
enum="QuicSessionLocations">
<owner>rch@chromium.org</owner>
<summary>
- The location in quic_client_session.cc where a session is unexpectedly
- not going away.
+ The location in quic_client_session.cc where a session is unexpectedly not
+ going away.
</summary>
</histogram>
@@ -52683,6 +52682,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="-1267958145" label="disable-pdf-material-ui"/>
<int value="-1241747717" label="enable-android-password-link"/>
<int value="-1218608640" label="disable-offline-load-stale-cache"/>
+ <int value="-1216837777" label="clear-data-reduction-proxy-data-savings"/>
<int value="-1212273428" label="enable-experimental-app-list"/>
<int value="-1203742042" label="enable-gesture-selection"/>
<int value="-1201183153" label="enable-centered-app-list"/>