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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 FROM_HERE, | 296 FROM_HERE, |
297 base::Bind(&ReadPrefsFromDisk, path_, alternate_path_), | 297 base::Bind(&ReadPrefsFromDisk, path_, alternate_path_), |
298 base::Bind(&JsonPrefStore::OnFileRead, AsWeakPtr())); | 298 base::Bind(&JsonPrefStore::OnFileRead, AsWeakPtr())); |
299 } | 299 } |
300 | 300 |
301 void JsonPrefStore::CommitPendingWrite() { | 301 void JsonPrefStore::CommitPendingWrite() { |
302 DCHECK(CalledOnValidThread()); | 302 DCHECK(CalledOnValidThread()); |
303 | 303 |
304 // Schedule a write for any lossy writes that are outstanding to ensure that | 304 // Schedule a write for any lossy writes that are outstanding to ensure that |
305 // they get flushed when this function is called. | 305 // they get flushed when this function is called. |
306 if (pending_lossy_write_) | 306 SchedulePendingLossyWrites(); |
307 writer_.ScheduleWrite(this); | |
308 | 307 |
309 if (writer_.HasPendingWrite() && !read_only_) | 308 if (writer_.HasPendingWrite() && !read_only_) |
310 writer_.DoScheduledWrite(); | 309 writer_.DoScheduledWrite(); |
311 } | 310 } |
312 | 311 |
| 312 void JsonPrefStore::SchedulePendingLossyWrites() { |
| 313 if (pending_lossy_write_) |
| 314 writer_.ScheduleWrite(this); |
| 315 } |
| 316 |
313 void JsonPrefStore::ReportValueChanged(const std::string& key, uint32 flags) { | 317 void JsonPrefStore::ReportValueChanged(const std::string& key, uint32 flags) { |
314 DCHECK(CalledOnValidThread()); | 318 DCHECK(CalledOnValidThread()); |
315 | 319 |
316 if (pref_filter_) | 320 if (pref_filter_) |
317 pref_filter_->FilterUpdate(key); | 321 pref_filter_->FilterUpdate(key); |
318 | 322 |
319 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); | 323 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); |
320 | 324 |
321 ScheduleWrite(flags); | 325 ScheduleWrite(flags); |
322 } | 326 } |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 DCHECK_EQ(31, num_buckets); | 537 DCHECK_EQ(31, num_buckets); |
534 | 538 |
535 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS | 539 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS |
536 // macro adapted to allow for a dynamically suffixed histogram name. | 540 // macro adapted to allow for a dynamically suffixed histogram name. |
537 // Note: The factory creates and owns the histogram. | 541 // Note: The factory creates and owns the histogram. |
538 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 542 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
539 histogram_name, min_value, max_value, num_buckets, | 543 histogram_name, min_value, max_value, num_buckets, |
540 base::HistogramBase::kUmaTargetedHistogramFlag); | 544 base::HistogramBase::kUmaTargetedHistogramFlag); |
541 return histogram; | 545 return histogram; |
542 } | 546 } |
OLD | NEW |