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

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

Issue 187443007: All Get/Set using the hash_store_id as a key should use *WithoutPathExpansion methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_hash_store_impl.h" 5 #include "chrome/browser/prefs/pref_hash_store_impl.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/prefs/pref_registry_simple.h" 9 #include "base/prefs/pref_registry_simple.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 void PrefHashStoreImpl::Reset() { 83 void PrefHashStoreImpl::Reset() {
84 DictionaryPrefUpdate update(local_state_, prefs::kProfilePreferenceHashes); 84 DictionaryPrefUpdate update(local_state_, prefs::kProfilePreferenceHashes);
85 85
86 // Remove the dictionary corresponding to the profile name, which may have a 86 // Remove the dictionary corresponding to the profile name, which may have a
87 // '.' 87 // '.'
88 update->RemoveWithoutPathExpansion(hash_store_id_, NULL); 88 update->RemoveWithoutPathExpansion(hash_store_id_, NULL);
89 89
90 // Remove this store's entry in the kStoreVersionsDict. 90 // Remove this store's entry in the kStoreVersionsDict.
91 base::DictionaryValue* version_dict; 91 base::DictionaryValue* version_dict;
92 if (update->GetDictionary(internals::kStoreVersionsDict, &version_dict)) 92 if (update->GetDictionary(internals::kStoreVersionsDict, &version_dict))
93 version_dict->Remove(hash_store_id_, NULL); 93 version_dict->RemoveWithoutPathExpansion(hash_store_id_, NULL);
94 94
95 // Remove this store's entry in the kHashOfHashesDict. 95 // Remove this store's entry in the kHashOfHashesDict.
96 base::DictionaryValue* hash_of_hashes_dict; 96 base::DictionaryValue* hash_of_hashes_dict;
97 if (update->GetDictionaryWithoutPathExpansion(internals::kHashOfHashesDict, 97 if (update->GetDictionaryWithoutPathExpansion(internals::kHashOfHashesDict,
98 &hash_of_hashes_dict)) { 98 &hash_of_hashes_dict)) {
99 hash_of_hashes_dict->Remove(hash_store_id_, NULL); 99 hash_of_hashes_dict->RemoveWithoutPathExpansion(hash_store_id_, NULL);
100 } 100 }
101 } 101 }
102 102
103 scoped_ptr<PrefHashStoreTransaction> PrefHashStoreImpl::BeginTransaction() { 103 scoped_ptr<PrefHashStoreTransaction> PrefHashStoreImpl::BeginTransaction() {
104 return scoped_ptr<PrefHashStoreTransaction>( 104 return scoped_ptr<PrefHashStoreTransaction>(
105 new PrefHashStoreTransactionImpl(this)); 105 new PrefHashStoreTransactionImpl(this));
106 } 106 }
107 107
108 PrefHashStoreImpl::StoreVersion PrefHashStoreImpl::GetCurrentVersion() const { 108 PrefHashStoreImpl::StoreVersion PrefHashStoreImpl::GetCurrentVersion() const {
109 const base::DictionaryValue* pref_hash_data = 109 const base::DictionaryValue* pref_hash_data =
110 local_state_->GetDictionary(prefs::kProfilePreferenceHashes); 110 local_state_->GetDictionary(prefs::kProfilePreferenceHashes);
111 111
112 if (!pref_hash_data->GetDictionaryWithoutPathExpansion(hash_store_id_, NULL)) 112 if (!pref_hash_data->GetDictionaryWithoutPathExpansion(hash_store_id_, NULL))
113 return VERSION_UNINITIALIZED; 113 return VERSION_UNINITIALIZED;
114 114
115 const base::DictionaryValue* version_dict; 115 const base::DictionaryValue* version_dict;
116 int current_version; 116 int current_version;
117 if (!pref_hash_data->GetDictionary(internals::kStoreVersionsDict, 117 if (!pref_hash_data->GetDictionary(internals::kStoreVersionsDict,
118 &version_dict) || 118 &version_dict) ||
119 !version_dict->GetInteger(hash_store_id_, &current_version)) { 119 !version_dict->GetIntegerWithoutPathExpansion(hash_store_id_,
120 &current_version)) {
120 return VERSION_PRE_MIGRATION; 121 return VERSION_PRE_MIGRATION;
121 } 122 }
122 123
123 DCHECK_GT(current_version, VERSION_PRE_MIGRATION); 124 DCHECK_GT(current_version, VERSION_PRE_MIGRATION);
124 return static_cast<StoreVersion>(current_version); 125 return static_cast<StoreVersion>(current_version);
125 } 126 }
126 127
127 bool PrefHashStoreImpl::IsHashDictionaryTrusted() const { 128 bool PrefHashStoreImpl::IsHashDictionaryTrusted() const {
128 const base::DictionaryValue* pref_hash_data = 129 const base::DictionaryValue* pref_hash_data =
129 local_state_->GetDictionary(prefs::kProfilePreferenceHashes); 130 local_state_->GetDictionary(prefs::kProfilePreferenceHashes);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 // practice only initialization transactions will actually do this, but 183 // practice only initialization transactions will actually do this, but
183 // since they always occur before minor update transaction it's okay 184 // since they always occur before minor update transaction it's okay
184 // to unconditionally do this here). Do this even if |!has_changed_| to also 185 // to unconditionally do this here). Do this even if |!has_changed_| to also
185 // seed version number on unchanged profiles. 186 // seed version number on unchanged profiles.
186 base::DictionaryValue* store_versions_dict = NULL; 187 base::DictionaryValue* store_versions_dict = NULL;
187 if (!update->GetDictionary(internals::kStoreVersionsDict, 188 if (!update->GetDictionary(internals::kStoreVersionsDict,
188 &store_versions_dict)) { 189 &store_versions_dict)) {
189 store_versions_dict = new base::DictionaryValue; 190 store_versions_dict = new base::DictionaryValue;
190 update->Set(internals::kStoreVersionsDict, store_versions_dict); 191 update->Set(internals::kStoreVersionsDict, store_versions_dict);
191 } 192 }
192 store_versions_dict->SetInteger(outer_->hash_store_id_, VERSION_LATEST); 193 store_versions_dict->SetIntegerWithoutPathExpansion(outer_->hash_store_id_,
194 VERSION_LATEST);
193 } 195 }
194 196
195 PrefHashStoreTransaction::ValueState 197 PrefHashStoreTransaction::ValueState
196 PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckValue( 198 PrefHashStoreImpl::PrefHashStoreTransactionImpl::CheckValue(
197 const std::string& path, const base::Value* initial_value) const { 199 const std::string& path, const base::Value* initial_value) const {
198 const base::DictionaryValue* pref_hash_data = 200 const base::DictionaryValue* pref_hash_data =
199 outer_->local_state_->GetDictionary(prefs::kProfilePreferenceHashes); 201 outer_->local_state_->GetDictionary(prefs::kProfilePreferenceHashes);
200 const base::DictionaryValue* hashed_prefs = NULL; 202 const base::DictionaryValue* hashed_prefs = NULL;
201 pref_hash_data->GetDictionaryWithoutPathExpansion(outer_->hash_store_id_, 203 pref_hash_data->GetDictionaryWithoutPathExpansion(outer_->hash_store_id_,
202 &hashed_prefs); 204 &hashed_prefs);
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 if (!update->Get()->GetDictionaryWithoutPathExpansion(outer_->hash_store_id_, 345 if (!update->Get()->GetDictionaryWithoutPathExpansion(outer_->hash_store_id_,
344 &hashes_dict)) { 346 &hashes_dict)) {
345 hashes_dict = new base::DictionaryValue; 347 hashes_dict = new base::DictionaryValue;
346 update->Get()->SetWithoutPathExpansion(outer_->hash_store_id_, hashes_dict); 348 update->Get()->SetWithoutPathExpansion(outer_->hash_store_id_, hashes_dict);
347 } 349 }
348 hashes_dict->SetString( 350 hashes_dict->SetString(
349 path, outer_->pref_hash_calculator_.Calculate(path, new_value)); 351 path, outer_->pref_hash_calculator_.Calculate(path, new_value));
350 352
351 has_changed_ = true; 353 has_changed_ = true;
352 } 354 }
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