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

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

Issue 11243002: Move the bits of Prefs where production code has only trivially easy (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments, fix gypi problem Created 8 years, 2 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
« no previous file with comments | « chrome/browser/prefs/pref_service_unittest.cc ('k') | chrome/browser/prefs/pref_value_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_
6 #define CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "base/basictypes.h"
13
14 namespace base {
15 class Value;
16 }
17
18 // A generic string to value map used by the PrefStore implementations.
19 class PrefValueMap {
20 public:
21 typedef std::map<std::string, base::Value*>::iterator iterator;
22 typedef std::map<std::string, base::Value*>::const_iterator const_iterator;
23
24 PrefValueMap();
25 virtual ~PrefValueMap();
26
27 // Gets the value for |key| and stores it in |value|. Ownership remains with
28 // the map. Returns true if a value is present. If not, |value| is not
29 // touched.
30 bool GetValue(const std::string& key, const base::Value** value) const;
31 bool GetValue(const std::string& key, base::Value** value);
32
33 // Sets a new |value| for |key|. Takes ownership of |value|, which must be
34 // non-NULL. Returns true if the value changed.
35 bool SetValue(const std::string& key, base::Value* value);
36
37 // Removes the value for |key| from the map. Returns true if a value was
38 // removed.
39 bool RemoveValue(const std::string& key);
40
41 // Clears the map.
42 void Clear();
43
44 // Swaps the contents of two maps.
45 void Swap(PrefValueMap* other);
46
47 iterator begin();
48 iterator end();
49 const_iterator begin() const;
50 const_iterator end() const;
51
52 // Gets a boolean value for |key| and stores it in |value|. Returns true if
53 // the value was found and of the proper type.
54 bool GetBoolean(const std::string& key, bool* value) const;
55
56 // Sets the value for |key| to the boolean |value|.
57 void SetBoolean(const std::string& key, bool value);
58
59 // Gets a string value for |key| and stores it in |value|. Returns true if
60 // the value was found and of the proper type.
61 bool GetString(const std::string& key, std::string* value) const;
62
63 // Sets the value for |key| to the string |value|.
64 void SetString(const std::string& key, const std::string& value);
65
66 // Gets an int value for |key| and stores it in |value|. Returns true if
67 // the value was found and of the proper type.
68 bool GetInteger(const std::string& key, int* value) const;
69
70 // Sets the value for |key| to the int |value|.
71 void SetInteger(const std::string& key, const int value);
72
73 // Compares this value map against |other| and stores all key names that have
74 // different values in |differing_keys|. This includes keys that are present
75 // only in one of the maps.
76 void GetDifferingKeys(const PrefValueMap* other,
77 std::vector<std::string>* differing_keys) const;
78
79 private:
80 typedef std::map<std::string, base::Value*> Map;
81
82 Map prefs_;
83
84 DISALLOW_COPY_AND_ASSIGN(PrefValueMap);
85 };
86
87 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_service_unittest.cc ('k') | chrome/browser/prefs/pref_value_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698