OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/prefs/overlay_persistent_pref_store.h" | 5 #include "chrome/browser/prefs/overlay_persistent_pref_store.h" |
6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" |
7 #include "base/values.h" | 8 #include "base/values.h" |
8 | 9 |
9 OverlayPersistentPrefStore::OverlayPersistentPrefStore( | 10 OverlayPersistentPrefStore::OverlayPersistentPrefStore( |
10 PersistentPrefStore* underlay) | 11 PersistentPrefStore* underlay) |
11 : underlay_(underlay) { | 12 : underlay_(underlay) { |
12 underlay_->AddObserver(this); | 13 underlay_->AddObserver(this); |
13 } | 14 } |
14 OverlayPersistentPrefStore::~OverlayPersistentPrefStore() { | 15 OverlayPersistentPrefStore::~OverlayPersistentPrefStore() { |
15 underlay_->RemoveObserver(this); | 16 underlay_->RemoveObserver(this); |
16 } | 17 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 if (overlay_.RemoveValue(key)) | 74 if (overlay_.RemoveValue(key)) |
74 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); | 75 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); |
75 } | 76 } |
76 | 77 |
77 bool OverlayPersistentPrefStore::ReadOnly() const { | 78 bool OverlayPersistentPrefStore::ReadOnly() const { |
78 return false; | 79 return false; |
79 } | 80 } |
80 | 81 |
81 PersistentPrefStore::PrefReadError OverlayPersistentPrefStore::ReadPrefs() { | 82 PersistentPrefStore::PrefReadError OverlayPersistentPrefStore::ReadPrefs() { |
82 // We do not read intentionally. | 83 // We do not read intentionally. |
| 84 OnInitializationCompleted(true); |
83 return PersistentPrefStore::PREF_READ_ERROR_NONE; | 85 return PersistentPrefStore::PREF_READ_ERROR_NONE; |
84 } | 86 } |
85 | 87 |
| 88 void OverlayPersistentPrefStore::ReadPrefsAsync( |
| 89 ReadErrorDelegate* error_delegate_raw) { |
| 90 scoped_ptr<ReadErrorDelegate> error_delegate(error_delegate_raw); |
| 91 // We do not read intentionally. |
| 92 OnInitializationCompleted(true); |
| 93 } |
| 94 |
86 bool OverlayPersistentPrefStore::WritePrefs() { | 95 bool OverlayPersistentPrefStore::WritePrefs() { |
87 // We do not write intentionally. | 96 // We do not write intentionally. |
88 return true; | 97 return true; |
89 } | 98 } |
90 | 99 |
91 void OverlayPersistentPrefStore::ScheduleWritePrefs() { | 100 void OverlayPersistentPrefStore::ScheduleWritePrefs() { |
92 // We do not write intentionally. | 101 // We do not write intentionally. |
93 } | 102 } |
94 | 103 |
95 void OverlayPersistentPrefStore::CommitPendingWrite() { | 104 void OverlayPersistentPrefStore::CommitPendingWrite() { |
96 // We do not write intentionally. | 105 // We do not write intentionally. |
97 } | 106 } |
98 | 107 |
99 void OverlayPersistentPrefStore::ReportValueChanged(const std::string& key) { | 108 void OverlayPersistentPrefStore::ReportValueChanged(const std::string& key) { |
100 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); | 109 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); |
101 } | 110 } |
102 | 111 |
103 void OverlayPersistentPrefStore::OnPrefValueChanged(const std::string& key) { | 112 void OverlayPersistentPrefStore::OnPrefValueChanged(const std::string& key) { |
104 if (!overlay_.GetValue(key, NULL)) | 113 if (!overlay_.GetValue(key, NULL)) |
105 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); | 114 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); |
106 } | 115 } |
107 | 116 |
108 void OverlayPersistentPrefStore::OnInitializationCompleted() { | 117 void OverlayPersistentPrefStore::OnInitializationCompleted(bool succeeded) { |
109 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, | 118 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, |
110 OnInitializationCompleted()); | 119 OnInitializationCompleted(succeeded)); |
111 } | 120 } |
OLD | NEW |