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

Side by Side Diff: base/prefs/pref_value_map.h

Issue 1124763003: Update from https://crrev.com/327068 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: update nacl, buildtools, fix display_change_notifier_unittest Created 5 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
OLDNEW
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 BASE_PREFS_PREF_VALUE_MAP_H_ 5 #ifndef BASE_PREFS_PREF_VALUE_MAP_H_
6 #define BASE_PREFS_PREF_VALUE_MAP_H_ 6 #define BASE_PREFS_PREF_VALUE_MAP_H_
7 7
8 #include <map>
9 #include <string> 8 #include <string>
10 #include <vector> 9 #include <vector>
11 10
12 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/containers/hash_tables.h"
13 #include "base/prefs/base_prefs_export.h" 13 #include "base/prefs/base_prefs_export.h"
14 14
15 namespace base { 15 namespace base {
16 class Value; 16 class Value;
17 } 17 }
18 18
19 // A generic string to value map used by the PrefStore implementations. 19 // A generic string to value map used by the PrefStore implementations.
20 class BASE_PREFS_EXPORT PrefValueMap { 20 class BASE_PREFS_EXPORT PrefValueMap {
21 public: 21 public:
22 typedef std::map<std::string, base::Value*>::iterator iterator; 22 using Map = base::hash_map<std::string, base::Value*>;
23 typedef std::map<std::string, base::Value*>::const_iterator const_iterator; 23 using iterator = Map::iterator;
24 using const_iterator = Map::const_iterator;
24 25
25 PrefValueMap(); 26 PrefValueMap();
26 virtual ~PrefValueMap(); 27 virtual ~PrefValueMap();
27 28
28 // Gets the value for |key| and stores it in |value|. Ownership remains with 29 // Gets the value for |key| and stores it in |value|. Ownership remains with
29 // the map. Returns true if a value is present. If not, |value| is not 30 // the map. Returns true if a value is present. If not, |value| is not
30 // touched. 31 // touched.
31 bool GetValue(const std::string& key, const base::Value** value) const; 32 bool GetValue(const std::string& key, const base::Value** value) const;
32 bool GetValue(const std::string& key, base::Value** value); 33 bool GetValue(const std::string& key, base::Value** value);
33 34
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Sets the value for |key| to the double |value|. 75 // Sets the value for |key| to the double |value|.
75 void SetDouble(const std::string& key, const double value); 76 void SetDouble(const std::string& key, const double value);
76 77
77 // Compares this value map against |other| and stores all key names that have 78 // Compares this value map against |other| and stores all key names that have
78 // different values in |differing_keys|. This includes keys that are present 79 // different values in |differing_keys|. This includes keys that are present
79 // only in one of the maps. 80 // only in one of the maps.
80 void GetDifferingKeys(const PrefValueMap* other, 81 void GetDifferingKeys(const PrefValueMap* other,
81 std::vector<std::string>* differing_keys) const; 82 std::vector<std::string>* differing_keys) const;
82 83
83 private: 84 private:
84 typedef std::map<std::string, base::Value*> Map;
85
86 Map prefs_; 85 Map prefs_;
87 86
88 DISALLOW_COPY_AND_ASSIGN(PrefValueMap); 87 DISALLOW_COPY_AND_ASSIGN(PrefValueMap);
89 }; 88 };
90 89
91 #endif // BASE_PREFS_PREF_VALUE_MAP_H_ 90 #endif // BASE_PREFS_PREF_VALUE_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698