Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: base/prefs/overlay_user_pref_store.cc

Issue 1141793003: Update from https://crrev.com/329939 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/prefs/overlay_user_pref_store.h ('k') | base/prefs/overlay_user_pref_store_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/overlay_user_pref_store.h" 5 #include "base/prefs/overlay_user_pref_store.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 9
10 OverlayUserPrefStore::OverlayUserPrefStore( 10 OverlayUserPrefStore::OverlayUserPrefStore(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 base::Value* underlay_value = NULL; 56 base::Value* underlay_value = NULL;
57 if (!underlay_->GetMutableValue(GetUnderlayKey(key), &underlay_value)) 57 if (!underlay_->GetMutableValue(GetUnderlayKey(key), &underlay_value))
58 return false; 58 return false;
59 59
60 *result = underlay_value->DeepCopy(); 60 *result = underlay_value->DeepCopy();
61 overlay_.SetValue(key, *result); 61 overlay_.SetValue(key, *result);
62 return true; 62 return true;
63 } 63 }
64 64
65 void OverlayUserPrefStore::SetValue(const std::string& key, 65 void OverlayUserPrefStore::SetValue(const std::string& key,
66 base::Value* value) { 66 base::Value* value,
67 uint32 flags) {
67 if (!ShallBeStoredInOverlay(key)) { 68 if (!ShallBeStoredInOverlay(key)) {
68 underlay_->SetValue(GetUnderlayKey(key), value); 69 underlay_->SetValue(GetUnderlayKey(key), value, flags);
69 return; 70 return;
70 } 71 }
71 72
72 if (overlay_.SetValue(key, value)) 73 if (overlay_.SetValue(key, value))
73 ReportValueChanged(key); 74 ReportValueChanged(key, flags);
74 } 75 }
75 76
76 void OverlayUserPrefStore::SetValueSilently(const std::string& key, 77 void OverlayUserPrefStore::SetValueSilently(const std::string& key,
77 base::Value* value) { 78 base::Value* value,
79 uint32 flags) {
78 if (!ShallBeStoredInOverlay(key)) { 80 if (!ShallBeStoredInOverlay(key)) {
79 underlay_->SetValueSilently(GetUnderlayKey(key), value); 81 underlay_->SetValueSilently(GetUnderlayKey(key), value, flags);
80 return; 82 return;
81 } 83 }
82 84
83 overlay_.SetValue(key, value); 85 overlay_.SetValue(key, value);
84 } 86 }
85 87
86 void OverlayUserPrefStore::RemoveValue(const std::string& key) { 88 void OverlayUserPrefStore::RemoveValue(const std::string& key, uint32 flags) {
87 if (!ShallBeStoredInOverlay(key)) { 89 if (!ShallBeStoredInOverlay(key)) {
88 underlay_->RemoveValue(GetUnderlayKey(key)); 90 underlay_->RemoveValue(GetUnderlayKey(key), flags);
89 return; 91 return;
90 } 92 }
91 93
92 if (overlay_.RemoveValue(key)) 94 if (overlay_.RemoveValue(key))
93 ReportValueChanged(key); 95 ReportValueChanged(key, flags);
94 } 96 }
95 97
96 bool OverlayUserPrefStore::ReadOnly() const { 98 bool OverlayUserPrefStore::ReadOnly() const {
97 return false; 99 return false;
98 } 100 }
99 101
100 PersistentPrefStore::PrefReadError OverlayUserPrefStore::GetReadError() const { 102 PersistentPrefStore::PrefReadError OverlayUserPrefStore::GetReadError() const {
101 return PersistentPrefStore::PREF_READ_ERROR_NONE; 103 return PersistentPrefStore::PREF_READ_ERROR_NONE;
102 } 104 }
103 105
104 PersistentPrefStore::PrefReadError OverlayUserPrefStore::ReadPrefs() { 106 PersistentPrefStore::PrefReadError OverlayUserPrefStore::ReadPrefs() {
105 // We do not read intentionally. 107 // We do not read intentionally.
106 OnInitializationCompleted(true); 108 OnInitializationCompleted(true);
107 return PersistentPrefStore::PREF_READ_ERROR_NONE; 109 return PersistentPrefStore::PREF_READ_ERROR_NONE;
108 } 110 }
109 111
110 void OverlayUserPrefStore::ReadPrefsAsync( 112 void OverlayUserPrefStore::ReadPrefsAsync(
111 ReadErrorDelegate* error_delegate_raw) { 113 ReadErrorDelegate* error_delegate_raw) {
112 scoped_ptr<ReadErrorDelegate> error_delegate(error_delegate_raw); 114 scoped_ptr<ReadErrorDelegate> error_delegate(error_delegate_raw);
113 // We do not read intentionally. 115 // We do not read intentionally.
114 OnInitializationCompleted(true); 116 OnInitializationCompleted(true);
115 } 117 }
116 118
117 void OverlayUserPrefStore::CommitPendingWrite() { 119 void OverlayUserPrefStore::CommitPendingWrite() {
118 underlay_->CommitPendingWrite(); 120 underlay_->CommitPendingWrite();
119 // We do not write our content intentionally. 121 // We do not write our content intentionally.
120 } 122 }
121 123
122 void OverlayUserPrefStore::ReportValueChanged(const std::string& key) { 124 void OverlayUserPrefStore::ReportValueChanged(const std::string& key,
125 uint32 flags) {
123 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); 126 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key));
124 } 127 }
125 128
126 void OverlayUserPrefStore::OnPrefValueChanged(const std::string& key) { 129 void OverlayUserPrefStore::OnPrefValueChanged(const std::string& key) {
127 if (!overlay_.GetValue(GetOverlayKey(key), NULL)) 130 if (!overlay_.GetValue(GetOverlayKey(key), NULL))
128 ReportValueChanged(GetOverlayKey(key)); 131 ReportValueChanged(GetOverlayKey(key), DEFAULT_PREF_WRITE_FLAGS);
129 } 132 }
130 133
131 void OverlayUserPrefStore::OnInitializationCompleted(bool succeeded) { 134 void OverlayUserPrefStore::OnInitializationCompleted(bool succeeded) {
132 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, 135 FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
133 OnInitializationCompleted(succeeded)); 136 OnInitializationCompleted(succeeded));
134 } 137 }
135 138
136 void OverlayUserPrefStore::RegisterOverlayPref(const std::string& key) { 139 void OverlayUserPrefStore::RegisterOverlayPref(const std::string& key) {
137 RegisterOverlayPref(key, key); 140 RegisterOverlayPref(key, key);
138 } 141 }
(...skipping 29 matching lines...) Expand all
168 NamesMap::const_iterator i = 171 NamesMap::const_iterator i =
169 overlay_to_underlay_names_map_.find(overlay_key); 172 overlay_to_underlay_names_map_.find(overlay_key);
170 return i != overlay_to_underlay_names_map_.end() ? i->second : overlay_key; 173 return i != overlay_to_underlay_names_map_.end() ? i->second : overlay_key;
171 } 174 }
172 175
173 bool OverlayUserPrefStore::ShallBeStoredInOverlay( 176 bool OverlayUserPrefStore::ShallBeStoredInOverlay(
174 const std::string& key) const { 177 const std::string& key) const {
175 return overlay_to_underlay_names_map_.find(key) != 178 return overlay_to_underlay_names_map_.find(key) !=
176 overlay_to_underlay_names_map_.end(); 179 overlay_to_underlay_names_map_.end();
177 } 180 }
OLDNEW
« no previous file with comments | « base/prefs/overlay_user_pref_store.h ('k') | base/prefs/overlay_user_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698