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/pref_service.h" | 5 #include "base/prefs/pref_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 DCHECK(CalledOnValidThread()); | 60 DCHECK(CalledOnValidThread()); |
61 | 61 |
62 // Reset pointers so accesses after destruction reliably crash. | 62 // Reset pointers so accesses after destruction reliably crash. |
63 pref_value_store_.reset(); | 63 pref_value_store_.reset(); |
64 pref_registry_ = NULL; | 64 pref_registry_ = NULL; |
65 user_pref_store_ = NULL; | 65 user_pref_store_ = NULL; |
66 pref_notifier_.reset(); | 66 pref_notifier_.reset(); |
67 } | 67 } |
68 | 68 |
69 void PrefService::InitFromStorage(bool async) { | 69 void PrefService::InitFromStorage(bool async) { |
70 if (!async) { | 70 if (user_pref_store_->IsInitializationComplete()) { |
| 71 read_error_callback_.Run(user_pref_store_->GetReadError()); |
| 72 } else if (!async) { |
71 read_error_callback_.Run(user_pref_store_->ReadPrefs()); | 73 read_error_callback_.Run(user_pref_store_->ReadPrefs()); |
72 } else { | 74 } else { |
73 // Guarantee that initialization happens after this function returned. | 75 // Guarantee that initialization happens after this function returned. |
74 base::MessageLoop::current()->PostTask( | 76 base::MessageLoop::current()->PostTask( |
75 FROM_HERE, | 77 FROM_HERE, |
76 base::Bind(&PersistentPrefStore::ReadPrefsAsync, | 78 base::Bind(&PersistentPrefStore::ReadPrefsAsync, |
77 user_pref_store_.get(), | 79 user_pref_store_.get(), |
78 new ReadErrorHandler(read_error_callback_))); | 80 new ReadErrorHandler(read_error_callback_))); |
79 } | 81 } |
80 } | 82 } |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 DCHECK(found_value->IsType(default_type)); | 546 DCHECK(found_value->IsType(default_type)); |
545 return found_value; | 547 return found_value; |
546 } else { | 548 } else { |
547 // Every registered preference has at least a default value. | 549 // Every registered preference has at least a default value. |
548 NOTREACHED() << "no valid value found for registered pref " << path; | 550 NOTREACHED() << "no valid value found for registered pref " << path; |
549 } | 551 } |
550 } | 552 } |
551 | 553 |
552 return NULL; | 554 return NULL; |
553 } | 555 } |
OLD | NEW |