| 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 #ifndef CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR_H_ |
| 6 #define CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/lazy_instance.h" | |
| 13 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 14 | 13 |
| 15 namespace base { | 14 namespace base { |
| 16 class Value; | 15 class Value; |
| 17 } // namespace base | 16 } // namespace base |
| 18 | 17 |
| 19 // Calculates and validates preference value hashes. | 18 // Calculates and validates preference value hashes. |
| 20 class PrefHashCalculator { | 19 class PrefHashCalculator { |
| 21 public: | 20 public: |
| 22 enum ValidationResult { | 21 enum ValidationResult { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 const std::string seed_; | 65 const std::string seed_; |
| 67 const std::string device_id_; | 66 const std::string device_id_; |
| 68 | 67 |
| 69 // The raw device id from which the legacy device id will be derived if | 68 // The raw device id from which the legacy device id will be derived if |
| 70 // required. | 69 // required. |
| 71 const std::string raw_device_id_; | 70 const std::string raw_device_id_; |
| 72 | 71 |
| 73 const GetLegacyDeviceIdCallback get_legacy_device_id_callback_; | 72 const GetLegacyDeviceIdCallback get_legacy_device_id_callback_; |
| 74 | 73 |
| 75 // A cache for the legacy device id which is hard to compute and thus lazily | 74 // A cache for the legacy device id which is hard to compute and thus lazily |
| 76 // computed when/if required. The same instance is used across all | 75 // computed when/if required (computing the original value for this instance |
| 77 // PrefHashCalculators. | 76 // is allowed in const methods). |
| 78 static base::LazyInstance<scoped_ptr<const std::string> >::Leaky | 77 mutable scoped_ptr<const std::string> legacy_device_id_instance_; |
| 79 legacy_device_id_instance_; | |
| 80 | 78 |
| 81 DISALLOW_COPY_AND_ASSIGN(PrefHashCalculator); | 79 DISALLOW_COPY_AND_ASSIGN(PrefHashCalculator); |
| 82 }; | 80 }; |
| 83 | 81 |
| 84 #endif // CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR_H_ | 82 #endif // CHROME_BROWSER_PREFS_PREF_HASH_CALCULATOR_H_ |
| OLD | NEW |