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

Side by Side Diff: components/user_prefs/tracked/pref_hash_store_impl.cc

Issue 2204943002: Integrate registry_hash_store_contents with the rest of tracked prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased and added important_file_writer CL as dependent patchset Created 4 years, 3 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
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 "components/user_prefs/tracked/pref_hash_store_impl.h" 5 #include "components/user_prefs/tracked/pref_hash_store_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h"
gab 2016/09/16 19:47:33 Not needed?
proberge 2016/09/20 21:35:45 Reverted changes to this file; probably a bad merg
12 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
13 #include "components/user_prefs/tracked/hash_store_contents.h" 14 #include "components/user_prefs/tracked/hash_store_contents.h"
14 15
15 class PrefHashStoreImpl::PrefHashStoreTransactionImpl 16 class PrefHashStoreImpl::PrefHashStoreTransactionImpl
16 : public PrefHashStoreTransaction { 17 : public PrefHashStoreTransaction {
17 public: 18 public:
18 // Constructs a PrefHashStoreTransactionImpl which can use the private 19 // Constructs a PrefHashStoreTransactionImpl which can use the private
19 // members of its |outer| PrefHashStoreImpl. 20 // members of its |outer| PrefHashStoreImpl.
20 PrefHashStoreTransactionImpl(PrefHashStoreImpl* outer, 21 PrefHashStoreTransactionImpl(PrefHashStoreImpl* outer,
21 HashStoreContents* storage); 22 HashStoreContents* storage);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 bool use_super_mac) 54 bool use_super_mac)
54 : pref_hash_calculator_(seed, device_id), use_super_mac_(use_super_mac) { 55 : pref_hash_calculator_(seed, device_id), use_super_mac_(use_super_mac) {
55 } 56 }
56 57
57 PrefHashStoreImpl::~PrefHashStoreImpl() { 58 PrefHashStoreImpl::~PrefHashStoreImpl() {
58 } 59 }
59 60
60 std::unique_ptr<PrefHashStoreTransaction> PrefHashStoreImpl::BeginTransaction( 61 std::unique_ptr<PrefHashStoreTransaction> PrefHashStoreImpl::BeginTransaction(
61 HashStoreContents* storage) { 62 HashStoreContents* storage) {
62 return std::unique_ptr<PrefHashStoreTransaction>( 63 return std::unique_ptr<PrefHashStoreTransaction>(
63 new PrefHashStoreTransactionImpl(this, std::move(storage))); 64 new PrefHashStoreTransactionImpl(this, storage));
64 } 65 }
65 66
66 std::string PrefHashStoreImpl::ComputeMac(const std::string& path, 67 std::string PrefHashStoreImpl::ComputeMac(const std::string& path,
67 const base::Value* value) { 68 const base::Value* value) {
68 return pref_hash_calculator_.Calculate(path, value); 69 return pref_hash_calculator_.Calculate(path, value);
69 } 70 }
70 71
71 std::unique_ptr<base::DictionaryValue> PrefHashStoreImpl::ComputeSplitMacs( 72 std::unique_ptr<base::DictionaryValue> PrefHashStoreImpl::ComputeSplitMacs(
72 const std::string& path, 73 const std::string& path,
73 const base::DictionaryValue* split_values) { 74 const base::DictionaryValue* split_values) {
(...skipping 15 matching lines...) Expand all
89 it.key(), ComputeMac(keyed_path, &it.value())); 90 it.key(), ComputeMac(keyed_path, &it.value()));
90 } 91 }
91 92
92 return split_macs; 93 return split_macs;
93 } 94 }
94 95
95 PrefHashStoreImpl::PrefHashStoreTransactionImpl::PrefHashStoreTransactionImpl( 96 PrefHashStoreImpl::PrefHashStoreTransactionImpl::PrefHashStoreTransactionImpl(
96 PrefHashStoreImpl* outer, 97 PrefHashStoreImpl* outer,
97 HashStoreContents* storage) 98 HashStoreContents* storage)
98 : outer_(outer), 99 : outer_(outer),
99 contents_(std::move(storage)), 100 contents_(storage),
100 super_mac_valid_(false), 101 super_mac_valid_(false),
101 super_mac_dirty_(false) { 102 super_mac_dirty_(false) {
102 if (!outer_->use_super_mac_) 103 if (!outer_->use_super_mac_)
103 return; 104 return;
104 105
105 // The store must have a valid super MAC to be trusted. 106 // The store must have a valid super MAC to be trusted.
106 std::string super_mac = contents_->GetSuperMac(); 107 std::string super_mac = contents_->GetSuperMac();
107 if (super_mac.empty()) 108 if (super_mac.empty())
108 return; 109 return;
109 110
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::IsSuperMACValid() const { 283 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::IsSuperMACValid() const {
283 return super_mac_valid_; 284 return super_mac_valid_;
284 } 285 }
285 286
286 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::StampSuperMac() { 287 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::StampSuperMac() {
287 if (!outer_->use_super_mac_ || super_mac_valid_) 288 if (!outer_->use_super_mac_ || super_mac_valid_)
288 return false; 289 return false;
289 super_mac_dirty_ = true; 290 super_mac_dirty_ = true;
290 return true; 291 return true;
291 } 292 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698