| OLD | NEW |
| 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 #ifndef CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_ |
| 6 #define CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/basictypes.h" | 13 #include "base/basictypes.h" |
| 14 | 14 |
| 15 namespace base { |
| 15 class Value; | 16 class Value; |
| 17 } |
| 16 | 18 |
| 17 // A generic string to value map used by the PrefStore implementations. | 19 // A generic string to value map used by the PrefStore implementations. |
| 18 class PrefValueMap { | 20 class PrefValueMap { |
| 19 public: | 21 public: |
| 20 typedef std::map<std::string, Value*>::iterator iterator; | 22 typedef std::map<std::string, base::Value*>::iterator iterator; |
| 21 typedef std::map<std::string, Value*>::const_iterator const_iterator; | 23 typedef std::map<std::string, base::Value*>::const_iterator const_iterator; |
| 22 | 24 |
| 23 PrefValueMap(); | 25 PrefValueMap(); |
| 24 virtual ~PrefValueMap(); | 26 virtual ~PrefValueMap(); |
| 25 | 27 |
| 26 // Gets the value for |key| and stores it in |value|. Ownership remains with | 28 // Gets the value for |key| and stores it in |value|. Ownership remains with |
| 27 // the map. Returns true if a value is present. If not, |value| is not | 29 // the map. Returns true if a value is present. If not, |value| is not |
| 28 // touched. | 30 // touched. |
| 29 bool GetValue(const std::string& key, const Value** value) const; | 31 bool GetValue(const std::string& key, const base::Value** value) const; |
| 30 bool GetValue(const std::string& key, Value** value); | 32 bool GetValue(const std::string& key, base::Value** value); |
| 31 | 33 |
| 32 // Sets a new |value| for |key|. Takes ownership of |value|, which must be | 34 // Sets a new |value| for |key|. Takes ownership of |value|, which must be |
| 33 // non-NULL. Returns true if the value changed. | 35 // non-NULL. Returns true if the value changed. |
| 34 bool SetValue(const std::string& key, Value* value); | 36 bool SetValue(const std::string& key, base::Value* value); |
| 35 | 37 |
| 36 // Removes the value for |key| from the map. Returns true if a value was | 38 // Removes the value for |key| from the map. Returns true if a value was |
| 37 // removed. | 39 // removed. |
| 38 bool RemoveValue(const std::string& key); | 40 bool RemoveValue(const std::string& key); |
| 39 | 41 |
| 40 // Clears the map. | 42 // Clears the map. |
| 41 void Clear(); | 43 void Clear(); |
| 42 | 44 |
| 43 iterator begin(); | 45 iterator begin(); |
| 44 iterator end(); | 46 iterator end(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 56 // Sets the value for |key| to the string |value|. | 58 // Sets the value for |key| to the string |value|. |
| 57 void SetString(const std::string& key, const std::string& value); | 59 void SetString(const std::string& key, const std::string& value); |
| 58 | 60 |
| 59 // Compares this value map against |other| and stores all key names that have | 61 // Compares this value map against |other| and stores all key names that have |
| 60 // different values in |differing_keys|. This includes keys that are present | 62 // different values in |differing_keys|. This includes keys that are present |
| 61 // only in one of the maps. | 63 // only in one of the maps. |
| 62 void GetDifferingKeys(const PrefValueMap* other, | 64 void GetDifferingKeys(const PrefValueMap* other, |
| 63 std::vector<std::string>* differing_keys) const; | 65 std::vector<std::string>* differing_keys) const; |
| 64 | 66 |
| 65 private: | 67 private: |
| 66 typedef std::map<std::string, Value*> Map; | 68 typedef std::map<std::string, base::Value*> Map; |
| 67 | 69 |
| 68 Map prefs_; | 70 Map prefs_; |
| 69 | 71 |
| 70 DISALLOW_COPY_AND_ASSIGN(PrefValueMap); | 72 DISALLOW_COPY_AND_ASSIGN(PrefValueMap); |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_ | 75 #endif // CHROME_BROWSER_PREFS_PREF_VALUE_MAP_H_ |
| OLD | NEW |