OLD | NEW |
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 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 void JsonPrefStore::SetValue(const std::string& key, | 223 void JsonPrefStore::SetValue(const std::string& key, |
224 base::Value* value, | 224 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); | 229 scoped_ptr<base::Value> new_value(value); |
230 base::Value* old_value = NULL; | 230 base::Value* old_value = NULL; |
231 prefs_->Get(key, &old_value); | 231 prefs_->Get(key, &old_value); |
232 if (!old_value || !value->Equals(old_value)) { | 232 if (!old_value || !value->Equals(old_value)) { |
233 prefs_->Set(key, new_value.release()); | 233 prefs_->Set(key, new_value.Pass()); |
234 ReportValueChanged(key, flags); | 234 ReportValueChanged(key, flags); |
235 } | 235 } |
236 } | 236 } |
237 | 237 |
238 void JsonPrefStore::SetValueSilently(const std::string& key, | 238 void JsonPrefStore::SetValueSilently(const std::string& key, |
239 base::Value* value, | 239 base::Value* value, |
240 uint32 flags) { | 240 uint32 flags) { |
241 DCHECK(CalledOnValidThread()); | 241 DCHECK(CalledOnValidThread()); |
242 | 242 |
243 DCHECK(value); | 243 DCHECK(value); |
244 scoped_ptr<base::Value> new_value(value); | 244 scoped_ptr<base::Value> new_value(value); |
245 base::Value* old_value = NULL; | 245 base::Value* old_value = NULL; |
246 prefs_->Get(key, &old_value); | 246 prefs_->Get(key, &old_value); |
247 if (!old_value || !value->Equals(old_value)) { | 247 if (!old_value || !value->Equals(old_value)) { |
248 prefs_->Set(key, new_value.release()); | 248 prefs_->Set(key, new_value.Pass()); |
249 ScheduleWrite(flags); | 249 ScheduleWrite(flags); |
250 } | 250 } |
251 } | 251 } |
252 | 252 |
253 void JsonPrefStore::RemoveValue(const std::string& key, uint32 flags) { | 253 void JsonPrefStore::RemoveValue(const std::string& key, uint32 flags) { |
254 DCHECK(CalledOnValidThread()); | 254 DCHECK(CalledOnValidThread()); |
255 | 255 |
256 if (prefs_->RemovePath(key, NULL)) | 256 if (prefs_->RemovePath(key, NULL)) |
257 ReportValueChanged(key, flags); | 257 ReportValueChanged(key, flags); |
258 } | 258 } |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 DCHECK_EQ(31, num_buckets); | 533 DCHECK_EQ(31, num_buckets); |
534 | 534 |
535 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS | 535 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS |
536 // macro adapted to allow for a dynamically suffixed histogram name. | 536 // macro adapted to allow for a dynamically suffixed histogram name. |
537 // Note: The factory creates and owns the histogram. | 537 // Note: The factory creates and owns the histogram. |
538 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 538 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
539 histogram_name, min_value, max_value, num_buckets, | 539 histogram_name, min_value, max_value, num_buckets, |
540 base::HistogramBase::kUmaTargetedHistogramFlag); | 540 base::HistogramBase::kUmaTargetedHistogramFlag); |
541 return histogram; | 541 return histogram; |
542 } | 542 } |
OLD | NEW |