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

Unified Diff: base/prefs/json_pref_store_unittest.cc

Issue 329173002: Make a JsonPrefStore readable while mid-interception. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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: base/prefs/json_pref_store_unittest.cc
diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc
index 4c9c847708f5f2d3f9845759bfffb7598b68e832..ca9adf3fcc621ae0ebf9a3ac817cb8b05487101d 100644
--- a/base/prefs/json_pref_store_unittest.cc
+++ b/base/prefs/json_pref_store_unittest.cc
@@ -37,7 +37,7 @@ class InterceptingPrefFilter : public PrefFilter {
// PrefFilter implementation:
virtual void FilterOnLoad(
const PostFilterOnLoadCallback& post_filter_on_load_callback,
- scoped_ptr<base::DictionaryValue> pref_store_contents) OVERRIDE;
+ base::DictionaryValue* pref_store_contents) OVERRIDE;
virtual void FilterUpdate(const std::string& path) OVERRIDE {}
virtual void FilterSerializeData(
const base::DictionaryValue* pref_store_contents) OVERRIDE {}
@@ -50,24 +50,25 @@ class InterceptingPrefFilter : public PrefFilter {
private:
PostFilterOnLoadCallback post_filter_on_load_callback_;
- scoped_ptr<base::DictionaryValue> intercepted_prefs_;
+ base::DictionaryValue* intercepted_prefs_;
DISALLOW_COPY_AND_ASSIGN(InterceptingPrefFilter);
};
-InterceptingPrefFilter::InterceptingPrefFilter() {}
+InterceptingPrefFilter::InterceptingPrefFilter() : intercepted_prefs_(NULL) {}
InterceptingPrefFilter::~InterceptingPrefFilter() {}
void InterceptingPrefFilter::FilterOnLoad(
const PostFilterOnLoadCallback& post_filter_on_load_callback,
- scoped_ptr<base::DictionaryValue> pref_store_contents) {
+ base::DictionaryValue* pref_store_contents) {
post_filter_on_load_callback_ = post_filter_on_load_callback;
- intercepted_prefs_ = pref_store_contents.Pass();
+ intercepted_prefs_ = pref_store_contents;
}
void InterceptingPrefFilter::ReleasePrefs() {
gab 2014/06/11 21:12:55 "ReleasePrefs" is technically wrong now that this
EXPECT_FALSE(post_filter_on_load_callback_.is_null());
- post_filter_on_load_callback_.Run(intercepted_prefs_.Pass(), false);
+ intercepted_prefs_ = NULL;
+ post_filter_on_load_callback_.Run(false);
post_filter_on_load_callback_.Reset();
}
@@ -381,7 +382,9 @@ TEST_F(JsonPrefStoreTest, ReadWithInterceptor) {
// returns.
EXPECT_TRUE(raw_intercepting_pref_filter_->has_intercepted_prefs());
EXPECT_FALSE(pref_store->IsInitializationComplete());
- EXPECT_FALSE(pref_store->GetValue(kHomePage, NULL));
+
+ // The store should be readable while mid-interception.
+ EXPECT_TRUE(pref_store->GetValue(kHomePage, NULL));
raw_intercepting_pref_filter_->ReleasePrefs();
@@ -437,7 +440,7 @@ TEST_F(JsonPrefStoreTest, ReadAsyncWithInterceptor) {
EXPECT_FALSE(pref_store->ReadOnly());
EXPECT_TRUE(raw_intercepting_pref_filter_->has_intercepted_prefs());
EXPECT_FALSE(pref_store->IsInitializationComplete());
- EXPECT_FALSE(pref_store->GetValue(kHomePage, NULL));
+ EXPECT_TRUE(pref_store->GetValue(kHomePage, NULL));
}
{

Powered by Google App Engine
This is Rietveld 408576698