| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <string> |
| 12 #include <vector> |
| 11 | 13 |
| 12 #include "base/macros.h" | 14 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
| 14 #include "chromeos/dbus/cryptohome_client.h" | 16 #include "chromeos/dbus/cryptohome_client.h" |
| 15 | 17 |
| 16 namespace chromeos { | 18 namespace chromeos { |
| 17 | 19 |
| 18 class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient { | 20 class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient { |
| 19 public: | 21 public: |
| 20 FakeCryptohomeClient(); | 22 FakeCryptohomeClient(); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 // Returns the stub system salt as raw bytes. (not as a string encoded in the | 215 // Returns the stub system salt as raw bytes. (not as a string encoded in the |
| 214 // format used by SystemSaltGetter::ConvertRawSaltToHexString()). | 216 // format used by SystemSaltGetter::ConvertRawSaltToHexString()). |
| 215 static std::vector<uint8_t> GetStubSystemSalt(); | 217 static std::vector<uint8_t> GetStubSystemSalt(); |
| 216 | 218 |
| 217 private: | 219 private: |
| 218 void ReturnProtobufMethodCallback( | 220 void ReturnProtobufMethodCallback( |
| 219 const cryptohome::BaseReply& reply, | 221 const cryptohome::BaseReply& reply, |
| 220 const ProtobufMethodCallback& callback); | 222 const ProtobufMethodCallback& callback); |
| 221 | 223 |
| 222 // Posts tasks which return fake results to the UI thread. | 224 // Posts tasks which return fake results to the UI thread. |
| 223 void ReturnAsyncMethodResult(const AsyncMethodCallback& callback, | 225 void ReturnAsyncMethodResult(const AsyncMethodCallback& callback); |
| 224 bool returns_data); | |
| 225 | 226 |
| 226 // This method is used to implement ReturnAsyncMethodResult. | 227 // Posts tasks which return fake data to the UI thread. |
| 227 void ReturnAsyncMethodResultInternal(const AsyncMethodCallback& callback, | 228 void ReturnAsyncMethodData(const AsyncMethodCallback& callback, |
| 228 bool returns_data); | 229 const std::string& data); |
| 230 |
| 231 // This method is used to implement ReturnAsyncMethodResult without data. |
| 232 void ReturnAsyncMethodResultInternal(const AsyncMethodCallback& callback); |
| 233 |
| 234 // This method is used to implement ReturnAsyncMethodResult with data. |
| 235 void ReturnAsyncMethodDataInternal(const AsyncMethodCallback& callback, |
| 236 const std::string& data); |
| 229 | 237 |
| 230 bool service_is_available_; | 238 bool service_is_available_; |
| 231 int async_call_id_; | 239 int async_call_id_; |
| 232 AsyncCallStatusHandler async_call_status_handler_; | 240 AsyncCallStatusHandler async_call_status_handler_; |
| 233 AsyncCallStatusWithDataHandler async_call_status_data_handler_; | 241 AsyncCallStatusWithDataHandler async_call_status_data_handler_; |
| 234 bool unmount_result_; | 242 bool unmount_result_; |
| 235 std::vector<uint8_t> system_salt_; | 243 std::vector<uint8_t> system_salt_; |
| 236 | 244 |
| 237 std::vector<WaitForServiceToBeAvailableCallback> | 245 std::vector<WaitForServiceToBeAvailableCallback> |
| 238 pending_wait_for_service_to_be_available_callbacks_; | 246 pending_wait_for_service_to_be_available_callbacks_; |
| 239 | 247 |
| 240 // A stub store for InstallAttributes, mapping an attribute name to the | 248 // A stub store for InstallAttributes, mapping an attribute name to the |
| 241 // associated data blob. Used to implement InstallAttributesSet and -Get. | 249 // associated data blob. Used to implement InstallAttributesSet and -Get. |
| 242 std::map<std::string, std::vector<uint8_t>> install_attrs_; | 250 std::map<std::string, std::vector<uint8_t>> install_attrs_; |
| 243 bool locked_; | 251 bool locked_; |
| 244 base::WeakPtrFactory<FakeCryptohomeClient> weak_ptr_factory_; | 252 base::WeakPtrFactory<FakeCryptohomeClient> weak_ptr_factory_; |
| 245 | 253 |
| 246 DISALLOW_COPY_AND_ASSIGN(FakeCryptohomeClient); | 254 DISALLOW_COPY_AND_ASSIGN(FakeCryptohomeClient); |
| 247 }; | 255 }; |
| 248 | 256 |
| 249 } // namespace chromeos | 257 } // namespace chromeos |
| 250 | 258 |
| 251 #endif // CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ | 259 #endif // CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ |
| OLD | NEW |