| 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_DBUS_CRYPTOHOME_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_CRYPTOHOME_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_CRYPTOHOME_CLIENT_H_ | 6 #define CHROMEOS_DBUS_CRYPTOHOME_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "chromeos/attestation/attestation_constants.h" | 15 #include "chromeos/attestation/attestation_constants.h" |
| 16 #include "chromeos/chromeos_export.h" | 16 #include "chromeos/chromeos_export.h" |
| 17 #include "chromeos/dbus/dbus_client.h" | 17 #include "chromeos/dbus/dbus_client.h" |
| 18 #include "chromeos/dbus/dbus_method_call_status.h" | 18 #include "chromeos/dbus/dbus_method_call_status.h" |
| 19 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 19 | 20 |
| 20 namespace cryptohome { | 21 namespace cryptohome { |
| 21 | 22 |
| 22 class AddKeyRequest; | 23 class AddKeyRequest; |
| 23 class AuthorizationRequest; | 24 class AuthorizationRequest; |
| 24 class BaseReply; | 25 class BaseReply; |
| 25 class CheckKeyRequest; | 26 class CheckKeyRequest; |
| 26 class FlushAndSignBootAttributesRequest; | 27 class FlushAndSignBootAttributesRequest; |
| 27 class GetBootAttributeRequest; | 28 class GetBootAttributeRequest; |
| 28 class GetKeyDataRequest; | 29 class GetKeyDataRequest; |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 typedef base::Callback<void(DBusMethodCallStatus call_status, | 85 typedef base::Callback<void(DBusMethodCallStatus call_status, |
| 85 bool result, | 86 bool result, |
| 86 const std::string& data)> DataMethodCallback; | 87 const std::string& data)> DataMethodCallback; |
| 87 | 88 |
| 88 // A callback for methods which return both a bool and a protobuf as reply. | 89 // A callback for methods which return both a bool and a protobuf as reply. |
| 89 typedef base::Callback< | 90 typedef base::Callback< |
| 90 void(DBusMethodCallStatus call_status, | 91 void(DBusMethodCallStatus call_status, |
| 91 bool result, | 92 bool result, |
| 92 const cryptohome::BaseReply& reply)> ProtobufMethodCallback; | 93 const cryptohome::BaseReply& reply)> ProtobufMethodCallback; |
| 93 | 94 |
| 95 // A callback to handle DircryptoMigrationProgress signals. |
| 96 typedef base::Callback<void(cryptohome::DircryptoMigrationStatus status, |
| 97 uint64_t current, |
| 98 uint64_t total)> |
| 99 DircryptoMigrationProgessHandler; |
| 100 |
| 94 ~CryptohomeClient() override; | 101 ~CryptohomeClient() override; |
| 95 | 102 |
| 96 // Factory function, creates a new instance and returns ownership. | 103 // Factory function, creates a new instance and returns ownership. |
| 97 // For normal usage, access the singleton via DBusThreadManager::Get(). | 104 // For normal usage, access the singleton via DBusThreadManager::Get(). |
| 98 static CryptohomeClient* Create(); | 105 static CryptohomeClient* Create(); |
| 99 | 106 |
| 100 // Returns the sanitized |username| that the stub implementation would return. | 107 // Returns the sanitized |username| that the stub implementation would return. |
| 101 static std::string GetStubSanitizedUsername( | 108 static std::string GetStubSanitizedUsername( |
| 102 const cryptohome::Identification& cryptohome_id); | 109 const cryptohome::Identification& cryptohome_id); |
| 103 | 110 |
| 104 // Sets AsyncCallStatus signal handlers. | 111 // Sets AsyncCallStatus signal handlers. |
| 105 // |handler| is called when results for AsyncXXX methods are returned. | 112 // |handler| is called when results for AsyncXXX methods are returned. |
| 106 // Cryptohome service will process the calls in a first-in-first-out manner | 113 // Cryptohome service will process the calls in a first-in-first-out manner |
| 107 // when they are made in parallel. | 114 // when they are made in parallel. |
| 108 virtual void SetAsyncCallStatusHandlers( | 115 virtual void SetAsyncCallStatusHandlers( |
| 109 const AsyncCallStatusHandler& handler, | 116 const AsyncCallStatusHandler& handler, |
| 110 const AsyncCallStatusWithDataHandler& data_handler) = 0; | 117 const AsyncCallStatusWithDataHandler& data_handler) = 0; |
| 111 | 118 |
| 112 // Resets AsyncCallStatus signal handlers. | 119 // Resets AsyncCallStatus signal handlers. |
| 113 virtual void ResetAsyncCallStatusHandlers() = 0; | 120 virtual void ResetAsyncCallStatusHandlers() = 0; |
| 114 | 121 |
| 115 // Sets LowDiskSpace signal handler. |handler| is called when the cryptohome | 122 // Sets LowDiskSpace signal handler. |handler| is called when the cryptohome |
| 116 // partition is running out of disk space. | 123 // partition is running out of disk space. |
| 117 virtual void SetLowDiskSpaceHandler(const LowDiskSpaceHandler& handler) = 0; | 124 virtual void SetLowDiskSpaceHandler(const LowDiskSpaceHandler& handler) = 0; |
| 118 | 125 |
| 126 // A callback to handle DircryptoMigrationProgress signals. |handler| is |
| 127 // called periodicaly during a migration is performed by cryptohomed, as well |
| 128 // as to notify the completion of migration. |
| 129 virtual void SetDircryptoMigrationProgressHandler( |
| 130 const DircryptoMigrationProgessHandler& handler) = 0; |
| 131 |
| 119 // Runs the callback as soon as the service becomes available. | 132 // Runs the callback as soon as the service becomes available. |
| 120 virtual void WaitForServiceToBeAvailable( | 133 virtual void WaitForServiceToBeAvailable( |
| 121 const WaitForServiceToBeAvailableCallback& callback) = 0; | 134 const WaitForServiceToBeAvailableCallback& callback) = 0; |
| 122 | 135 |
| 123 // Calls IsMounted method and returns true when the call succeeds. | 136 // Calls IsMounted method and returns true when the call succeeds. |
| 124 virtual void IsMounted(const BoolDBusMethodCallback& callback) = 0; | 137 virtual void IsMounted(const BoolDBusMethodCallback& callback) = 0; |
| 125 | 138 |
| 126 // Calls Unmount method and returns true when the call succeeds. | 139 // Calls Unmount method and returns true when the call succeeds. |
| 127 // This method blocks until the call returns. | 140 // This method blocks until the call returns. |
| 128 virtual bool Unmount(bool* success) = 0; | 141 virtual bool Unmount(bool* success) = 0; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 | 561 |
| 549 // Asynchronously calls FlushAndSignBootAttributes method. |callback| is | 562 // Asynchronously calls FlushAndSignBootAttributes method. |callback| is |
| 550 // called after method call, and with reply protobuf. | 563 // called after method call, and with reply protobuf. |
| 551 // FlushAndSignBootAttributes makes all pending boot attribute settings | 564 // FlushAndSignBootAttributes makes all pending boot attribute settings |
| 552 // available, and have them signed by a special TPM key. This method always | 565 // available, and have them signed by a special TPM key. This method always |
| 553 // fails after any user, publuc, or guest session starts. | 566 // fails after any user, publuc, or guest session starts. |
| 554 virtual void FlushAndSignBootAttributes( | 567 virtual void FlushAndSignBootAttributes( |
| 555 const cryptohome::FlushAndSignBootAttributesRequest& request, | 568 const cryptohome::FlushAndSignBootAttributesRequest& request, |
| 556 const ProtobufMethodCallback& callback) = 0; | 569 const ProtobufMethodCallback& callback) = 0; |
| 557 | 570 |
| 571 // Asynchronously calls MigrateToDircrypto method. It tells cryptohomed to |
| 572 // start migration, and is immediately called back by |callback|. The actual |
| 573 // result response is done via DircryptoMigrationProgress callback with its |
| 574 // status flag indicating the completion. |
| 575 // MigrateToDircrypto attempts to migrate the home dir using given |
| 576 // authorization to the new "dircrypto" encryption. |
| 577 virtual void MigrateToDircrypto( |
| 578 const cryptohome::Identification& cryptohome_id, |
| 579 const cryptohome::AuthorizationRequest& auth, |
| 580 const VoidDBusMethodCallback& callback) = 0; |
| 581 |
| 558 protected: | 582 protected: |
| 559 // Create() should be used instead. | 583 // Create() should be used instead. |
| 560 CryptohomeClient(); | 584 CryptohomeClient(); |
| 561 | 585 |
| 562 private: | 586 private: |
| 563 DISALLOW_COPY_AND_ASSIGN(CryptohomeClient); | 587 DISALLOW_COPY_AND_ASSIGN(CryptohomeClient); |
| 564 }; | 588 }; |
| 565 | 589 |
| 566 } // namespace chromeos | 590 } // namespace chromeos |
| 567 | 591 |
| 568 #endif // CHROMEOS_DBUS_CRYPTOHOME_CLIENT_H_ | 592 #endif // CHROMEOS_DBUS_CRYPTOHOME_CLIENT_H_ |
| OLD | NEW |