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

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: fix presubmit checks, no code change 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
« no previous file with comments | « chrome/browser/prefs/pref_value_store.h ('k') | chrome/browser/prefs/testing_pref_store.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) 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);
30 DCHECK_EQ(0U, pref_store_->NumberOfObservers());
31 }
30 type_ = type; 32 type_ = type;
31 pref_value_store_ = store; 33 pref_value_store_ = store;
32 pref_store_ = pref_store; 34 pref_store_ = pref_store;
33 if (pref_store_.get()) 35 if (pref_store_.get())
34 pref_store_->AddObserver(this); 36 pref_store_->AddObserver(this);
35 } 37 }
36 38
37 void PrefValueStore::PrefStoreKeeper::OnPrefValueChanged( 39 void PrefValueStore::PrefStoreKeeper::OnPrefValueChanged(
38 const std::string& key) { 40 const std::string& key) {
39 pref_value_store_->OnPrefValueChanged(type_, key); 41 pref_value_store_->OnPrefValueChanged(type_, key);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 return effective_store >= USER_STORE || 180 return effective_store >= USER_STORE ||
179 effective_store == INVALID_STORE; 181 effective_store == INVALID_STORE;
180 } 182 }
181 183
182 bool PrefValueStore::PrefValueExtensionModifiable(const char* name) const { 184 bool PrefValueStore::PrefValueExtensionModifiable(const char* name) const {
183 PrefStoreType effective_store = ControllingPrefStoreForPref(name); 185 PrefStoreType effective_store = ControllingPrefStoreForPref(name);
184 return effective_store >= EXTENSION_STORE || 186 return effective_store >= EXTENSION_STORE ||
185 effective_store == INVALID_STORE; 187 effective_store == INVALID_STORE;
186 } 188 }
187 189
190 void PrefValueStore::UpdateCommandLinePrefStore(PrefStore* command_line_prefs) {
191 InitPrefStore(COMMAND_LINE_STORE, command_line_prefs);
192 }
193
188 bool PrefValueStore::PrefValueInStore( 194 bool PrefValueStore::PrefValueInStore(
189 const char* name, 195 const char* name,
190 PrefValueStore::PrefStoreType store) const { 196 PrefValueStore::PrefStoreType store) const {
191 // Declare a temp Value* and call GetValueFromStore, 197 // Declare a temp Value* and call GetValueFromStore,
192 // ignoring the output value. 198 // ignoring the output value.
193 const Value* tmp_value = NULL; 199 const Value* tmp_value = NULL;
194 return GetValueFromStore(name, store, &tmp_value); 200 return GetValueFromStore(name, store, &tmp_value);
195 } 201 }
196 202
197 bool PrefValueStore::PrefValueInStoreRange( 203 bool PrefValueStore::PrefValueInStoreRange(
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 if (initialization_failed_) 279 if (initialization_failed_)
274 return; 280 return;
275 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) { 281 for (size_t i = 0; i <= PREF_STORE_TYPE_MAX; ++i) {
276 scoped_refptr<PrefStore> store = 282 scoped_refptr<PrefStore> store =
277 GetPrefStore(static_cast<PrefStoreType>(i)); 283 GetPrefStore(static_cast<PrefStoreType>(i));
278 if (store && !store->IsInitializationComplete()) 284 if (store && !store->IsInitializationComplete())
279 return; 285 return;
280 } 286 }
281 pref_notifier_->OnInitializationCompleted(true); 287 pref_notifier_->OnInitializationCompleted(true);
282 } 288 }
OLDNEW
« no previous file with comments | « chrome/browser/prefs/pref_value_store.h ('k') | chrome/browser/prefs/testing_pref_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698