| 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 COMPONENTS_PREFS_PREF_VALUE_MAP_H_ | 5 #ifndef COMPONENTS_PREFS_PREF_VALUE_MAP_H_ |
| 6 #define COMPONENTS_PREFS_PREF_VALUE_MAP_H_ | 6 #define COMPONENTS_PREFS_PREF_VALUE_MAP_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <unordered_map> | 10 #include <unordered_map> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "components/prefs/base_prefs_export.h" | 14 #include "components/prefs/base_prefs_export.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class DictionaryValue; | |
| 18 class Value; | 17 class Value; |
| 19 } | 18 } |
| 20 | 19 |
| 21 // A generic string to value map used by the PrefStore implementations. | 20 // A generic string to value map used by the PrefStore implementations. |
| 22 class COMPONENTS_PREFS_EXPORT PrefValueMap { | 21 class COMPONENTS_PREFS_EXPORT PrefValueMap { |
| 23 public: | 22 public: |
| 24 using Map = std::unordered_map<std::string, std::unique_ptr<base::Value>>; | 23 using Map = std::unordered_map<std::string, std::unique_ptr<base::Value>>; |
| 25 using iterator = Map::iterator; | 24 using iterator = Map::iterator; |
| 26 using const_iterator = Map::const_iterator; | 25 using const_iterator = Map::const_iterator; |
| 27 | 26 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 76 |
| 78 // Sets the value for |key| to the double |value|. | 77 // Sets the value for |key| to the double |value|. |
| 79 void SetDouble(const std::string& key, const double value); | 78 void SetDouble(const std::string& key, const double value); |
| 80 | 79 |
| 81 // Compares this value map against |other| and stores all key names that have | 80 // Compares this value map against |other| and stores all key names that have |
| 82 // different values in |differing_keys|. This includes keys that are present | 81 // different values in |differing_keys|. This includes keys that are present |
| 83 // only in one of the maps. | 82 // only in one of the maps. |
| 84 void GetDifferingKeys(const PrefValueMap* other, | 83 void GetDifferingKeys(const PrefValueMap* other, |
| 85 std::vector<std::string>* differing_keys) const; | 84 std::vector<std::string>* differing_keys) const; |
| 86 | 85 |
| 87 // Copies the map into a dictionary value. | |
| 88 std::unique_ptr<base::DictionaryValue> AsDictionaryValue() const; | |
| 89 | |
| 90 private: | 86 private: |
| 91 Map prefs_; | 87 Map prefs_; |
| 92 | 88 |
| 93 DISALLOW_COPY_AND_ASSIGN(PrefValueMap); | 89 DISALLOW_COPY_AND_ASSIGN(PrefValueMap); |
| 94 }; | 90 }; |
| 95 | 91 |
| 96 #endif // COMPONENTS_PREFS_PREF_VALUE_MAP_H_ | 92 #endif // COMPONENTS_PREFS_PREF_VALUE_MAP_H_ |
| OLD | NEW |