Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(380)

Side by Side Diff: chromeos/tpm/tpm_token_info_getter.h

Issue 1165323004: We should use UserID object to identify users instead of username. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_TPM_TPM_TOKEN_INFO_GETTER_H_ 5 #ifndef CHROMEOS_TPM_TPM_TOKEN_INFO_GETTER_H_
6 #define CHROMEOS_TPM_TPM_TOKEN_INFO_GETTER_H_ 6 #define CHROMEOS_TPM_TPM_TOKEN_INFO_GETTER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chromeos/chromeos_export.h" 14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_method_call_status.h" 15 #include "chromeos/dbus/dbus_method_call_status.h"
16 #include "components/user_manager/user_id.h"
16 17
17 namespace base { 18 namespace base {
18 class TaskRunner; 19 class TaskRunner;
19 } 20 }
20 21
21 namespace chromeos { 22 namespace chromeos {
22 class CryptohomeClient; 23 class CryptohomeClient;
23 } 24 }
24 25
25 namespace chromeos { 26 namespace chromeos {
(...skipping 13 matching lines...) Expand all
39 }; 40 };
40 41
41 // Class for getting a user or the system TPM token info from cryptohome during 42 // Class for getting a user or the system TPM token info from cryptohome during
42 // TPM token loading. 43 // TPM token loading.
43 class CHROMEOS_EXPORT TPMTokenInfoGetter { 44 class CHROMEOS_EXPORT TPMTokenInfoGetter {
44 public: 45 public:
45 using TPMTokenInfoCallback = base::Callback<void(const TPMTokenInfo& info)>; 46 using TPMTokenInfoCallback = base::Callback<void(const TPMTokenInfo& info)>;
46 47
47 // Factory method for TPMTokenInfoGetter for a user token. 48 // Factory method for TPMTokenInfoGetter for a user token.
48 static scoped_ptr<TPMTokenInfoGetter> CreateForUserToken( 49 static scoped_ptr<TPMTokenInfoGetter> CreateForUserToken(
49 const std::string& user_id, 50 const user_manager::UserID& user_id,
50 CryptohomeClient* cryptohome_client, 51 CryptohomeClient* cryptohome_client,
51 const scoped_refptr<base::TaskRunner>& delayed_task_runner); 52 const scoped_refptr<base::TaskRunner>& delayed_task_runner);
52 53
53 // Factory method for TPMTokenGetter for the system token. 54 // Factory method for TPMTokenGetter for the system token.
54 static scoped_ptr<TPMTokenInfoGetter> CreateForSystemToken( 55 static scoped_ptr<TPMTokenInfoGetter> CreateForSystemToken(
55 CryptohomeClient* cryptohome_client, 56 CryptohomeClient* cryptohome_client,
56 const scoped_refptr<base::TaskRunner>& delayed_task_runner); 57 const scoped_refptr<base::TaskRunner>& delayed_task_runner);
57 58
58 ~TPMTokenInfoGetter(); 59 ~TPMTokenInfoGetter();
59 60
(...skipping 12 matching lines...) Expand all
72 73
73 enum State { 74 enum State {
74 STATE_INITIAL, 75 STATE_INITIAL,
75 STATE_STARTED, 76 STATE_STARTED,
76 STATE_TPM_ENABLED, 77 STATE_TPM_ENABLED,
77 STATE_DONE 78 STATE_DONE
78 }; 79 };
79 80
80 TPMTokenInfoGetter( 81 TPMTokenInfoGetter(
81 Type type, 82 Type type,
82 const std::string& user_id, 83 const user_manager::UserID& user_id,
83 CryptohomeClient* cryptohome_client, 84 CryptohomeClient* cryptohome_client,
84 const scoped_refptr<base::TaskRunner>& delayed_task_runner); 85 const scoped_refptr<base::TaskRunner>& delayed_task_runner);
85 86
86 // Continues TPM token info getting procedure by starting the task associated 87 // Continues TPM token info getting procedure by starting the task associated
87 // with the current TPMTokenInfoGetter state. 88 // with the current TPMTokenInfoGetter state.
88 void Continue(); 89 void Continue();
89 90
90 // If token initialization step fails (e.g. if tpm token is not yet ready) 91 // If token initialization step fails (e.g. if tpm token is not yet ready)
91 // schedules the initialization step retry attempt after a timeout. 92 // schedules the initialization step retry attempt after a timeout.
92 void RetryLater(); 93 void RetryLater();
93 94
94 // Cryptohome methods callbacks. 95 // Cryptohome methods callbacks.
95 void OnTpmIsEnabled(DBusMethodCallStatus call_status, 96 void OnTpmIsEnabled(DBusMethodCallStatus call_status,
96 bool tpm_is_enabled); 97 bool tpm_is_enabled);
97 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status, 98 void OnPkcs11GetTpmTokenInfo(DBusMethodCallStatus call_status,
98 const std::string& token_name, 99 const std::string& token_name,
99 const std::string& user_pin, 100 const std::string& user_pin,
100 int token_slot_id); 101 int token_slot_id);
101 102
102 // The task runner used to run delayed tasks when retrying failed Cryptohome 103 // The task runner used to run delayed tasks when retrying failed Cryptohome
103 // calls. 104 // calls.
104 scoped_refptr<base::TaskRunner> delayed_task_runner_; 105 scoped_refptr<base::TaskRunner> delayed_task_runner_;
105 106
106 Type type_; 107 Type type_;
107 State state_; 108 State state_;
108 109
109 // The user id associated with the TPMTokenInfoGetter. Empty for system token. 110 // The user id associated with the TPMTokenInfoGetter. Empty for system token.
110 std::string user_id_; 111 user_manager::UserID user_id_;
111 112
112 TPMTokenInfoCallback callback_; 113 TPMTokenInfoCallback callback_;
113 114
114 // The current request delay before the next attempt to initialize the 115 // The current request delay before the next attempt to initialize the
115 // TPM. Will be adapted after each attempt. 116 // TPM. Will be adapted after each attempt.
116 base::TimeDelta tpm_request_delay_; 117 base::TimeDelta tpm_request_delay_;
117 118
118 CryptohomeClient* cryptohome_client_; 119 CryptohomeClient* cryptohome_client_;
119 120
120 base::WeakPtrFactory<TPMTokenInfoGetter> weak_factory_; 121 base::WeakPtrFactory<TPMTokenInfoGetter> weak_factory_;
121 122
122 DISALLOW_COPY_AND_ASSIGN(TPMTokenInfoGetter); 123 DISALLOW_COPY_AND_ASSIGN(TPMTokenInfoGetter);
123 }; 124 };
124 125
125 } // namespace chromeos 126 } // namespace chromeos
126 127
127 #endif // CHROMEOS_TPM_TPM_TOKEN_INFO_GETTER_H_ 128 #endif // CHROMEOS_TPM_TPM_TOKEN_INFO_GETTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698