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

Side by Side Diff: components/prefs/pref_value_map.cc

Issue 2149253003: Switch various ValueTypeToString()s to base::Value::GetTypeName(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@value
Patch Set: rebase Created 4 years, 5 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 #include "components/prefs/pref_value_map.h" 5 #include "components/prefs/pref_value_map.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 PrefValueMap::const_iterator PrefValueMap::begin() const { 69 PrefValueMap::const_iterator PrefValueMap::begin() const {
70 return prefs_.begin(); 70 return prefs_.begin();
71 } 71 }
72 72
73 PrefValueMap::const_iterator PrefValueMap::end() const { 73 PrefValueMap::const_iterator PrefValueMap::end() const {
74 return prefs_.end(); 74 return prefs_.end();
75 } 75 }
76 76
77 bool PrefValueMap::empty() const {
78 return prefs_.empty();
79 }
80
77 bool PrefValueMap::GetBoolean(const std::string& key, 81 bool PrefValueMap::GetBoolean(const std::string& key,
78 bool* value) const { 82 bool* value) const {
79 const base::Value* stored_value = nullptr; 83 const base::Value* stored_value = nullptr;
80 return GetValue(key, &stored_value) && stored_value->GetAsBoolean(value); 84 return GetValue(key, &stored_value) && stored_value->GetAsBoolean(value);
81 } 85 }
82 86
83 void PrefValueMap::SetBoolean(const std::string& key, bool value) { 87 void PrefValueMap::SetBoolean(const std::string& key, bool value) {
84 SetValue(key, base::WrapUnique(new base::FundamentalValue(value))); 88 SetValue(key, base::MakeUnique<base::FundamentalValue>(value));
85 } 89 }
86 90
87 bool PrefValueMap::GetString(const std::string& key, 91 bool PrefValueMap::GetString(const std::string& key,
88 std::string* value) const { 92 std::string* value) const {
89 const base::Value* stored_value = nullptr; 93 const base::Value* stored_value = nullptr;
90 return GetValue(key, &stored_value) && stored_value->GetAsString(value); 94 return GetValue(key, &stored_value) && stored_value->GetAsString(value);
91 } 95 }
92 96
93 void PrefValueMap::SetString(const std::string& key, 97 void PrefValueMap::SetString(const std::string& key,
94 const std::string& value) { 98 const std::string& value) {
95 SetValue(key, base::WrapUnique(new base::StringValue(value))); 99 SetValue(key, base::MakeUnique<base::StringValue>(value));
96 } 100 }
97 101
98 bool PrefValueMap::GetInteger(const std::string& key, int* value) const { 102 bool PrefValueMap::GetInteger(const std::string& key, int* value) const {
99 const base::Value* stored_value = nullptr; 103 const base::Value* stored_value = nullptr;
100 return GetValue(key, &stored_value) && stored_value->GetAsInteger(value); 104 return GetValue(key, &stored_value) && stored_value->GetAsInteger(value);
101 } 105 }
102 106
103 void PrefValueMap::SetInteger(const std::string& key, const int value) { 107 void PrefValueMap::SetInteger(const std::string& key, const int value) {
104 SetValue(key, base::WrapUnique(new base::FundamentalValue(value))); 108 SetValue(key, base::MakeUnique<base::FundamentalValue>(value));
105 } 109 }
106 110
107 void PrefValueMap::SetDouble(const std::string& key, const double value) { 111 void PrefValueMap::SetDouble(const std::string& key, const double value) {
108 SetValue(key, base::WrapUnique(new base::FundamentalValue(value))); 112 SetValue(key, base::MakeUnique<base::FundamentalValue>(value));
109 } 113 }
110 114
111 void PrefValueMap::GetDifferingKeys( 115 void PrefValueMap::GetDifferingKeys(
112 const PrefValueMap* other, 116 const PrefValueMap* other,
113 std::vector<std::string>* differing_keys) const { 117 std::vector<std::string>* differing_keys) const {
114 differing_keys->clear(); 118 differing_keys->clear();
115 119
116 // Put everything into ordered maps. 120 // Put everything into ordered maps.
117 std::map<std::string, base::Value*> this_prefs(prefs_.begin(), prefs_.end()); 121 std::map<std::string, base::Value*> this_prefs(prefs_.begin(), prefs_.end());
118 std::map<std::string, base::Value*> other_prefs(other->prefs_.begin(), 122 std::map<std::string, base::Value*> other_prefs(other->prefs_.begin(),
(...skipping 17 matching lines...) Expand all
136 ++other_pref; 140 ++other_pref;
137 } 141 }
138 } 142 }
139 143
140 // Add the remaining entries. 144 // Add the remaining entries.
141 for ( ; this_pref != this_prefs.end(); ++this_pref) 145 for ( ; this_pref != this_prefs.end(); ++this_pref)
142 differing_keys->push_back(this_pref->first); 146 differing_keys->push_back(this_pref->first);
143 for ( ; other_pref != other_prefs.end(); ++other_pref) 147 for ( ; other_pref != other_prefs.end(); ++other_pref)
144 differing_keys->push_back(other_pref->first); 148 differing_keys->push_back(other_pref->first);
145 } 149 }
OLDNEW
« no previous file with comments | « components/prefs/pref_value_map.h ('k') | tools/json_schema_compiler/test/error_generation_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698