Index: components/data_reduction_proxy/browser/data_reduction_proxy_prefs.cc |
diff --git a/components/data_reduction_proxy/browser/data_reduction_proxy_prefs.cc b/components/data_reduction_proxy/browser/data_reduction_proxy_prefs.cc |
index 243303cdc2aad9ba5721359bf92ddc0aa07a34c6..bff4c7ad0f7d16de789576195f1057e29a7cf87a 100644 |
--- a/components/data_reduction_proxy/browser/data_reduction_proxy_prefs.cc |
+++ b/components/data_reduction_proxy/browser/data_reduction_proxy_prefs.cc |
@@ -5,35 +5,99 @@ |
#include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" |
#include "base/prefs/pref_registry_simple.h" |
+#include "base/prefs/pref_service.h" |
+#include "base/prefs/scoped_user_pref_update.h" |
#include "components/data_reduction_proxy/common/data_reduction_proxy_pref_names.h" |
#include "components/pref_registry/pref_registry_syncable.h" |
+namespace { |
+ |
+void CopyList(const char* pref_path, PrefService* src, PrefService* dest) { |
marq (ping after 24h)
2014/10/15 08:29:35
Rename to CopyPrefList for clarity.
bengr
2014/10/15 22:52:51
Done.
|
+ ListPrefUpdate update(dest, pref_path); |
marq (ping after 24h)
2014/10/15 08:29:35
What happens if |pref_path| doesn't have a list va
bengr
2014/10/15 22:52:51
Done.
|
+ scoped_ptr<base::ListValue> src_list(src->GetList(pref_path)->DeepCopy()); |
+ update->Swap(src_list.get()); |
mmenke
2014/10/15 15:49:34
Shouldn't we also be deleting the old values? Or
bengr
2014/10/15 22:52:51
Done.
|
+} |
+ |
+} |
mmenke
2014/10/15 15:49:34
nit:
} // namespace
bengr
2014/10/15 22:52:51
Done.
|
+ |
namespace data_reduction_proxy { |
// Make sure any changes here that have the potential to impact android_webview |
// are reflected in RegisterSimpleProfilePrefs. |
void RegisterSyncableProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { |
registry->RegisterBooleanPref( |
- data_reduction_proxy::prefs::kDataReductionProxyEnabled, |
+ prefs::kDataReductionProxyEnabled, |
false, |
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
registry->RegisterBooleanPref( |
- data_reduction_proxy::prefs::kDataReductionProxyAltEnabled, |
+ prefs::kDataReductionProxyAltEnabled, |
false, |
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
registry->RegisterBooleanPref( |
- data_reduction_proxy::prefs::kDataReductionProxyWasEnabledBefore, |
+ prefs::kDataReductionProxyWasEnabledBefore, |
+ false, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ |
+ registry->RegisterInt64Pref( |
+ prefs::kHttpReceivedContentLength, |
+ 0, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterInt64Pref( |
+ prefs::kHttpOriginalContentLength, |
+ 0, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ |
+ registry->RegisterBooleanPref( |
+ prefs::kStatisticsPrefsMigrated, |
false, |
user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterListPref( |
+ prefs::kDailyHttpOriginalContentLength, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterListPref( |
+ prefs::kDailyHttpReceivedContentLength, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterListPref( |
+ prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabled, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterListPref( |
+ prefs::kDailyContentLengthWithDataReductionProxyEnabled, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterListPref( |
+ prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterListPref( |
+ prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterListPref( |
+ prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterListPref( |
+ prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterListPref( |
+ prefs::kDailyOriginalContentLengthViaDataReductionProxy, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterListPref( |
+ prefs::kDailyContentLengthViaDataReductionProxy, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
+ registry->RegisterInt64Pref( |
+ prefs::kDailyHttpContentLengthLastUpdateDate, |
+ 0L, |
+ user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
} |
void RegisterSimpleProfilePrefs(PrefRegistrySimple* registry) { |
registry->RegisterBooleanPref( |
- data_reduction_proxy::prefs::kDataReductionProxyEnabled, false); |
+ prefs::kDataReductionProxyEnabled, false); |
+ registry->RegisterBooleanPref( |
+ prefs::kDataReductionProxyAltEnabled, false); |
registry->RegisterBooleanPref( |
- data_reduction_proxy::prefs::kDataReductionProxyAltEnabled, false); |
+ prefs::kDataReductionProxyWasEnabledBefore, false); |
+ |
registry->RegisterBooleanPref( |
- data_reduction_proxy::prefs::kDataReductionProxyWasEnabledBefore, false); |
+ prefs::kStatisticsPrefsMigrated, false); |
+ RegisterPrefs(registry); |
} |
// Add any new data reduction proxy prefs to the |pref_map_| or the |
@@ -67,4 +131,41 @@ void RegisterPrefs(PrefRegistrySimple* registry) { |
prefs::kDailyHttpContentLengthLastUpdateDate, 0L); |
} |
+void MigrateStatisticsPrefs(PrefService* local_state_prefs, |
+ PrefService* profile_prefs) { |
+ if (profile_prefs->GetBoolean(prefs::kStatisticsPrefsMigrated)) |
+ return; |
+ profile_prefs->SetInt64( |
+ prefs::kHttpReceivedContentLength, |
+ local_state_prefs->GetInt64(prefs::kHttpReceivedContentLength)); |
+ profile_prefs->SetInt64( |
+ prefs::kHttpOriginalContentLength, |
+ local_state_prefs->GetInt64(prefs::kHttpOriginalContentLength)); |
+ CopyList(prefs::kDailyHttpOriginalContentLength, |
+ local_state_prefs, profile_prefs); |
+ CopyList(prefs::kDailyHttpReceivedContentLength, |
+ local_state_prefs, profile_prefs); |
+ CopyList(prefs::kDailyOriginalContentLengthWithDataReductionProxyEnabled, |
+ local_state_prefs, profile_prefs); |
+ CopyList(prefs::kDailyContentLengthWithDataReductionProxyEnabled, |
+ local_state_prefs, profile_prefs); |
+ CopyList(prefs::kDailyContentLengthHttpsWithDataReductionProxyEnabled, |
+ local_state_prefs, profile_prefs); |
+ CopyList(prefs::kDailyContentLengthShortBypassWithDataReductionProxyEnabled, |
+ local_state_prefs, profile_prefs); |
+ CopyList(prefs::kDailyContentLengthLongBypassWithDataReductionProxyEnabled, |
+ local_state_prefs, profile_prefs); |
+ CopyList(prefs::kDailyContentLengthUnknownWithDataReductionProxyEnabled, |
+ local_state_prefs, profile_prefs); |
+ CopyList(prefs::kDailyOriginalContentLengthViaDataReductionProxy, |
+ local_state_prefs, profile_prefs); |
+ CopyList(prefs::kDailyContentLengthViaDataReductionProxy, |
+ local_state_prefs, profile_prefs); |
+ profile_prefs->SetInt64( |
+ prefs::kDailyHttpContentLengthLastUpdateDate, |
+ local_state_prefs->GetInt64( |
+ prefs::kDailyHttpContentLengthLastUpdateDate)); |
+ profile_prefs->SetBoolean(prefs::kStatisticsPrefsMigrated, true); |
+} |
+ |
} // namespace data_reduction_proxy |