| 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/pref_service.h" | 5 #include "components/prefs/pref_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 | 91 |
| 92 void PrefService::InitFromStorage(bool async) { | 92 void PrefService::InitFromStorage(bool async) { |
| 93 if (user_pref_store_->IsInitializationComplete()) { | 93 if (user_pref_store_->IsInitializationComplete()) { |
| 94 read_error_callback_.Run(user_pref_store_->GetReadError()); | 94 read_error_callback_.Run(user_pref_store_->GetReadError()); |
| 95 } else if (!async) { | 95 } else if (!async) { |
| 96 read_error_callback_.Run(user_pref_store_->ReadPrefs()); | 96 read_error_callback_.Run(user_pref_store_->ReadPrefs()); |
| 97 } else { | 97 } else { |
| 98 // Guarantee that initialization happens after this function returned. | 98 // Guarantee that initialization happens after this function returned. |
| 99 base::ThreadTaskRunnerHandle::Get()->PostTask( | 99 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 100 FROM_HERE, | 100 FROM_HERE, |
| 101 base::Bind(&PersistentPrefStore::ReadPrefsAsync, user_pref_store_.get(), | 101 base::Bind(&PersistentPrefStore::ReadPrefsAsync, user_pref_store_, |
| 102 new ReadErrorHandler(read_error_callback_))); | 102 new ReadErrorHandler(read_error_callback_))); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 void PrefService::CommitPendingWrite() { | 106 void PrefService::CommitPendingWrite() { |
| 107 DCHECK(CalledOnValidThread()); | 107 DCHECK(CalledOnValidThread()); |
| 108 user_pref_store_->CommitPendingWrite(); | 108 user_pref_store_->CommitPendingWrite(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void PrefService::SchedulePendingLossyWrites() { | 111 void PrefService::SchedulePendingLossyWrites() { |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 613 DCHECK(found_value->IsType(default_type)); | 613 DCHECK(found_value->IsType(default_type)); |
| 614 return found_value; | 614 return found_value; |
| 615 } else { | 615 } else { |
| 616 // Every registered preference has at least a default value. | 616 // Every registered preference has at least a default value. |
| 617 NOTREACHED() << "no valid value found for registered pref " << path; | 617 NOTREACHED() << "no valid value found for registered pref " << path; |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 return NULL; | 621 return NULL; |
| 622 } | 622 } |
| OLD | NEW |