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

Side by Side Diff: chrome/browser/prefs/testing_pref_store.cc

Issue 6894020: Adds async interface method to PersistentPrefStore. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unittest for asyn reading Created 9 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/prefs/testing_pref_store.h" 5 #include "chrome/browser/prefs/testing_pref_store.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 8
9 TestingPrefStore::TestingPrefStore() 9 TestingPrefStore::TestingPrefStore()
10 : read_only_(true), 10 : read_only_(true),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 if (prefs_.RemoveValue(key)) 48 if (prefs_.RemoveValue(key))
49 NotifyPrefValueChanged(key); 49 NotifyPrefValueChanged(key);
50 } 50 }
51 51
52 bool TestingPrefStore::ReadOnly() const { 52 bool TestingPrefStore::ReadOnly() const {
53 return read_only_; 53 return read_only_;
54 } 54 }
55 55
56 PersistentPrefStore::PrefReadError TestingPrefStore::ReadPrefs() { 56 PersistentPrefStore::PrefReadError TestingPrefStore::ReadPrefs() {
57 prefs_.Clear(); 57 prefs_.Clear();
58 NotifyInitializationCompleted();
58 return PersistentPrefStore::PREF_READ_ERROR_NONE; 59 return PersistentPrefStore::PREF_READ_ERROR_NONE;
59 } 60 }
60 61
62 void TestingPrefStore::ReadPrefsAsync(ReadErrorDelegate* error_delegate) {
63 prefs_.Clear();
64 NotifyInitializationCompleted();
65 }
66
61 bool TestingPrefStore::WritePrefs() { 67 bool TestingPrefStore::WritePrefs() {
62 prefs_written_ = true; 68 prefs_written_ = true;
63 return prefs_written_; 69 return prefs_written_;
64 } 70 }
65 71
66 void TestingPrefStore::SetInitializationCompleted() { 72 void TestingPrefStore::SetInitializationCompleted() {
67 init_complete_ = true; 73 init_complete_ = true;
68 NotifyInitializationCompleted(); 74 NotifyInitializationCompleted();
69 } 75 }
70 76
71 void TestingPrefStore::NotifyPrefValueChanged(const std::string& key) { 77 void TestingPrefStore::NotifyPrefValueChanged(const std::string& key) {
72 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); 78 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
73 } 79 }
74 80
75 void TestingPrefStore::NotifyInitializationCompleted() { 81 void TestingPrefStore::NotifyInitializationCompleted() {
76 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted()); 82 FOR_EACH_OBSERVER(Observer, observers_, OnInitializationCompleted(true));
77 } 83 }
78 84
79 void TestingPrefStore::ReportValueChanged(const std::string& key) { 85 void TestingPrefStore::ReportValueChanged(const std::string& key) {
80 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key)); 86 FOR_EACH_OBSERVER(Observer, observers_, OnPrefValueChanged(key));
81 } 87 }
82 88
83 void TestingPrefStore::SetString(const std::string& key, 89 void TestingPrefStore::SetString(const std::string& key,
84 const std::string& value) { 90 const std::string& value) {
85 SetValue(key, Value::CreateStringValue(value)); 91 SetValue(key, Value::CreateStringValue(value));
86 } 92 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 read_only_ = read_only; 128 read_only_ = read_only;
123 } 129 }
124 130
125 void TestingPrefStore::set_prefs_written(bool status) { 131 void TestingPrefStore::set_prefs_written(bool status) {
126 prefs_written_ = status; 132 prefs_written_ = status;
127 } 133 }
128 134
129 bool TestingPrefStore::get_prefs_written() { 135 bool TestingPrefStore::get_prefs_written() {
130 return prefs_written_; 136 return prefs_written_;
131 } 137 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698