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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/memory/weak_ptr.h" |
13 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
14 | 15 |
15 namespace chromeos { | 16 namespace chromeos { |
16 | 17 |
17 // This class is used to get the system salt from cryptohome and cache it. | 18 // This class is used to get the system salt from cryptohome and cache it. |
18 class CHROMEOS_EXPORT SystemSaltGetter { | 19 class CHROMEOS_EXPORT SystemSaltGetter { |
19 public: | 20 public: |
20 typedef base::Callback<void(const std::string& system_salt)> | 21 typedef base::Callback<void(const std::string& system_salt)> |
21 GetSystemSaltCallback; | 22 GetSystemSaltCallback; |
22 | 23 |
(...skipping 19 matching lines...) Expand all Loading... |
42 // Returns system hash in hex encoded ascii format, cached by a prior call | 43 // Returns system hash in hex encoded ascii format, cached by a prior call |
43 // to GetSystemSalt(). Note: this may return an empty string (e.g. if | 44 // to GetSystemSalt(). Note: this may return an empty string (e.g. if |
44 // GetSystemSalt() is not yet called). | 45 // GetSystemSalt() is not yet called). |
45 std::string GetCachedSystemSalt(); | 46 std::string GetCachedSystemSalt(); |
46 | 47 |
47 protected: | 48 protected: |
48 SystemSaltGetter(); | 49 SystemSaltGetter(); |
49 ~SystemSaltGetter(); | 50 ~SystemSaltGetter(); |
50 | 51 |
51 private: | 52 private: |
| 53 // Used to implement GetSystemSalt(). |
| 54 void GetSystemSaltInternal(const GetSystemSaltCallback& callback, |
| 55 bool service_is_available); |
| 56 |
52 // Loads the system salt from cryptohome and caches it. | 57 // Loads the system salt from cryptohome and caches it. |
53 void LoadSystemSalt(); | 58 void LoadSystemSalt(); |
54 | 59 |
55 std::string system_salt_; | 60 std::string system_salt_; |
56 | 61 |
| 62 base::WeakPtrFactory<SystemSaltGetter> weak_ptr_factory_; |
| 63 |
57 DISALLOW_COPY_AND_ASSIGN(SystemSaltGetter); | 64 DISALLOW_COPY_AND_ASSIGN(SystemSaltGetter); |
58 }; | 65 }; |
59 | 66 |
60 } // namespace chromeos | 67 } // namespace chromeos |
61 | 68 |
62 #endif // CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ | 69 #endif // CHROMEOS_CRYPTOHOME_SYSTEM_SALT_GETTER_H_ |
OLD | NEW |