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

Side by Side Diff: chrome/browser/prefs/pref_value_store.cc

Issue 6357019: PrefValueStore incorrectly DCHECK()s when handling change notification for unregistered pref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 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/pref_value_store.h" 5 #include "chrome/browser/prefs/pref_value_store.h"
6 6
7 #include "chrome/browser/prefs/pref_notifier.h" 7 #include "chrome/browser/prefs/pref_notifier.h"
8 8
9 PrefValueStore::PrefStoreKeeper::PrefStoreKeeper() 9 PrefValueStore::PrefStoreKeeper::PrefStoreKeeper()
10 : pref_value_store_(NULL), 10 : pref_value_store_(NULL),
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 } 110 }
111 } 111 }
112 return false; 112 return false;
113 } 113 }
114 114
115 void PrefValueStore::NotifyPrefChanged( 115 void PrefValueStore::NotifyPrefChanged(
116 const char* path, 116 const char* path,
117 PrefValueStore::PrefStoreType new_store) { 117 PrefValueStore::PrefStoreType new_store) {
118 DCHECK(new_store != INVALID_STORE); 118 DCHECK(new_store != INVALID_STORE);
119 119
120 bool changed = true; 120 // If the pref is controlled by a higher-priority store, its effective value
121 // Replying that the pref has changed in case the new store is invalid may 121 // cannot have changed.
122 // cause problems, but it's the safer choice. 122 PrefStoreType controller = ControllingPrefStoreForPref(path);
123 if (new_store != INVALID_STORE) { 123 if (controller == INVALID_STORE || controller >= new_store)
124 PrefStoreType controller = ControllingPrefStoreForPref(path);
125 DCHECK(controller != INVALID_STORE);
126 // If the pref is controlled by a higher-priority store, its effective value
127 // cannot have changed.
128 if (controller != INVALID_STORE &&
129 controller < new_store) {
130 changed = false;
131 }
132 }
133
134 if (changed)
135 pref_notifier_->OnPreferenceChanged(path); 124 pref_notifier_->OnPreferenceChanged(path);
136 } 125 }
137 126
138 bool PrefValueStore::PrefValueInManagedPlatformStore(const char* name) const { 127 bool PrefValueStore::PrefValueInManagedPlatformStore(const char* name) const {
139 return PrefValueInStore(name, MANAGED_PLATFORM_STORE); 128 return PrefValueInStore(name, MANAGED_PLATFORM_STORE);
140 } 129 }
141 130
142 bool PrefValueStore::PrefValueInDeviceManagementStore(const char* name) const { 131 bool PrefValueStore::PrefValueInDeviceManagementStore(const char* name) const {
143 return PrefValueInStore(name, DEVICE_MANAGEMENT_STORE); 132 return PrefValueInStore(name, DEVICE_MANAGEMENT_STORE);
144 } 133 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 237
249 void PrefValueStore::CheckInitializationCompleted() { 238 void PrefValueStore::CheckInitializationCompleted() {
250 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { 239 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) {
251 scoped_refptr<PrefStore> store = 240 scoped_refptr<PrefStore> store =
252 GetPrefStore(static_cast<PrefStoreType>(i)); 241 GetPrefStore(static_cast<PrefStoreType>(i));
253 if (store && !store->IsInitializationComplete()) 242 if (store && !store->IsInitializationComplete())
254 return; 243 return;
255 } 244 }
256 pref_notifier_->OnInitializationCompleted(); 245 pref_notifier_->OnInitializationCompleted();
257 } 246 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698