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

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

Issue 11519026: base: Do not use Value::Create* functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: scoped_ptr Created 8 years 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 | « base/prefs/overlay_user_pref_store_unittest.cc ('k') | base/prefs/pref_value_map_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/prefs/pref_value_map.h" 5 #include "base/prefs/pref_value_map.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 return prefs_.end(); 89 return prefs_.end();
90 } 90 }
91 91
92 bool PrefValueMap::GetBoolean(const std::string& key, 92 bool PrefValueMap::GetBoolean(const std::string& key,
93 bool* value) const { 93 bool* value) const {
94 const Value* stored_value = NULL; 94 const Value* stored_value = NULL;
95 return GetValue(key, &stored_value) && stored_value->GetAsBoolean(value); 95 return GetValue(key, &stored_value) && stored_value->GetAsBoolean(value);
96 } 96 }
97 97
98 void PrefValueMap::SetBoolean(const std::string& key, bool value) { 98 void PrefValueMap::SetBoolean(const std::string& key, bool value) {
99 SetValue(key, Value::CreateBooleanValue(value)); 99 SetValue(key, new base::FundamentalValue(value));
100 } 100 }
101 101
102 bool PrefValueMap::GetString(const std::string& key, 102 bool PrefValueMap::GetString(const std::string& key,
103 std::string* value) const { 103 std::string* value) const {
104 const Value* stored_value = NULL; 104 const Value* stored_value = NULL;
105 return GetValue(key, &stored_value) && stored_value->GetAsString(value); 105 return GetValue(key, &stored_value) && stored_value->GetAsString(value);
106 } 106 }
107 107
108 void PrefValueMap::SetString(const std::string& key, 108 void PrefValueMap::SetString(const std::string& key,
109 const std::string& value) { 109 const std::string& value) {
110 SetValue(key, Value::CreateStringValue(value)); 110 SetValue(key, new base::StringValue(value));
111 } 111 }
112 112
113 bool PrefValueMap::GetInteger(const std::string& key, int* value) const { 113 bool PrefValueMap::GetInteger(const std::string& key, int* value) const {
114 const Value* stored_value = NULL; 114 const Value* stored_value = NULL;
115 return GetValue(key, &stored_value) && stored_value->GetAsInteger(value); 115 return GetValue(key, &stored_value) && stored_value->GetAsInteger(value);
116 } 116 }
117 117
118 void PrefValueMap::SetInteger(const std::string& key, const int value) { 118 void PrefValueMap::SetInteger(const std::string& key, const int value) {
119 SetValue(key, Value::CreateIntegerValue(value)); 119 SetValue(key, new base::FundamentalValue(value));
120 } 120 }
121 121
122 void PrefValueMap::GetDifferingKeys( 122 void PrefValueMap::GetDifferingKeys(
123 const PrefValueMap* other, 123 const PrefValueMap* other,
124 std::vector<std::string>* differing_keys) const { 124 std::vector<std::string>* differing_keys) const {
125 differing_keys->clear(); 125 differing_keys->clear();
126 126
127 // Walk over the maps in lockstep, adding everything that is different. 127 // Walk over the maps in lockstep, adding everything that is different.
128 Map::const_iterator this_pref(prefs_.begin()); 128 Map::const_iterator this_pref(prefs_.begin());
129 Map::const_iterator other_pref(other->prefs_.begin()); 129 Map::const_iterator other_pref(other->prefs_.begin());
(...skipping 12 matching lines...) Expand all
142 ++other_pref; 142 ++other_pref;
143 } 143 }
144 } 144 }
145 145
146 // Add the remaining entries. 146 // Add the remaining entries.
147 for ( ; this_pref != prefs_.end(); ++this_pref) 147 for ( ; this_pref != prefs_.end(); ++this_pref)
148 differing_keys->push_back(this_pref->first); 148 differing_keys->push_back(this_pref->first);
149 for ( ; other_pref != other->prefs_.end(); ++other_pref) 149 for ( ; other_pref != other->prefs_.end(); ++other_pref)
150 differing_keys->push_back(other_pref->first); 150 differing_keys->push_back(other_pref->first);
151 } 151 }
OLDNEW
« no previous file with comments | « base/prefs/overlay_user_pref_store_unittest.cc ('k') | base/prefs/pref_value_map_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698