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