OLD | NEW |
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 | 9 |
9 #include "base/logging.h" | 10 #include "base/logging.h" |
10 #include "base/macros.h" | 11 #include "base/macros.h" |
11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "components/user_prefs/tracked/hash_store_contents.h" | 14 #include "components/user_prefs/tracked/hash_store_contents.h" |
14 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" | 15 #include "components/user_prefs/tracked/pref_hash_store_transaction.h" |
15 | 16 |
16 class PrefHashStoreImpl::PrefHashStoreTransactionImpl | 17 class PrefHashStoreImpl::PrefHashStoreTransactionImpl |
17 : public PrefHashStoreTransaction { | 18 : public PrefHashStoreTransaction { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 const std::string& device_id, | 68 const std::string& device_id, |
68 bool use_super_mac) | 69 bool use_super_mac) |
69 : pref_hash_calculator_(seed, device_id), use_super_mac_(use_super_mac) { | 70 : pref_hash_calculator_(seed, device_id), use_super_mac_(use_super_mac) { |
70 } | 71 } |
71 | 72 |
72 PrefHashStoreImpl::~PrefHashStoreImpl() { | 73 PrefHashStoreImpl::~PrefHashStoreImpl() { |
73 } | 74 } |
74 | 75 |
75 void PrefHashStoreImpl::set_legacy_hash_store_contents( | 76 void PrefHashStoreImpl::set_legacy_hash_store_contents( |
76 scoped_ptr<HashStoreContents> legacy_hash_store_contents) { | 77 scoped_ptr<HashStoreContents> legacy_hash_store_contents) { |
77 legacy_hash_store_contents_ = legacy_hash_store_contents.Pass(); | 78 legacy_hash_store_contents_ = std::move(legacy_hash_store_contents); |
78 } | 79 } |
79 | 80 |
80 scoped_ptr<PrefHashStoreTransaction> PrefHashStoreImpl::BeginTransaction( | 81 scoped_ptr<PrefHashStoreTransaction> PrefHashStoreImpl::BeginTransaction( |
81 scoped_ptr<HashStoreContents> storage) { | 82 scoped_ptr<HashStoreContents> storage) { |
82 return scoped_ptr<PrefHashStoreTransaction>( | 83 return scoped_ptr<PrefHashStoreTransaction>( |
83 new PrefHashStoreTransactionImpl(this, storage.Pass())); | 84 new PrefHashStoreTransactionImpl(this, std::move(storage))); |
84 } | 85 } |
85 | 86 |
86 PrefHashStoreImpl::PrefHashStoreTransactionImpl::PrefHashStoreTransactionImpl( | 87 PrefHashStoreImpl::PrefHashStoreTransactionImpl::PrefHashStoreTransactionImpl( |
87 PrefHashStoreImpl* outer, | 88 PrefHashStoreImpl* outer, |
88 scoped_ptr<HashStoreContents> storage) | 89 scoped_ptr<HashStoreContents> storage) |
89 : outer_(outer), | 90 : outer_(outer), |
90 contents_(storage.Pass()), | 91 contents_(std::move(storage)), |
91 super_mac_valid_(false), | 92 super_mac_valid_(false), |
92 super_mac_dirty_(false) { | 93 super_mac_dirty_(false) { |
93 if (!outer_->use_super_mac_) | 94 if (!outer_->use_super_mac_) |
94 return; | 95 return; |
95 | 96 |
96 // The store must be initialized and have a valid super MAC to be trusted. | 97 // The store must be initialized and have a valid super MAC to be trusted. |
97 | 98 |
98 const base::DictionaryValue* store_contents = contents()->GetContents(); | 99 const base::DictionaryValue* store_contents = contents()->GetContents(); |
99 if (!store_contents) | 100 if (!store_contents) |
100 return; | 101 return; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::IsSuperMACValid() const { | 303 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::IsSuperMACValid() const { |
303 return super_mac_valid_; | 304 return super_mac_valid_; |
304 } | 305 } |
305 | 306 |
306 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::StampSuperMac() { | 307 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::StampSuperMac() { |
307 if (!outer_->use_super_mac_ || super_mac_valid_) | 308 if (!outer_->use_super_mac_ || super_mac_valid_) |
308 return false; | 309 return false; |
309 super_mac_dirty_ = true; | 310 super_mac_dirty_ = true; |
310 return true; | 311 return true; |
311 } | 312 } |
OLD | NEW |