Chromium Code Reviews| Index: chromeos/dbus/cryptohome_client.cc |
| diff --git a/chromeos/dbus/cryptohome_client.cc b/chromeos/dbus/cryptohome_client.cc |
| index 86fe5b7e65ab7ff67ad86c151812aee85abde460..05b653ec0ae7176228a9d9dbdf4d1d2011d5268f 100644 |
| --- a/chromeos/dbus/cryptohome_client.cc |
| +++ b/chromeos/dbus/cryptohome_client.cc |
| @@ -68,6 +68,12 @@ class CryptohomeClientImpl : public CryptohomeClient { |
| } |
| // CryptohomeClient override. |
| + void SetDircryptoMigrationProgressHandler( |
| + const DircryptoMigrationProgessHandler& handler) override { |
| + dircrypto_migration_progress_handler_ = handler; |
| + } |
| + |
| + // CryptohomeClient override. |
| void WaitForServiceToBeAvailable( |
| const WaitForServiceToBeAvailableCallback& callback) override { |
| proxy_->WaitForServiceToBeAvailable(callback); |
| @@ -927,6 +933,24 @@ class CryptohomeClientImpl : public CryptohomeClient { |
| callback)); |
| } |
| + void MigrateToDircrypto(const cryptohome::Identification& cryptohome_id, |
| + const cryptohome::AuthorizationRequest& auth, |
| + const ProtobufMethodCallback& callback) override { |
| + const char* method_name = cryptohome::kCryptohomeMigrateToDircrypto; |
|
Daniel Erat
2017/03/14 15:37:36
nit: just inline this in the next statement? it do
kinaba
2017/03/15 08:17:30
Done.
|
| + dbus::MethodCall method_call(cryptohome::kCryptohomeInterface, method_name); |
| + |
| + cryptohome::AccountIdentifier id_proto; |
| + FillIdentificationProtobuf(cryptohome_id, &id_proto); |
| + |
| + dbus::MessageWriter writer(&method_call); |
| + writer.AppendProtoAsArrayOfBytes(id_proto); |
| + writer.AppendProtoAsArrayOfBytes(auth); |
| + |
| + proxy_->CallMethod(&method_call, kTpmDBusTimeoutMs, |
|
Daniel Erat
2017/03/14 15:37:36
is this dependent on the TPM, or does it make sens
kinaba
2017/03/15 08:17:30
Good catch. Done
|
| + base::Bind(&CryptohomeClientImpl::OnBaseReplyMethod, |
| + weak_ptr_factory_.GetWeakPtr(), callback)); |
| + } |
| + |
| protected: |
| void Init(dbus::Bus* bus) override { |
| proxy_ = bus->GetObjectProxy( |
| @@ -954,6 +978,13 @@ class CryptohomeClientImpl : public CryptohomeClient { |
| weak_ptr_factory_.GetWeakPtr()), |
| base::Bind(&CryptohomeClientImpl::OnSignalConnected, |
| weak_ptr_factory_.GetWeakPtr())); |
| + proxy_->ConnectToSignal( |
| + cryptohome::kCryptohomeInterface, |
| + cryptohome::kSignalDircryptoMigrationProgress, |
| + base::Bind(&CryptohomeClientImpl::OnDircryptoMigrationProgress, |
| + weak_ptr_factory_.GetWeakPtr()), |
| + base::Bind(&CryptohomeClientImpl::OnSignalConnected, |
| + weak_ptr_factory_.GetWeakPtr())); |
| } |
| private: |
| @@ -1187,6 +1218,22 @@ class CryptohomeClientImpl : public CryptohomeClient { |
| low_disk_space_handler_.Run(disk_free_bytes); |
| } |
| + // Handles DircryptoMigrationProgess signal. |
| + void OnDircryptoMigrationProgress(dbus::Signal* signal) { |
| + dbus::MessageReader reader(signal); |
| + uint64_t current = 0, total = 0; |
| + if (!reader.PopUint64(¤t)) { |
| + LOG(ERROR) << "Invalid signal: " << signal->ToString(); |
| + return; |
| + } |
| + if (!reader.PopUint64(&total)) { |
|
Daniel Erat
2017/03/14 15:37:36
just merge these:
if (!reader.PopUint64(¤
kinaba
2017/03/15 08:17:30
Done.
|
| + LOG(ERROR) << "Invalid signal: " << signal->ToString(); |
| + return; |
| + } |
| + if (!dircrypto_migration_progress_handler_.is_null()) |
|
Daniel Erat
2017/03/14 15:37:36
move this check to the top of the method? it doesn
kinaba
2017/03/15 08:17:30
Done.
|
| + dircrypto_migration_progress_handler_.Run(current, total); |
| + } |
| + |
| // Handles the result of signal connection setup. |
| void OnSignalConnected(const std::string& interface, |
| const std::string& signal, |
| @@ -1200,6 +1247,7 @@ class CryptohomeClientImpl : public CryptohomeClient { |
| AsyncCallStatusHandler async_call_status_handler_; |
| AsyncCallStatusWithDataHandler async_call_status_data_handler_; |
| LowDiskSpaceHandler low_disk_space_handler_; |
| + DircryptoMigrationProgessHandler dircrypto_migration_progress_handler_; |
| // Note: This should remain the last member so it'll be destroyed and |
| // invalidate its weak pointers before any other members are destroyed. |