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

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

Issue 1544033003: Switch to standard integer types in base/prefs/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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/pref_change_registrar.h » ('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 <utility> 7 #include <utility>
8 8
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 if (!underlay_->GetMutableValue(GetUnderlayKey(key), &underlay_value)) 59 if (!underlay_->GetMutableValue(GetUnderlayKey(key), &underlay_value))
60 return false; 60 return false;
61 61
62 *result = underlay_value->DeepCopy(); 62 *result = underlay_value->DeepCopy();
63 overlay_.SetValue(key, make_scoped_ptr(*result)); 63 overlay_.SetValue(key, make_scoped_ptr(*result));
64 return true; 64 return true;
65 } 65 }
66 66
67 void OverlayUserPrefStore::SetValue(const std::string& key, 67 void OverlayUserPrefStore::SetValue(const std::string& key,
68 scoped_ptr<base::Value> value, 68 scoped_ptr<base::Value> value,
69 uint32 flags) { 69 uint32_t flags) {
70 if (!ShallBeStoredInOverlay(key)) { 70 if (!ShallBeStoredInOverlay(key)) {
71 underlay_->SetValue(GetUnderlayKey(key), std::move(value), flags); 71 underlay_->SetValue(GetUnderlayKey(key), std::move(value), flags);
72 return; 72 return;
73 } 73 }
74 74
75 if (overlay_.SetValue(key, std::move(value))) 75 if (overlay_.SetValue(key, std::move(value)))
76 ReportValueChanged(key, flags); 76 ReportValueChanged(key, flags);
77 } 77 }
78 78
79 void OverlayUserPrefStore::SetValueSilently(const std::string& key, 79 void OverlayUserPrefStore::SetValueSilently(const std::string& key,
80 scoped_ptr<base::Value> value, 80 scoped_ptr<base::Value> value,
81 uint32 flags) { 81 uint32_t flags) {
82 if (!ShallBeStoredInOverlay(key)) { 82 if (!ShallBeStoredInOverlay(key)) {
83 underlay_->SetValueSilently(GetUnderlayKey(key), std::move(value), flags); 83 underlay_->SetValueSilently(GetUnderlayKey(key), std::move(value), flags);
84 return; 84 return;
85 } 85 }
86 86
87 overlay_.SetValue(key, std::move(value)); 87 overlay_.SetValue(key, std::move(value));
88 } 88 }
89 89
90 void OverlayUserPrefStore::RemoveValue(const std::string& key, uint32 flags) { 90 void OverlayUserPrefStore::RemoveValue(const std::string& key, uint32_t flags) {
91 if (!ShallBeStoredInOverlay(key)) { 91 if (!ShallBeStoredInOverlay(key)) {
92 underlay_->RemoveValue(GetUnderlayKey(key), flags); 92 underlay_->RemoveValue(GetUnderlayKey(key), flags);
93 return; 93 return;
94 } 94 }
95 95
96 if (overlay_.RemoveValue(key)) 96 if (overlay_.RemoveValue(key))
97 ReportValueChanged(key, flags); 97 ReportValueChanged(key, flags);
98 } 98 }
99 99
100 bool OverlayUserPrefStore::ReadOnly() const { 100 bool OverlayUserPrefStore::ReadOnly() const {
(...skipping 20 matching lines...) Expand all
121 void OverlayUserPrefStore::CommitPendingWrite() { 121 void OverlayUserPrefStore::CommitPendingWrite() {
122 underlay_->CommitPendingWrite(); 122 underlay_->CommitPendingWrite();
123 // We do not write our content intentionally. 123 // We do not write our content intentionally.
124 } 124 }
125 125
126 void OverlayUserPrefStore::SchedulePendingLossyWrites() { 126 void OverlayUserPrefStore::SchedulePendingLossyWrites() {
127 underlay_->SchedulePendingLossyWrites(); 127 underlay_->SchedulePendingLossyWrites();
128 } 128 }
129 129
130 void OverlayUserPrefStore::ReportValueChanged(const std::string& key, 130 void OverlayUserPrefStore::ReportValueChanged(const std::string& key,
131 uint32 flags) { 131 uint32_t flags) {
132 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key)); 132 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, OnPrefValueChanged(key));
133 } 133 }
134 134
135 void OverlayUserPrefStore::OnPrefValueChanged(const std::string& key) { 135 void OverlayUserPrefStore::OnPrefValueChanged(const std::string& key) {
136 if (!overlay_.GetValue(GetOverlayKey(key), NULL)) 136 if (!overlay_.GetValue(GetOverlayKey(key), NULL))
137 ReportValueChanged(GetOverlayKey(key), DEFAULT_PREF_WRITE_FLAGS); 137 ReportValueChanged(GetOverlayKey(key), DEFAULT_PREF_WRITE_FLAGS);
138 } 138 }
139 139
140 void OverlayUserPrefStore::OnInitializationCompleted(bool succeeded) { 140 void OverlayUserPrefStore::OnInitializationCompleted(bool succeeded) {
141 FOR_EACH_OBSERVER(PrefStore::Observer, observers_, 141 FOR_EACH_OBSERVER(PrefStore::Observer, observers_,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 NamesMap::const_iterator i = 177 NamesMap::const_iterator i =
178 overlay_to_underlay_names_map_.find(overlay_key); 178 overlay_to_underlay_names_map_.find(overlay_key);
179 return i != overlay_to_underlay_names_map_.end() ? i->second : overlay_key; 179 return i != overlay_to_underlay_names_map_.end() ? i->second : overlay_key;
180 } 180 }
181 181
182 bool OverlayUserPrefStore::ShallBeStoredInOverlay( 182 bool OverlayUserPrefStore::ShallBeStoredInOverlay(
183 const std::string& key) const { 183 const std::string& key) const {
184 return overlay_to_underlay_names_map_.find(key) != 184 return overlay_to_underlay_names_map_.find(key) !=
185 overlay_to_underlay_names_map_.end(); 185 overlay_to_underlay_names_map_.end();
186 } 186 }
OLDNEW
« no previous file with comments | « base/prefs/overlay_user_pref_store.h ('k') | base/prefs/pref_change_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698