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

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

Issue 5441002: Clean up pref change notification handling. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_PREFS_DUMMY_PREF_STORE_H_ 5 #ifndef CHROME_TEST_TESTING_PREF_STORE_H_
6 #define CHROME_BROWSER_PREFS_DUMMY_PREF_STORE_H_ 6 #define CHROME_TEST_TESTING_PREF_STORE_H_
7 #pragma once 7 #pragma once
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/scoped_ptr.h" 10 #include "base/scoped_ptr.h"
11 #include "chrome/common/pref_store.h" 11 #include "chrome/common/pref_store_base.h"
12 12
13 class DictionaryValue; 13 class DictionaryValue;
14 14
15 // |DummyPrefStore| is a stub implementation of the |PrefStore| interface. 15 // |TestingPrefStore| is a stub implementation of the |PrefStore| interface.
16 // It allows to get and set the state of the |PrefStore|. 16 // It allows to get and set the state of the |PrefStore| as well as triggering
17 class DummyPrefStore : public PrefStore { 17 // notifications.
18 class TestingPrefStore : public PrefStoreBase {
18 public: 19 public:
19 DummyPrefStore(); 20 TestingPrefStore();
20 virtual ~DummyPrefStore() {} 21 virtual ~TestingPrefStore() {}
21 22
22 virtual DictionaryValue* prefs() const { return prefs_.get(); } 23 virtual DictionaryValue* prefs() const { return prefs_.get(); }
23 24
24 virtual PrefStore::PrefReadError ReadPrefs(); 25 virtual PrefStore::PrefReadError ReadPrefs();
25 26
26 virtual bool ReadOnly() { return read_only_; } 27 virtual bool ReadOnly() { return read_only_; }
27 28
28 virtual bool WritePrefs(); 29 virtual bool WritePrefs();
29 30
30 // Getter and Setter methods for setting and getting the state of the 31 // Getter and Setter methods for setting and getting the state of the
31 // |DummyPrefStore|. 32 // |DummyPrefStore|.
32 virtual void set_read_only(bool read_only) { read_only_ = read_only; } 33 virtual void set_read_only(bool read_only) { read_only_ = read_only; }
33 virtual void set_prefs(DictionaryValue* prefs) { prefs_.reset(prefs); } 34 virtual void set_prefs(DictionaryValue* prefs) { prefs_.reset(prefs); }
34 virtual void set_prefs_written(bool status) { prefs_written_ = status; } 35 virtual void set_prefs_written(bool status) { prefs_written_ = status; }
35 virtual bool get_prefs_written() { return prefs_written_; } 36 virtual bool get_prefs_written() { return prefs_written_; }
36 37
38 // Publish these functions so tests can call them from the outside.
39 void NotifyPrefValueChanged(const std::string& key);
40 void NotifyInitializationCompleted();
41
37 private: 42 private:
38 scoped_ptr<DictionaryValue> prefs_; 43 scoped_ptr<DictionaryValue> prefs_;
39 44
40 // Flag that indicates if the PrefStore is read-only 45 // Flag that indicates if the PrefStore is read-only
41 bool read_only_; 46 bool read_only_;
42 47
43 // Flag that indicates if the method WritePrefs was called. 48 // Flag that indicates if the method WritePrefs was called.
44 bool prefs_written_; 49 bool prefs_written_;
45 50
46 DISALLOW_COPY_AND_ASSIGN(DummyPrefStore); 51 DISALLOW_COPY_AND_ASSIGN(TestingPrefStore);
47 }; 52 };
48 53
49 #endif // CHROME_BROWSER_PREFS_DUMMY_PREF_STORE_H_ 54 #endif // CHROME_TEST_TESTING_PREF_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698