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 CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "chromeos/dbus/cryptohome_client.h" | 12 #include "chromeos/dbus/cryptohome_client.h" |
13 | 13 |
14 namespace chromeos { | 14 namespace chromeos { |
15 | 15 |
16 class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient { | 16 class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient { |
17 public: | 17 public: |
18 FakeCryptohomeClient(); | 18 FakeCryptohomeClient(); |
19 virtual ~FakeCryptohomeClient(); | 19 virtual ~FakeCryptohomeClient(); |
20 | 20 |
21 virtual void Init(dbus::Bus* bus) OVERRIDE; | 21 virtual void Init(dbus::Bus* bus) OVERRIDE; |
22 virtual void SetAsyncCallStatusHandlers( | 22 virtual void SetAsyncCallStatusHandlers( |
23 const AsyncCallStatusHandler& handler, | 23 const AsyncCallStatusHandler& handler, |
24 const AsyncCallStatusWithDataHandler& data_handler) OVERRIDE; | 24 const AsyncCallStatusWithDataHandler& data_handler) OVERRIDE; |
25 virtual void ResetAsyncCallStatusHandlers() OVERRIDE; | 25 virtual void ResetAsyncCallStatusHandlers() OVERRIDE; |
| 26 virtual void WaitForServiceToBeAvailable( |
| 27 const WaitForServiceToBeAvailableCallback& callback) OVERRIDE; |
26 virtual void IsMounted(const BoolDBusMethodCallback& callback) OVERRIDE; | 28 virtual void IsMounted(const BoolDBusMethodCallback& callback) OVERRIDE; |
27 virtual bool Unmount(bool* success) OVERRIDE; | 29 virtual bool Unmount(bool* success) OVERRIDE; |
28 virtual void AsyncCheckKey(const std::string& username, | 30 virtual void AsyncCheckKey(const std::string& username, |
29 const std::string& key, | 31 const std::string& key, |
30 const AsyncMethodCallback& callback) OVERRIDE; | 32 const AsyncMethodCallback& callback) OVERRIDE; |
31 virtual void AsyncMigrateKey(const std::string& username, | 33 virtual void AsyncMigrateKey(const std::string& username, |
32 const std::string& from_key, | 34 const std::string& from_key, |
33 const std::string& to_key, | 35 const std::string& to_key, |
34 const AsyncMethodCallback& callback) OVERRIDE; | 36 const AsyncMethodCallback& callback) OVERRIDE; |
35 virtual void AsyncRemove(const std::string& username, | 37 virtual void AsyncRemove(const std::string& username, |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 const std::string& user_id, | 146 const std::string& user_id, |
145 const std::string& key_name, | 147 const std::string& key_name, |
146 const DataMethodCallback& callback) OVERRIDE; | 148 const DataMethodCallback& callback) OVERRIDE; |
147 virtual void TpmAttestationSetKeyPayload( | 149 virtual void TpmAttestationSetKeyPayload( |
148 attestation::AttestationKeyType key_type, | 150 attestation::AttestationKeyType key_type, |
149 const std::string& user_id, | 151 const std::string& user_id, |
150 const std::string& key_name, | 152 const std::string& key_name, |
151 const std::string& payload, | 153 const std::string& payload, |
152 const BoolDBusMethodCallback& callback) OVERRIDE; | 154 const BoolDBusMethodCallback& callback) OVERRIDE; |
153 | 155 |
| 156 // Changes the behavior of WaitForServiceToBeAvailable(). This method runs |
| 157 // pending callbacks if is_available is true. |
| 158 void SetServiceIsAvailable(bool is_available); |
| 159 |
154 // Sets the unmount result of Unmount() call. | 160 // Sets the unmount result of Unmount() call. |
155 void set_unmount_result(bool result) { | 161 void set_unmount_result(bool result) { |
156 unmount_result_= result; | 162 unmount_result_= result; |
157 } | 163 } |
158 | 164 |
159 // Returns the stub system salt as raw bytes. (not as a string encoded in the | 165 // Returns the stub system salt as raw bytes. (not as a string encoded in the |
160 // format used by SystemSaltGetter::ConvertRawSaltToHexString()). | 166 // format used by SystemSaltGetter::ConvertRawSaltToHexString()). |
161 static std::vector<uint8> GetStubSystemSalt(); | 167 static std::vector<uint8> GetStubSystemSalt(); |
162 | 168 |
163 private: | 169 private: |
164 // Posts tasks which return fake results to the UI thread. | 170 // Posts tasks which return fake results to the UI thread. |
165 void ReturnAsyncMethodResult(const AsyncMethodCallback& callback, | 171 void ReturnAsyncMethodResult(const AsyncMethodCallback& callback, |
166 bool returns_data); | 172 bool returns_data); |
167 | 173 |
168 // This method is used to implement ReturnAsyncMethodResult. | 174 // This method is used to implement ReturnAsyncMethodResult. |
169 void ReturnAsyncMethodResultInternal(const AsyncMethodCallback& callback, | 175 void ReturnAsyncMethodResultInternal(const AsyncMethodCallback& callback, |
170 bool returns_data); | 176 bool returns_data); |
171 | 177 |
| 178 bool service_is_available_; |
172 int async_call_id_; | 179 int async_call_id_; |
173 AsyncCallStatusHandler async_call_status_handler_; | 180 AsyncCallStatusHandler async_call_status_handler_; |
174 AsyncCallStatusWithDataHandler async_call_status_data_handler_; | 181 AsyncCallStatusWithDataHandler async_call_status_data_handler_; |
175 int tpm_is_ready_counter_; | 182 int tpm_is_ready_counter_; |
176 bool unmount_result_; | 183 bool unmount_result_; |
177 | 184 |
| 185 std::vector<WaitForServiceToBeAvailableCallback> |
| 186 pending_wait_for_service_to_be_available_callbacks_; |
| 187 |
178 // A stub store for InstallAttributes, mapping an attribute name to the | 188 // A stub store for InstallAttributes, mapping an attribute name to the |
179 // associated data blob. Used to implement InstallAttributesSet and -Get. | 189 // associated data blob. Used to implement InstallAttributesSet and -Get. |
180 std::map<std::string, std::vector<uint8> > install_attrs_; | 190 std::map<std::string, std::vector<uint8> > install_attrs_; |
181 bool locked_; | 191 bool locked_; |
182 base::WeakPtrFactory<FakeCryptohomeClient> weak_ptr_factory_; | 192 base::WeakPtrFactory<FakeCryptohomeClient> weak_ptr_factory_; |
183 | 193 |
184 DISALLOW_COPY_AND_ASSIGN(FakeCryptohomeClient); | 194 DISALLOW_COPY_AND_ASSIGN(FakeCryptohomeClient); |
185 }; | 195 }; |
186 | 196 |
187 } // namespace chromeos | 197 } // namespace chromeos |
188 | 198 |
189 #endif // CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ | 199 #endif // CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ |
OLD | NEW |