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

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

Issue 9251026: Reinitialize LocalState's CommandLinePrefStore after about_flags updates the command line. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 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
OLDNEW
1 // Copyright (c) 2011 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 "chrome/browser/prefs/pref_value_store.h" 5 #include "chrome/browser/prefs/pref_value_store.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/prefs/pref_model_associator.h" 8 #include "chrome/browser/prefs/pref_model_associator.h"
9 #include "chrome/browser/prefs/pref_notifier.h" 9 #include "chrome/browser/prefs/pref_notifier.h"
10 10
11 PrefValueStore::PrefStoreKeeper::PrefStoreKeeper() 11 PrefValueStore::PrefStoreKeeper::PrefStoreKeeper()
12 : pref_value_store_(NULL), 12 : pref_value_store_(NULL),
13 type_(PrefValueStore::INVALID_STORE) { 13 type_(PrefValueStore::INVALID_STORE) {
14 } 14 }
15 15
16 PrefValueStore::PrefStoreKeeper::~PrefStoreKeeper() { 16 PrefValueStore::PrefStoreKeeper::~PrefStoreKeeper() {
17 if (pref_store_.get()) { 17 if (pref_store_.get()) {
18 pref_store_->RemoveObserver(this); 18 pref_store_->RemoveObserver(this);
19 pref_store_ = NULL; 19 pref_store_ = NULL;
20 } 20 }
21 pref_value_store_ = NULL; 21 pref_value_store_ = NULL;
22 } 22 }
23 23
24 void PrefValueStore::PrefStoreKeeper::Initialize( 24 void PrefValueStore::PrefStoreKeeper::Initialize(
25 PrefValueStore* store, 25 PrefValueStore* store,
26 PrefStore* pref_store, 26 PrefStore* pref_store,
27 PrefValueStore::PrefStoreType type) { 27 PrefValueStore::PrefStoreType type) {
28 if (pref_store_.get()) 28 if (pref_store_.get())
29 pref_store_->RemoveObserver(this); 29 pref_store_->RemoveObserver(this);
battre 2012/01/19 09:52:21 could you please add a DCHECK that verifies that n
Lei Zhang 2012/01/19 20:33:59 Done.
30 type_ = type; 30 type_ = type;
31 pref_value_store_ = store; 31 pref_value_store_ = store;
32 pref_store_ = pref_store; 32 pref_store_ = pref_store;
33 if (pref_store_.get()) 33 if (pref_store_.get())
34 pref_store_->AddObserver(this); 34 pref_store_->AddObserver(this);
35 } 35 }
36 36
37 void PrefValueStore::PrefStoreKeeper::OnPrefValueChanged( 37 void PrefValueStore::PrefStoreKeeper::OnPrefValueChanged(
38 const std::string& key) { 38 const std::string& key) {
39 pref_value_store_->OnPrefValueChanged(type_, key); 39 pref_value_store_->OnPrefValueChanged(type_, key);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return effective_store >= USER_STORE || 178 return effective_store >= USER_STORE ||
179 effective_store == INVALID_STORE; 179 effective_store == INVALID_STORE;
180 } 180 }
181 181
182 bool PrefValueStore::PrefValueExtensionModifiable(const char* name) const { 182 bool PrefValueStore::PrefValueExtensionModifiable(const char* name) const {
183 PrefStoreType effective_store = ControllingPrefStoreForPref(name); 183 PrefStoreType effective_store = ControllingPrefStoreForPref(name);
184 return effective_store >= EXTENSION_STORE || 184 return effective_store >= EXTENSION_STORE ||
185 effective_store == INVALID_STORE; 185 effective_store == INVALID_STORE;
186 } 186 }
187 187
188 void PrefValueStore::UpdateCommandLinePrefStore(PrefStore* command_line_prefs) {
189 InitPrefStore(COMMAND_LINE_STORE, command_line_prefs);
190 }
191
188 bool PrefValueStore::PrefValueInStore( 192 bool PrefValueStore::PrefValueInStore(
189 const char* name, 193 const char* name,
190 PrefValueStore::PrefStoreType store) const { 194 PrefValueStore::PrefStoreType store) const {
191 // Declare a temp Value* and call GetValueFromStore, 195 // Declare a temp Value* and call GetValueFromStore,
192 // ignoring the output value. 196 // ignoring the output value.
193 const Value* tmp_value = NULL; 197 const Value* tmp_value = NULL;
194 return GetValueFromStore(name, store, &tmp_value); 198 return GetValueFromStore(name, store, &tmp_value);
195 } 199 }
196 200
197 bool PrefValueStore::PrefValueInStoreRange( 201 bool PrefValueStore::PrefValueInStoreRange(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 if (initialization_failed_) 277 if (initialization_failed_)
274 return; 278 return;
275 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { 279 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) {
276 scoped_refptr<PrefStore> store = 280 scoped_refptr<PrefStore> store =
277 GetPrefStore(static_cast<PrefStoreType>(i)); 281 GetPrefStore(static_cast<PrefStoreType>(i));
278 if (store && !store->IsInitializationComplete()) 282 if (store && !store->IsInitializationComplete())
279 return; 283 return;
280 } 284 }
281 pref_notifier_->OnInitializationCompleted(true); 285 pref_notifier_->OnInitializationCompleted(true);
282 } 286 }
OLDNEW
« chrome/browser/prefs/pref_service.cc ('K') | « chrome/browser/prefs/pref_value_store.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698