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 "components/prefs/json_pref_store.h" | 5 #include "components/prefs/json_pref_store.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 if (pending_lossy_write_) | 313 if (pending_lossy_write_) |
314 writer_.ScheduleWrite(this); | 314 writer_.ScheduleWrite(this); |
315 } | 315 } |
316 | 316 |
317 void JsonPrefStore::ReportValueChanged(const std::string& key, uint32_t flags) { | 317 void JsonPrefStore::ReportValueChanged(const std::string& key, uint32_t flags) { |
318 DCHECK(CalledOnValidThread()); | 318 DCHECK(CalledOnValidThread()); |
319 | 319 |
320 if (pref_filter_) | 320 if (pref_filter_) |
321 pref_filter_->FilterUpdate(key); | 321 pref_filter_->FilterUpdate(key); |
322 | 322 |
323 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); | 323 for (PrefStore::Observer& observer : observers_) |
| 324 observer.OnPrefValueChanged(key); |
324 | 325 |
325 ScheduleWrite(flags); | 326 ScheduleWrite(flags); |
326 } | 327 } |
327 | 328 |
328 void JsonPrefStore::RunOrScheduleNextSuccessfulWriteCallback( | 329 void JsonPrefStore::RunOrScheduleNextSuccessfulWriteCallback( |
329 bool write_success) { | 330 bool write_success) { |
330 DCHECK(CalledOnValidThread()); | 331 DCHECK(CalledOnValidThread()); |
331 | 332 |
332 has_pending_write_reply_ = false; | 333 has_pending_write_reply_ = false; |
333 if (!on_next_successful_write_reply_.is_null()) { | 334 if (!on_next_successful_write_reply_.is_null()) { |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 482 |
482 void JsonPrefStore::FinalizeFileRead( | 483 void JsonPrefStore::FinalizeFileRead( |
483 bool initialization_successful, | 484 bool initialization_successful, |
484 std::unique_ptr<base::DictionaryValue> prefs, | 485 std::unique_ptr<base::DictionaryValue> prefs, |
485 bool schedule_write) { | 486 bool schedule_write) { |
486 DCHECK(CalledOnValidThread()); | 487 DCHECK(CalledOnValidThread()); |
487 | 488 |
488 filtering_in_progress_ = false; | 489 filtering_in_progress_ = false; |
489 | 490 |
490 if (!initialization_successful) { | 491 if (!initialization_successful) { |
491 FOR_EACH_OBSERVER(PrefStore::Observer, | 492 for (PrefStore::Observer& observer : observers_) |
492 observers_, | 493 observer.OnInitializationCompleted(false); |
493 OnInitializationCompleted(false)); | |
494 return; | 494 return; |
495 } | 495 } |
496 | 496 |
497 prefs_ = std::move(prefs); | 497 prefs_ = std::move(prefs); |
498 | 498 |
499 initialized_ = true; | 499 initialized_ = true; |
500 | 500 |
501 if (schedule_write) | 501 if (schedule_write) |
502 ScheduleWrite(DEFAULT_PREF_WRITE_FLAGS); | 502 ScheduleWrite(DEFAULT_PREF_WRITE_FLAGS); |
503 | 503 |
504 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) | 504 if (error_delegate_ && read_error_ != PREF_READ_ERROR_NONE) |
505 error_delegate_->OnError(read_error_); | 505 error_delegate_->OnError(read_error_); |
506 | 506 |
507 FOR_EACH_OBSERVER(PrefStore::Observer, | 507 for (PrefStore::Observer& observer : observers_) |
508 observers_, | 508 observer.OnInitializationCompleted(true); |
509 OnInitializationCompleted(true)); | |
510 | 509 |
511 return; | 510 return; |
512 } | 511 } |
513 | 512 |
514 void JsonPrefStore::ScheduleWrite(uint32_t flags) { | 513 void JsonPrefStore::ScheduleWrite(uint32_t flags) { |
515 if (read_only_) | 514 if (read_only_) |
516 return; | 515 return; |
517 | 516 |
518 if (flags & LOSSY_PREF_WRITE_FLAG) | 517 if (flags & LOSSY_PREF_WRITE_FLAG) |
519 pending_lossy_write_ = true; | 518 pending_lossy_write_ = true; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 DCHECK_EQ(31, num_buckets); | 599 DCHECK_EQ(31, num_buckets); |
601 | 600 |
602 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS | 601 // The histogram below is an expansion of the UMA_HISTOGRAM_CUSTOM_COUNTS |
603 // macro adapted to allow for a dynamically suffixed histogram name. | 602 // macro adapted to allow for a dynamically suffixed histogram name. |
604 // Note: The factory creates and owns the histogram. | 603 // Note: The factory creates and owns the histogram. |
605 base::HistogramBase* histogram = base::Histogram::FactoryGet( | 604 base::HistogramBase* histogram = base::Histogram::FactoryGet( |
606 histogram_name, min_value, max_value, num_buckets, | 605 histogram_name, min_value, max_value, num_buckets, |
607 base::HistogramBase::kUmaTargetedHistogramFlag); | 606 base::HistogramBase::kUmaTargetedHistogramFlag); |
608 return histogram; | 607 return histogram; |
609 } | 608 } |
OLD | NEW |