Commit 8e2aa8a3 authored by David Van Cleve's avatar David Van Cleve Committed by Chromium LUCI CQ

data_reduction_proxy: Temporarily readd (and clear) obsolete prefs

battre@ pointed out that a number of the data reduction prefs corresponding to obsolete metrics removed in crrev.com/c/1762336 were never cleared, so they continue to take up space in profile directories where they were set.

This change adds back the prefs deleted in that CL temporarily, clearing them on startup. I've filed crbug.com/1153394 to remind us to remove the prefs once M90 branches (so that the clearing logic will have been live for two releases).

Test: Added a unit test verifying all of the obsolete prefs get cleared
Bug: 1132866,934982,1153394
Change-Id: Ife2dab8634205812119db36d50e95d0173884a6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2563788Reviewed-by: default avatarDominic Battré <battre@chromium.org>
Reviewed-by: default avatarTarun Bansal <tbansal@chromium.org>
Commit-Queue: Tarun Bansal <tbansal@chromium.org>
Auto-Submit: David Van Cleve <davidvc@chromium.org>
Cr-Commit-Position: refs/heads/master@{#832002}
parent fc6baf71
......@@ -183,6 +183,62 @@ void RecordDictionaryToHistogram(const std::string& histogram_name,
}
#endif
// These obsolete prefs were deleted without first clearing them (see
// https://crbug.com/934982#c10). We readd them for two milestones in order to
// increase the chance they get removed from profile directories.
void ClearTemporarilyReaddedObsoletePrefsToFreeStorage(
PrefService& pref_service) {
pref_service.ClearPref(prefs::kDailyHttpOriginalContentLengthApplication);
pref_service.ClearPref(prefs::kDailyHttpOriginalContentLengthVideo);
pref_service.ClearPref(prefs::kDailyHttpOriginalContentLengthUnknown);
pref_service.ClearPref(prefs::kDailyHttpReceivedContentLengthApplication);
pref_service.ClearPref(prefs::kDailyHttpReceivedContentLengthVideo);
pref_service.ClearPref(prefs::kDailyHttpReceivedContentLengthUnknown);
pref_service.ClearPref(
prefs::kDailyOriginalContentLengthViaDataReductionProxyApplication);
pref_service.ClearPref(
prefs::kDailyOriginalContentLengthViaDataReductionProxyVideo);
pref_service.ClearPref(
prefs::kDailyOriginalContentLengthViaDataReductionProxyUnknown);
pref_service.ClearPref(
prefs::kDailyContentLengthViaDataReductionProxyApplication);
pref_service.ClearPref(prefs::kDailyContentLengthViaDataReductionProxyVideo);
pref_service.ClearPref(
prefs::kDailyContentLengthViaDataReductionProxyUnknown);
pref_service.ClearPref(
prefs::
kDailyOriginalContentLengthWithDataReductionProxyEnabledApplication);
pref_service.ClearPref(
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabledVideo);
pref_service.ClearPref(
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabledUnknown);
pref_service.ClearPref(
prefs::kDailyContentLengthWithDataReductionProxyEnabledApplication);
pref_service.ClearPref(
prefs::kDailyContentLengthWithDataReductionProxyEnabledVideo);
pref_service.ClearPref(
prefs::kDailyContentLengthWithDataReductionProxyEnabledUnknown);
pref_service.ClearPref(
prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled);
pref_service.ClearPref(
prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled);
pref_service.ClearPref(
prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled);
pref_service.ClearPref(
prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled);
pref_service.ClearPref(prefs::kDailyContentLengthViaDataReductionProxy);
pref_service.ClearPref(
prefs::kDailyContentLengthWithDataReductionProxyEnabled);
pref_service.ClearPref(
prefs::kDailyOriginalContentLengthViaDataReductionProxy);
pref_service.ClearPref(
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabled);
}
} // namespace
class DataReductionProxyCompressionStats::DailyContentLengthUpdate {
......@@ -361,6 +417,8 @@ void DataReductionProxyCompressionStats::Init() {
// Init all list prefs.
InitListPref(prefs::kDailyHttpOriginalContentLength);
InitListPref(prefs::kDailyHttpReceivedContentLength);
ClearTemporarilyReaddedObsoletePrefsToFreeStorage(*pref_service_);
}
void DataReductionProxyCompressionStats::RecordDataUseWithMimeType(
......
......@@ -1116,4 +1116,42 @@ TEST_F(DataReductionProxyCompressionStatsTest,
data_use_measurement::DataUseUserData::NON_MAIN_FRAME_HTML, 0);
}
TEST_F(DataReductionProxyCompressionStatsTest, ClearsObsoletePrefs) {
const std::vector<std::string> kObsoletePrefNames = {
prefs::kDailyHttpOriginalContentLengthApplication,
prefs::kDailyHttpOriginalContentLengthVideo,
prefs::kDailyHttpOriginalContentLengthUnknown,
prefs::kDailyHttpReceivedContentLengthApplication,
prefs::kDailyHttpReceivedContentLengthVideo,
prefs::kDailyHttpReceivedContentLengthUnknown,
prefs::kDailyOriginalContentLengthViaDataReductionProxyApplication,
prefs::kDailyOriginalContentLengthViaDataReductionProxyVideo,
prefs::kDailyOriginalContentLengthViaDataReductionProxyUnknown,
prefs::kDailyContentLengthViaDataReductionProxyApplication,
prefs::kDailyContentLengthViaDataReductionProxyVideo,
prefs::kDailyContentLengthViaDataReductionProxyUnknown,
prefs::
kDailyOriginalContentLengthWithDataReductionProxyEnabledApplication,
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabledVideo,
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabledUnknown,
prefs::kDailyContentLengthWithDataReductionProxyEnabledApplication,
prefs::kDailyContentLengthWithDataReductionProxyEnabledVideo,
prefs::kDailyContentLengthWithDataReductionProxyEnabledUnknown,
prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled,
prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled,
prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled,
prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled,
prefs::kDailyContentLengthViaDataReductionProxy,
prefs::kDailyContentLengthWithDataReductionProxyEnabled,
prefs::kDailyOriginalContentLengthViaDataReductionProxy,
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabled};
for (const std::string& pref_name : kObsoletePrefNames) {
const PrefService::Preference* pref =
pref_service()->FindPreference(pref_name);
ASSERT_TRUE(pref) << pref_name;
EXPECT_TRUE(pref->IsDefaultValue()) << pref_name;
}
}
} // namespace data_reduction_proxy
......@@ -14,6 +14,125 @@
namespace data_reduction_proxy {
namespace {
// Re-register a collection of obsolete prefs we're temporarily readding in
// order to clear them to save space in profile directories.
void RegisterObsoleteSyncablePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterInt64Pref(prefs::kDailyHttpOriginalContentLengthApplication,
0L);
registry->RegisterInt64Pref(prefs::kDailyHttpOriginalContentLengthVideo, 0L);
registry->RegisterInt64Pref(prefs::kDailyHttpOriginalContentLengthUnknown,
0L);
registry->RegisterInt64Pref(prefs::kDailyHttpReceivedContentLengthApplication,
0L);
registry->RegisterInt64Pref(prefs::kDailyHttpReceivedContentLengthVideo, 0L);
registry->RegisterInt64Pref(prefs::kDailyHttpReceivedContentLengthUnknown,
0L);
registry->RegisterListPref(
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabled);
registry->RegisterInt64Pref(
prefs::
kDailyOriginalContentLengthWithDataReductionProxyEnabledApplication,
0L);
registry->RegisterInt64Pref(
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabledVideo, 0L);
registry->RegisterInt64Pref(
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabledUnknown,
0L);
registry->RegisterListPref(
prefs::kDailyContentLengthWithDataReductionProxyEnabled);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthWithDataReductionProxyEnabledApplication, 0L);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthWithDataReductionProxyEnabledVideo, 0L);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthWithDataReductionProxyEnabledUnknown, 0L);
registry->RegisterListPref(
prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled);
registry->RegisterListPref(
prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled);
registry->RegisterListPref(
prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled);
registry->RegisterListPref(
prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled);
registry->RegisterListPref(
prefs::kDailyOriginalContentLengthViaDataReductionProxy);
registry->RegisterInt64Pref(
prefs::kDailyOriginalContentLengthViaDataReductionProxyApplication, 0L);
registry->RegisterInt64Pref(
prefs::kDailyOriginalContentLengthViaDataReductionProxyVideo, 0L);
registry->RegisterInt64Pref(
prefs::kDailyOriginalContentLengthViaDataReductionProxyUnknown, 0L);
registry->RegisterListPref(prefs::kDailyContentLengthViaDataReductionProxy);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthViaDataReductionProxyApplication, 0L);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthViaDataReductionProxyVideo, 0L);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthViaDataReductionProxyUnknown, 0L);
}
// Re-register a collection of obsolete prefs we're temporarily readding in
// order to clear them to save space in profile directories.
void RegisterObsoleteSimplePrefs(PrefRegistrySimple* registry) {
registry->RegisterInt64Pref(prefs::kDailyHttpOriginalContentLengthApplication,
0L);
registry->RegisterInt64Pref(prefs::kDailyHttpOriginalContentLengthVideo, 0L);
registry->RegisterInt64Pref(prefs::kDailyHttpOriginalContentLengthUnknown,
0L);
registry->RegisterInt64Pref(prefs::kDailyHttpReceivedContentLengthApplication,
0L);
registry->RegisterInt64Pref(prefs::kDailyHttpReceivedContentLengthVideo, 0L);
registry->RegisterInt64Pref(prefs::kDailyHttpReceivedContentLengthUnknown,
0L);
registry->RegisterListPref(
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabled);
registry->RegisterInt64Pref(
prefs::
kDailyOriginalContentLengthWithDataReductionProxyEnabledApplication,
0L);
registry->RegisterInt64Pref(
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabledVideo, 0L);
registry->RegisterInt64Pref(
prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabledUnknown,
0L);
registry->RegisterListPref(
prefs::kDailyContentLengthWithDataReductionProxyEnabled);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthWithDataReductionProxyEnabledApplication, 0L);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthWithDataReductionProxyEnabledVideo, 0L);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthWithDataReductionProxyEnabledUnknown, 0L);
registry->RegisterListPref(
prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled);
registry->RegisterListPref(
prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled);
registry->RegisterListPref(
prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled);
registry->RegisterListPref(
prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled);
registry->RegisterListPref(
prefs::kDailyOriginalContentLengthViaDataReductionProxy);
registry->RegisterInt64Pref(
prefs::kDailyOriginalContentLengthViaDataReductionProxyApplication, 0L);
registry->RegisterInt64Pref(
prefs::kDailyOriginalContentLengthViaDataReductionProxyVideo, 0L);
registry->RegisterInt64Pref(
prefs::kDailyOriginalContentLengthViaDataReductionProxyUnknown, 0L);
registry->RegisterListPref(prefs::kDailyContentLengthViaDataReductionProxy);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthViaDataReductionProxyApplication, 0L);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthViaDataReductionProxyVideo, 0L);
registry->RegisterInt64Pref(
prefs::kDailyContentLengthViaDataReductionProxyUnknown, 0L);
}
} // namespace
// Make sure any changes here that have the potential to impact android_webview
// are reflected in RegisterSimpleProfilePrefs.
void RegisterSyncableProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
......@@ -52,6 +171,8 @@ void RegisterSyncableProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterDictionaryPref(
prefs::kLastWeekUserTrafficContentTypeDownstreamKB,
PrefRegistry::LOSSY_PREF);
RegisterObsoleteSyncablePrefs(registry);
}
void RegisterSimpleProfilePrefs(PrefRegistrySimple* registry) {
......@@ -94,6 +215,8 @@ void RegisterPrefs(PrefRegistrySimple* registry) {
registry->RegisterDictionaryPref(
prefs::kLastWeekUserTrafficContentTypeDownstreamKB,
PrefRegistry::LOSSY_PREF);
RegisterObsoleteSimplePrefs(registry);
}
} // namespace data_reduction_proxy
......@@ -90,5 +90,158 @@ const char kThisWeekUserTrafficContentTypeDownstreamKB[] =
const char kLastWeekUserTrafficContentTypeDownstreamKB[] =
"data_reduction.last_week_user_traffic_contenttype_downstream_kb";
// The following prefs are obsolete and are being readded temporarily to clear
// them.
// BEGIN OBSOLETE PREFS READDED FOR DELETION
// A List pref that contains daily totals of the size of all HTTPS
// content received when the data reduction proxy was enabled.
const char kDailyContentLengthHttpsWithDataReductionProxyEnabled[] =
"data_reduction.daily_received_length_https_with_"
"data_reduction_proxy_enabled";
// A List pref that contains daily totals of the size of all HTTP/HTTPS
// content received when a bypass of more than 30 minutes is in effect.
const char kDailyContentLengthLongBypassWithDataReductionProxyEnabled[] =
"data_reduction.daily_received_length_long_bypass_with_"
"data_reduction_proxy_enabled";
// A List pref that contains daily totals of the size of all HTTP/HTTPS
// content received when a bypass of less than 30 minutes is in effect.
const char kDailyContentLengthShortBypassWithDataReductionProxyEnabled[] =
"data_reduction.daily_received_length_short_bypass_with_"
"data_reduction_proxy_enabled";
// TODO(bengr): what is this?
const char kDailyContentLengthUnknownWithDataReductionProxyEnabled[] =
"data_reduction.daily_received_length_unknown_with_"
"data_reduction_proxy_enabled";
// A List pref that contains daily totals of the size of all HTTP/HTTPS
// content received via the data reduction proxy.
const char kDailyContentLengthViaDataReductionProxy[] =
"data_reduction.daily_received_length_via_data_reduction_proxy";
// A List pref that contains daily totals of the size of all HTTP/HTTPS
// content with application mime-type received via the data reduction proxy.
const char kDailyContentLengthViaDataReductionProxyApplication[] =
"data_reduction.daily_received_length_via_data_reduction_proxy_application";
// A List pref that contains daily totals of the size of all HTTP/HTTPS
// content with video mime-type received via the data reduction proxy.
const char kDailyContentLengthViaDataReductionProxyVideo[] =
"data_reduction.daily_received_length_via_data_reduction_proxy_video";
// A List pref that contains daily totals of the size of all HTTP/HTTPS
// content with unknown mime-type received via the data reduction proxy.
const char kDailyContentLengthViaDataReductionProxyUnknown[] =
"data_reduction.daily_received_length_via_data_reduction_proxy_unknown";
// A List pref that contains daily totals of the size of all HTTP/HTTPS
// content received while the data reduction proxy is enabled.
const char kDailyContentLengthWithDataReductionProxyEnabled[] =
"data_reduction.daily_received_length_with_data_reduction_proxy_enabled";
// A List pref that contains daily totals of the size of all HTTP/HTTPS
// content with application mime-type received while the data reduction proxy is
// enabled.
const char kDailyContentLengthWithDataReductionProxyEnabledApplication[] =
"data_reduction.daily_received_length_with_data_reduction_proxy_enabled_"
"application";
// A List pref that contains daily totals of the size of all HTTP/HTTPS
// content with video mime-type received while the data reduction proxy is
// enabled.
const char kDailyContentLengthWithDataReductionProxyEnabledVideo[] =
"data_reduction.daily_received_length_with_data_reduction_proxy_enabled_"
"video";
// A List pref that contains daily totals of the size of all HTTP/HTTPS
// content with unknown mime-type received while the data reduction proxy is
// enabled.
const char kDailyContentLengthWithDataReductionProxyEnabledUnknown[] =
"data_reduction.daily_received_length_with_data_reduction_proxy_enabled_"
"unknown";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content with application mime-type received from the network.
const char kDailyHttpOriginalContentLengthApplication[] =
"data_reduction.daily_original_length_application";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content with video mime-type received from the network.
const char kDailyHttpOriginalContentLengthVideo[] =
"data_reduction.daily_original_length_video";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content with unknown mime-type received from the network.
const char kDailyHttpOriginalContentLengthUnknown[] =
"data_reduction.daily_original_length_unknown";
// A List pref that contains daily totals of the size of all HTTP/HTTPS content
// received with application mime-type from the network.
const char kDailyHttpReceivedContentLengthApplication[] =
"data_reduction.daily_received_length_application";
// A List pref that contains daily totals of the size of all HTTP/HTTPS content
// received with video mime-type from the network.
const char kDailyHttpReceivedContentLengthVideo[] =
"data_reduction.daily_received_length_video";
// A List pref that contains daily totals of the size of all HTTP/HTTPS content
// received with unknown mime-type from the network.
const char kDailyHttpReceivedContentLengthUnknown[] =
"data_reduction.daily_received_length_unknown";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content received via the data reduction proxy.
const char kDailyOriginalContentLengthViaDataReductionProxy[] =
"data_reduction.daily_original_length_via_data_reduction_proxy";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content with application mime-type received via the data reduction proxy.
const char kDailyOriginalContentLengthViaDataReductionProxyApplication[] =
"data_reduction.daily_original_length_via_data_reduction_proxy_application";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content with video mime-type received via the data reduction proxy.
const char kDailyOriginalContentLengthViaDataReductionProxyVideo[] =
"data_reduction.daily_original_length_via_data_reduction_proxy_video";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content with unknown mime-type received via the data reduction proxy.
const char kDailyOriginalContentLengthViaDataReductionProxyUnknown[] =
"data_reduction.daily_original_length_via_data_reduction_proxy_unknown";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content received while the data reduction proxy is enabled.
const char kDailyOriginalContentLengthWithDataReductionProxyEnabled[] =
"data_reduction.daily_original_length_with_data_reduction_proxy_enabled";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content with application mime type received while the data reduction proxy is
// enabled.
const char
kDailyOriginalContentLengthWithDataReductionProxyEnabledApplication[] =
"data_reduction.daily_original_length_with_data_reduction_proxy_"
"enabled_application";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content with video mime type received while the data reduction proxy is
// enabled.
const char kDailyOriginalContentLengthWithDataReductionProxyEnabledVideo[] =
"data_reduction.daily_original_length_with_data_reduction_proxy_enabled_"
"video";
// A List pref that contains daily totals of the original size of all HTTP/HTTPS
// content with unknown mime type received while the data reduction proxy is
// enabled.
const char kDailyOriginalContentLengthWithDataReductionProxyEnabledUnknown[] =
"data_reduction.daily_original_length_with_data_reduction_proxy_enabled_"
"unknown";
// END OBSOLETE PREFS READDED FOR DELETION
} // namespace prefs
} // namespace data_reduction_proxy
......@@ -33,6 +33,44 @@ extern const char kLastWeekServicesDownstreamForegroundKB[];
extern const char kThisWeekUserTrafficContentTypeDownstreamKB[];
extern const char kLastWeekUserTrafficContentTypeDownstreamKB[];
// The following are obsolete and are being readded temporarily to delete them
// so that they stop taking up space in profile directories.
//
// TODO(crbug.com/1153394): Remove these again once M90 branches (i.e. so that
// they are removed in M91, after having been live for at least two milestones).
//
// BEGIN OBSOLETE PREFS READDED FOR DELETION
extern const char kDailyContentLengthHttpsWithDataReductionProxyEnabled[];
extern const char kDailyContentLengthLongBypassWithDataReductionProxyEnabled[];
extern const char kDailyContentLengthShortBypassWithDataReductionProxyEnabled[];
extern const char kDailyContentLengthUnknownWithDataReductionProxyEnabled[];
extern const char kDailyContentLengthViaDataReductionProxy[];
extern const char kDailyContentLengthViaDataReductionProxyApplication[];
extern const char kDailyContentLengthViaDataReductionProxyVideo[];
extern const char kDailyContentLengthViaDataReductionProxyUnknown[];
extern const char kDailyContentLengthWithDataReductionProxyEnabled[];
extern const char kDailyContentLengthWithDataReductionProxyEnabledApplication[];
extern const char kDailyContentLengthWithDataReductionProxyEnabledVideo[];
extern const char kDailyContentLengthWithDataReductionProxyEnabledUnknown[];
extern const char kDailyHttpOriginalContentLengthApplication[];
extern const char kDailyHttpOriginalContentLengthVideo[];
extern const char kDailyHttpOriginalContentLengthUnknown[];
extern const char kDailyHttpReceivedContentLengthApplication[];
extern const char kDailyHttpReceivedContentLengthVideo[];
extern const char kDailyHttpReceivedContentLengthUnknown[];
extern const char kDailyOriginalContentLengthViaDataReductionProxy[];
extern const char kDailyOriginalContentLengthViaDataReductionProxyApplication[];
extern const char kDailyOriginalContentLengthViaDataReductionProxyVideo[];
extern const char kDailyOriginalContentLengthViaDataReductionProxyUnknown[];
extern const char kDailyOriginalContentLengthWithDataReductionProxyEnabled[];
extern const char
kDailyOriginalContentLengthWithDataReductionProxyEnabledApplication[];
extern const char
kDailyOriginalContentLengthWithDataReductionProxyEnabledVideo[];
extern const char
kDailyOriginalContentLengthWithDataReductionProxyEnabledUnknown[];
// END OBSOLETE PREFS READDED FOR DELETION
} // namespace prefs
} // namespace data_reduction_proxy
......
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