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

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

Issue 10068036: RefCounted types should not have public destructors, chrome/browser/ part 5 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Win fix Created 8 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_VALUE_MAP_PREF_STORE_H_ 5 #ifndef CHROME_BROWSER_PREFS_VALUE_MAP_PREF_STORE_H_
6 #define CHROME_BROWSER_PREFS_VALUE_MAP_PREF_STORE_H_ 6 #define CHROME_BROWSER_PREFS_VALUE_MAP_PREF_STORE_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chrome/browser/prefs/pref_value_map.h" 14 #include "chrome/browser/prefs/pref_value_map.h"
15 #include "chrome/common/pref_store.h" 15 #include "chrome/common/pref_store.h"
16 16
17 // A basic PrefStore implementation that uses a simple name-value map for 17 // A basic PrefStore implementation that uses a simple name-value map for
18 // storing the preference values. 18 // storing the preference values.
19 class ValueMapPrefStore : public PrefStore { 19 class ValueMapPrefStore : public PrefStore {
20 public: 20 public:
21 typedef std::map<std::string, base::Value*>::iterator iterator; 21 typedef std::map<std::string, base::Value*>::iterator iterator;
22 typedef std::map<std::string, base::Value*>::const_iterator const_iterator; 22 typedef std::map<std::string, base::Value*>::const_iterator const_iterator;
23 23
24 ValueMapPrefStore(); 24 ValueMapPrefStore();
25 virtual ~ValueMapPrefStore();
26 25
27 // PrefStore overrides: 26 // PrefStore overrides:
28 virtual ReadResult GetValue(const std::string& key, 27 virtual ReadResult GetValue(const std::string& key,
29 const base::Value** value) const OVERRIDE; 28 const base::Value** value) const OVERRIDE;
30 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE; 29 virtual void AddObserver(PrefStore::Observer* observer) OVERRIDE;
31 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE; 30 virtual void RemoveObserver(PrefStore::Observer* observer) OVERRIDE;
32 virtual size_t NumberOfObservers() const OVERRIDE; 31 virtual size_t NumberOfObservers() const OVERRIDE;
33 32
34 iterator begin(); 33 iterator begin();
35 iterator end(); 34 iterator end();
36 const_iterator begin() const; 35 const_iterator begin() const;
37 const_iterator end() const; 36 const_iterator end() const;
38 37
39 protected: 38 protected:
39 virtual ~ValueMapPrefStore();
40
40 // Store a |value| for |key| in the store. Also generates an notification if 41 // Store a |value| for |key| in the store. Also generates an notification if
41 // the value changed. Assumes ownership of |value|, which must be non-NULL. 42 // the value changed. Assumes ownership of |value|, which must be non-NULL.
42 void SetValue(const std::string& key, base::Value* value); 43 void SetValue(const std::string& key, base::Value* value);
43 44
44 // Remove the value for |key| from the store. Sends a notification if there 45 // Remove the value for |key| from the store. Sends a notification if there
45 // was a value to be removed. 46 // was a value to be removed.
46 void RemoveValue(const std::string& key); 47 void RemoveValue(const std::string& key);
47 48
48 // Notify observers about the initialization completed event. 49 // Notify observers about the initialization completed event.
49 void NotifyInitializationCompleted(); 50 void NotifyInitializationCompleted();
50 51
51 private: 52 private:
52 PrefValueMap prefs_; 53 PrefValueMap prefs_;
53 54
54 ObserverList<PrefStore::Observer, true> observers_; 55 ObserverList<PrefStore::Observer, true> observers_;
55 56
56 DISALLOW_COPY_AND_ASSIGN(ValueMapPrefStore); 57 DISALLOW_COPY_AND_ASSIGN(ValueMapPrefStore);
57 }; 58 };
58 59
59 #endif // CHROME_BROWSER_PREFS_VALUE_MAP_PREF_STORE_H_ 60 #endif // CHROME_BROWSER_PREFS_VALUE_MAP_PREF_STORE_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/testing_pref_store.cc ('k') | chrome/browser/prefs/value_map_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698