 Chromium Code Reviews
 Chromium Code Reviews Issue 2634403002:
  Use GetDeterministicMachineSpecificId instead of RLZ for device_id  (Closed)
    
  
    Issue 2634403002:
  Use GetDeterministicMachineSpecificId instead of RLZ for device_id  (Closed) 
  | 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 #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/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" | 
| 13 #include "components/user_prefs/tracked/device_id.h" | |
| 13 #include "components/user_prefs/tracked/hash_store_contents.h" | 14 #include "components/user_prefs/tracked/hash_store_contents.h" | 
| 14 | 15 | 
| 16 namespace { | |
| 
gab
2017/01/17 21:03:48
nit: empty lines after opening and before closing
 
proberge
2017/01/18 16:10:58
Done.
 | |
| 17 // Returns a deterministic ID for this machine. | |
| 18 std::string GenerateDeviceId() { | |
| 19 std::string device_id; | |
| 20 if (GetDeterministicMachineSpecificId(&device_id) == MachineIdStatus::SUCCESS) | |
| 21 return device_id; | |
| 22 | |
| 23 return std::string(); | |
| 24 } | |
| 25 } | |
| 
gab
2017/01/17 21:03:48
nit: }  // namespace
 
proberge
2017/01/18 16:10:58
Done.
 | |
| 26 | |
| 15 class PrefHashStoreImpl::PrefHashStoreTransactionImpl | 27 class PrefHashStoreImpl::PrefHashStoreTransactionImpl | 
| 16 : public PrefHashStoreTransaction { | 28 : public PrefHashStoreTransaction { | 
| 17 public: | 29 public: | 
| 18 // Constructs a PrefHashStoreTransactionImpl which can use the private | 30 // Constructs a PrefHashStoreTransactionImpl which can use the private | 
| 19 // members of its |outer| PrefHashStoreImpl. | 31 // members of its |outer| PrefHashStoreImpl. | 
| 20 PrefHashStoreTransactionImpl(PrefHashStoreImpl* outer, | 32 PrefHashStoreTransactionImpl(PrefHashStoreImpl* outer, | 
| 21 HashStoreContents* storage); | 33 HashStoreContents* storage); | 
| 22 ~PrefHashStoreTransactionImpl() override; | 34 ~PrefHashStoreTransactionImpl() override; | 
| 23 | 35 | 
| 24 // PrefHashStoreTransaction implementation. | 36 // PrefHashStoreTransaction implementation. | 
| (...skipping 17 matching lines...) Expand all Loading... | |
| 42 PrefHashStoreImpl* outer_; | 54 PrefHashStoreImpl* outer_; | 
| 43 HashStoreContents* contents_; | 55 HashStoreContents* contents_; | 
| 44 | 56 | 
| 45 bool super_mac_valid_; | 57 bool super_mac_valid_; | 
| 46 bool super_mac_dirty_; | 58 bool super_mac_dirty_; | 
| 47 | 59 | 
| 48 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreTransactionImpl); | 60 DISALLOW_COPY_AND_ASSIGN(PrefHashStoreTransactionImpl); | 
| 49 }; | 61 }; | 
| 50 | 62 | 
| 51 PrefHashStoreImpl::PrefHashStoreImpl(const std::string& seed, | 63 PrefHashStoreImpl::PrefHashStoreImpl(const std::string& seed, | 
| 52 const std::string& device_id, | 64 const std::string& legacy_device_id, | 
| 53 bool use_super_mac) | 65 bool use_super_mac) | 
| 54 : pref_hash_calculator_(seed, device_id), use_super_mac_(use_super_mac) { | 66 : pref_hash_calculator_(seed, GenerateDeviceId(), legacy_device_id), | 
| 55 } | 67 use_super_mac_(use_super_mac) {} | 
| 56 | 68 | 
| 57 PrefHashStoreImpl::~PrefHashStoreImpl() { | 69 PrefHashStoreImpl::~PrefHashStoreImpl() { | 
| 58 } | 70 } | 
| 59 | 71 | 
| 60 std::unique_ptr<PrefHashStoreTransaction> PrefHashStoreImpl::BeginTransaction( | 72 std::unique_ptr<PrefHashStoreTransaction> PrefHashStoreImpl::BeginTransaction( | 
| 61 HashStoreContents* storage) { | 73 HashStoreContents* storage) { | 
| 62 return std::unique_ptr<PrefHashStoreTransaction>( | 74 return std::unique_ptr<PrefHashStoreTransaction>( | 
| 63 new PrefHashStoreTransactionImpl(this, std::move(storage))); | 75 new PrefHashStoreTransactionImpl(this, std::move(storage))); | 
| 64 } | 76 } | 
| 65 | 77 | 
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::IsSuperMACValid() const { | 294 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::IsSuperMACValid() const { | 
| 283 return super_mac_valid_; | 295 return super_mac_valid_; | 
| 284 } | 296 } | 
| 285 | 297 | 
| 286 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::StampSuperMac() { | 298 bool PrefHashStoreImpl::PrefHashStoreTransactionImpl::StampSuperMac() { | 
| 287 if (!outer_->use_super_mac_ || super_mac_valid_) | 299 if (!outer_->use_super_mac_ || super_mac_valid_) | 
| 288 return false; | 300 return false; | 
| 289 super_mac_dirty_ = true; | 301 super_mac_dirty_ = true; | 
| 290 return true; | 302 return true; | 
| 291 } | 303 } | 
| OLD | NEW |