OLD | NEW |
1 // Copyright (c) 2009-2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2009-2010 The Chromium OS 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 // TpmInit - public interface class for initializing the TPM | 5 // TpmInit - public interface class for initializing the TPM |
6 | 6 |
| 7 #include <base/basictypes.h> |
7 #include <base/scoped_ptr.h> | 8 #include <base/scoped_ptr.h> |
8 #include <base/platform_thread.h> | |
9 #include <chromeos/utility.h> | 9 #include <chromeos/utility.h> |
10 | 10 |
11 #ifndef TPM_INIT_TPM_INIT_H_ | 11 #ifndef TPM_INIT_TPM_INIT_H_ |
12 #define TPM_INIT_TPM_INIT_H_ | 12 #define TPM_INIT_TPM_INIT_H_ |
13 | 13 |
14 namespace tpm_init { | 14 namespace tpm_init { |
15 | 15 |
16 class TpmInitTask; | 16 class TpmInitTask; |
17 | 17 |
18 class TpmInit { | 18 class TpmInit { |
| 19 // Friend class TpmInitTask as it is a glue class to allow ThreadMain to be |
| 20 // called on a separate thread without inheriting from |
| 21 // PlatformThread::Delegate |
| 22 friend class TpmInitTask; |
19 public: | 23 public: |
20 | 24 |
21 class TpmInitCallback { | 25 class TpmInitCallback { |
22 public: | 26 public: |
23 virtual void InitializeTpmComplete(bool status, bool took_ownership) = 0; | 27 virtual void InitializeTpmComplete(bool status, bool took_ownership) = 0; |
24 }; | 28 }; |
25 | 29 |
26 // Default constructor | 30 // Default constructor |
27 TpmInit(); | 31 TpmInit(); |
28 | 32 |
(...skipping 16 matching lines...) Expand all Loading... |
45 | 49 |
46 // Returns true if the TPM is enabled | 50 // Returns true if the TPM is enabled |
47 virtual bool IsTpmEnabled(); | 51 virtual bool IsTpmEnabled(); |
48 | 52 |
49 // Returns true if the TPM is owned | 53 // Returns true if the TPM is owned |
50 virtual bool IsTpmOwned(); | 54 virtual bool IsTpmOwned(); |
51 | 55 |
52 // Returns true if the TPM is being owned | 56 // Returns true if the TPM is being owned |
53 virtual bool IsTpmBeingOwned(); | 57 virtual bool IsTpmBeingOwned(); |
54 | 58 |
| 59 // Returns true if initialization has been called |
| 60 virtual bool HasInitializeBeenCalled(); |
| 61 |
55 // Gets the TPM password if the TPM initialization took ownership | 62 // Gets the TPM password if the TPM initialization took ownership |
56 // | 63 // |
57 // Parameters | 64 // Parameters |
58 // password (OUT) - The owner password used for the TPM | 65 // password (OUT) - The owner password used for the TPM |
59 virtual bool GetTpmPassword(chromeos::Blob* password); | 66 virtual bool GetTpmPassword(chromeos::Blob* password); |
60 | 67 |
| 68 // Clears the TPM password from memory and disk |
| 69 virtual void ClearStoredTpmPassword(); |
| 70 |
61 // Returns the number of milliseconds it took to initialize the TPM | 71 // Returns the number of milliseconds it took to initialize the TPM |
62 virtual long GetInitializationMillis(); | 72 virtual long GetInitializationMillis(); |
63 | 73 |
64 private: | 74 private: |
| 75 virtual void ThreadMain(); |
| 76 |
65 // The background task for initializing the TPM, implemented as a | 77 // The background task for initializing the TPM, implemented as a |
66 // PlatformThread::Delegate | 78 // PlatformThread::Delegate |
67 scoped_ptr<TpmInitTask> tpm_init_task_; | 79 scoped_ptr<TpmInitTask> tpm_init_task_; |
68 | 80 |
69 TpmInitCallback* notify_callback_; | 81 TpmInitCallback* notify_callback_; |
70 | 82 |
| 83 bool initialize_called_; |
| 84 bool task_done_; |
| 85 bool initialize_took_ownership_; |
| 86 long initialization_time_; |
| 87 |
71 DISALLOW_COPY_AND_ASSIGN(TpmInit); | 88 DISALLOW_COPY_AND_ASSIGN(TpmInit); |
72 }; | 89 }; |
73 | 90 |
74 } // namespace tpm_init | 91 } // namespace tpm_init |
75 | 92 |
76 #endif // TPM_INIT_TPM_INIT_H_ | 93 #endif // TPM_INIT_TPM_INIT_H_ |
OLD | NEW |