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

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

Issue 1641513004: Update //base to chromium 9659b08ea5a34f889dc4166217f438095ddc10d2 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 10 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/json_pref_store.h" 5 #include "base/prefs/json_pref_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 } 214 }
215 215
216 bool JsonPrefStore::GetMutableValue(const std::string& key, 216 bool JsonPrefStore::GetMutableValue(const std::string& key,
217 base::Value** result) { 217 base::Value** result) {
218 DCHECK(CalledOnValidThread()); 218 DCHECK(CalledOnValidThread());
219 219
220 return prefs_->Get(key, result); 220 return prefs_->Get(key, result);
221 } 221 }
222 222
223 void JsonPrefStore::SetValue(const std::string& key, 223 void JsonPrefStore::SetValue(const std::string& key,
224 base::Value* value, 224 scoped_ptr<base::Value> value,
225 uint32 flags) { 225 uint32 flags) {
226 DCHECK(CalledOnValidThread()); 226 DCHECK(CalledOnValidThread());
227 227
228 DCHECK(value); 228 DCHECK(value);
229 scoped_ptr<base::Value> new_value(value);
230 base::Value* old_value = NULL; 229 base::Value* old_value = NULL;
231 prefs_->Get(key, &old_value); 230 prefs_->Get(key, &old_value);
232 if (!old_value || !value->Equals(old_value)) { 231 if (!old_value || !value->Equals(old_value)) {
233 prefs_->Set(key, new_value.Pass()); 232 prefs_->Set(key, value.Pass());
234 ReportValueChanged(key, flags); 233 ReportValueChanged(key, flags);
235 } 234 }
236 } 235 }
237 236
238 void JsonPrefStore::SetValueSilently(const std::string& key, 237 void JsonPrefStore::SetValueSilently(const std::string& key,
239 base::Value* value, 238 scoped_ptr<base::Value> value,
240 uint32 flags) { 239 uint32 flags) {
241 DCHECK(CalledOnValidThread()); 240 DCHECK(CalledOnValidThread());
242 241
243 DCHECK(value); 242 DCHECK(value);
244 scoped_ptr<base::Value> new_value(value);
245 base::Value* old_value = NULL; 243 base::Value* old_value = NULL;
246 prefs_->Get(key, &old_value); 244 prefs_->Get(key, &old_value);
247 if (!old_value || !value->Equals(old_value)) { 245 if (!old_value || !value->Equals(old_value)) {
248 prefs_->Set(key, new_value.Pass()); 246 prefs_->Set(key, value.Pass());
249 ScheduleWrite(flags); 247 ScheduleWrite(flags);
250 } 248 }
251 } 249 }
252 250
253 void JsonPrefStore::RemoveValue(const std::string& key, uint32 flags) { 251 void JsonPrefStore::RemoveValue(const std::string& key, uint32 flags) {
254 DCHECK(CalledOnValidThread()); 252 DCHECK(CalledOnValidThread());
255 253
256 if (prefs_->RemovePath(key, NULL)) 254 if (prefs_->RemovePath(key, NULL))
257 ReportValueChanged(key, flags); 255 ReportValueChanged(key, flags);
258 } 256 }
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 DCHECK_EQ(31, num_buckets); 535 DCHECK_EQ(31, num_buckets);
538 536
539 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS 537 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS
540 // macro adapted to allow for a dynamically suffixed histogram name. 538 // macro adapted to allow for a dynamically suffixed histogram name.
541 // Note: The factory creates and owns the histogram. 539 // Note: The factory creates and owns the histogram.
542 base::HistogramBase* histogram = base::Histogram::FactoryGet( 540 base::HistogramBase* histogram = base::Histogram::FactoryGet(
543 histogram_name, min_value, max_value, num_buckets, 541 histogram_name, min_value, max_value, num_buckets,
544 base::HistogramBase::kUmaTargetedHistogramFlag); 542 base::HistogramBase::kUmaTargetedHistogramFlag);
545 return histogram; 543 return histogram;
546 } 544 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698