summaryrefslogtreecommitdiffstats
path: root/net/sdch
diff options
context:
space:
mode:
authorraymes <raymes@chromium.org>2015-05-05 20:22:21 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-06 03:22:49 +0000
commit76de1af44ac758e104f2fea2f045f0274aa42221 (patch)
tree8eb169d5cbb849e7fb14de814896dc5720f9b737 /net/sdch
parent3a9179a64eac8c0d606409b2ebdabd60b612151a (diff)
downloadchromium_src-76de1af44ac758e104f2fea2f045f0274aa42221.zip
chromium_src-76de1af44ac758e104f2fea2f045f0274aa42221.tar.gz
chromium_src-76de1af44ac758e104f2fea2f045f0274aa42221.tar.bz2
Add a PrefRegistrationFlags::LOSSY_PREF flag for writing lossy prefs
This adds a registration flag for marking a pref as "lossy". There is no strict time guarantee on when a lossy pref will be persisted to permanent storage when it is modified. WriteablePrefStore::PrefWriteFlags are introduced to be used to change the way that prefs get written into a WriteablePrefStore. The plumbing to pass registration flags down from PrefService into the WriteablePrefStore and convert them into PrefWriteFlags is also added here. The code which actually makes the pref behave in a lossy way has not been added yet. BUG=476800 Review URL: https://codereview.chromium.org/1092223004 Cr-Commit-Position: refs/heads/master@{#328481}
Diffstat (limited to 'net/sdch')
-rw-r--r--net/sdch/sdch_owner.cc8
-rw-r--r--net/sdch/sdch_owner_unittest.cc9
2 files changed, 12 insertions, 5 deletions
diff --git a/net/sdch/sdch_owner.cc b/net/sdch/sdch_owner.cc
index d0f3135..226604a 100644
--- a/net/sdch/sdch_owner.cc
+++ b/net/sdch/sdch_owner.cc
@@ -102,7 +102,8 @@ void InitializePrefStore(WriteablePrefStore* store) {
empty_store->SetInteger(kVersionKey, kVersion);
empty_store->Set(kDictionariesKey,
make_scoped_ptr(new base::DictionaryValue));
- store->SetValue(kPreferenceName, empty_store);
+ store->SetValue(kPreferenceName, empty_store,
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
}
// A class to allow iteration over all dictionaries in the pref store, and
@@ -190,7 +191,10 @@ class ScopedPrefNotifier {
// lifetime of this object.
ScopedPrefNotifier(WriteablePrefStore* pref_store)
: pref_store_(pref_store) {}
- ~ScopedPrefNotifier() { pref_store_->ReportValueChanged(kPreferenceName); }
+ ~ScopedPrefNotifier() {
+ pref_store_->ReportValueChanged(
+ kPreferenceName, WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
+ }
private:
WriteablePrefStore* pref_store_;
diff --git a/net/sdch/sdch_owner_unittest.cc b/net/sdch/sdch_owner_unittest.cc
index e1f778f..e522d18 100644
--- a/net/sdch/sdch_owner_unittest.cc
+++ b/net/sdch/sdch_owner_unittest.cc
@@ -774,7 +774,8 @@ TEST_F(SdchOwnerPersistenceTest, Empty) {
// Test a persistence store with an empty dictionary.
TEST_F(SdchOwnerPersistenceTest, Persistent_EmptyDict) {
- pref_store_->SetValue("SDCH", new base::DictionaryValue());
+ pref_store_->SetValue("SDCH", new base::DictionaryValue(),
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
ResetOwner(false);
EXPECT_EQ(0, owner_->GetDictionaryCountForTesting());
}
@@ -783,7 +784,8 @@ TEST_F(SdchOwnerPersistenceTest, Persistent_EmptyDict) {
TEST_F(SdchOwnerPersistenceTest, Persistent_BadVersion) {
base::DictionaryValue* sdch_dict = new base::DictionaryValue();
sdch_dict->SetInteger("version", 2);
- pref_store_->SetValue("SDCH", sdch_dict);
+ pref_store_->SetValue("SDCH", sdch_dict,
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
ResetOwner(false);
EXPECT_EQ(0, owner_->GetDictionaryCountForTesting());
@@ -795,7 +797,8 @@ TEST_F(SdchOwnerPersistenceTest, Persistent_EmptyDictList) {
scoped_ptr<base::DictionaryValue> dicts(new base::DictionaryValue());
sdch_dict->SetInteger("version", 1);
sdch_dict->Set("dictionaries", dicts.Pass());
- pref_store_->SetValue("SDCH", sdch_dict);
+ pref_store_->SetValue("SDCH", sdch_dict,
+ WriteablePrefStore::DEFAULT_PREF_WRITE_FLAGS);
ResetOwner(false);
EXPECT_EQ(0, owner_->GetDictionaryCountForTesting());