| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ | 5 #ifndef CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ |
| 6 #define CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ | 6 #define CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 static void Shutdown(); | 32 static void Shutdown(); |
| 33 static SystemSaltGetter* Get(); | 33 static SystemSaltGetter* Get(); |
| 34 | 34 |
| 35 // Converts |salt| to a hex encoded string. | 35 // Converts |salt| to a hex encoded string. |
| 36 static std::string ConvertRawSaltToHexString(const RawSalt& salt); | 36 static std::string ConvertRawSaltToHexString(const RawSalt& salt); |
| 37 | 37 |
| 38 // Returns system hash in hex encoded ascii format. Note: this may return | 38 // Returns system hash in hex encoded ascii format. Note: this may return |
| 39 // an empty string (e.g. errors in D-Bus layer) | 39 // an empty string (e.g. errors in D-Bus layer) |
| 40 void GetSystemSalt(const GetSystemSaltCallback& callback); | 40 void GetSystemSalt(const GetSystemSaltCallback& callback); |
| 41 | 41 |
| 42 // Adds another callback to be called when system salt is received. |
| 43 // (If system salt is available, closure will be called immediately). |
| 44 void AddOnSystemSaltReady(const base::Closure& closure); |
| 45 |
| 42 // Returns pointer to binary system salt if it is already known. | 46 // Returns pointer to binary system salt if it is already known. |
| 43 // Returns nullptr if system salt is not known. | 47 // Returns nullptr if system salt is not known. |
| 44 const RawSalt* GetRawSalt() const; | 48 const RawSalt* GetRawSalt() const; |
| 45 | 49 |
| 46 // This is for browser tests API. | 50 // This is for browser tests API. |
| 47 void SetRawSaltForTesting(const RawSalt& raw_salt); | 51 void SetRawSaltForTesting(const RawSalt& raw_salt); |
| 48 | 52 |
| 49 protected: | 53 protected: |
| 50 SystemSaltGetter(); | 54 SystemSaltGetter(); |
| 51 ~SystemSaltGetter(); | 55 ~SystemSaltGetter(); |
| 52 | 56 |
| 53 private: | 57 private: |
| 54 // Used to implement GetSystemSalt(). | 58 // Used to implement GetSystemSalt(). |
| 55 void DidWaitForServiceToBeAvailable(const GetSystemSaltCallback& callback, | 59 void DidWaitForServiceToBeAvailable(const GetSystemSaltCallback& callback, |
| 56 bool service_is_available); | 60 bool service_is_available); |
| 57 void DidGetSystemSalt(const GetSystemSaltCallback& callback, | 61 void DidGetSystemSalt(const GetSystemSaltCallback& callback, |
| 58 DBusMethodCallStatus call_status, | 62 DBusMethodCallStatus call_status, |
| 59 const RawSalt& system_salt); | 63 const RawSalt& system_salt); |
| 60 | 64 |
| 61 RawSalt raw_salt_; | 65 RawSalt raw_salt_; |
| 62 std::string system_salt_; | 66 std::string system_salt_; |
| 63 | 67 |
| 68 // List of callbacks waiting for system salt ready event. |
| 69 std::vector<base::Closure> on_system_salt_ready_; |
| 70 |
| 64 base::WeakPtrFactory<SystemSaltGetter> weak_ptr_factory_; | 71 base::WeakPtrFactory<SystemSaltGetter> weak_ptr_factory_; |
| 65 | 72 |
| 66 DISALLOW_COPY_AND_ASSIGN(SystemSaltGetter); | 73 DISALLOW_COPY_AND_ASSIGN(SystemSaltGetter); |
| 67 }; | 74 }; |
| 68 | 75 |
| 69 } // namespace chromeos | 76 } // namespace chromeos |
| 70 | 77 |
| 71 #endif // CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ | 78 #endif // CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ |
| OLD | NEW |