Commit 344cfb32 authored by Satoshi Niwa's avatar Satoshi Niwa Committed by Chromium LUCI CQ

cryptohome_client: Add GetCurrentSpaceForProjectId() and SetProjectId()

Depends on crrev.com/c/2557965 (cryptohome service-side CL)

BUG=b:171847983
TEST=Check if valid value is returned from cryptohome

Change-Id: I3d0b1ede10f576e60ba9582df8c7ab48e573bba4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2545853
Commit-Queue: Satoshi Niwa <niwa@chromium.org>
Auto-Submit: Satoshi Niwa <niwa@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835973}
parent 2a5030c1
...@@ -724,6 +724,41 @@ class CryptohomeClientImpl : public CryptohomeClient { ...@@ -724,6 +724,41 @@ class CryptohomeClientImpl : public CryptohomeClient {
weak_ptr_factory_.GetWeakPtr(), std::move(callback))); weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
} }
void GetCurrentSpaceForProjectId(
const int project_id,
DBusMethodCallback<int64_t> callback) override {
dbus::MethodCall method_call(
cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeGetCurrentSpaceForProjectId);
dbus::MessageWriter writer(&method_call);
writer.AppendUint32(project_id);
proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&CryptohomeClientImpl::OnInt64DBusMethod,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void SetProjectId(const int project_id,
const cryptohome::SetProjectIdAllowedPathType parent_path,
const std::string& child_path,
const cryptohome::AccountIdentifier& account_id,
DBusMethodCallback<bool> callback) override {
dbus::MethodCall method_call(cryptohome::kCryptohomeInterface,
cryptohome::kCryptohomeSetProjectId);
dbus::MessageWriter writer(&method_call);
writer.AppendUint32(project_id);
writer.AppendInt32(parent_path);
writer.AppendString(child_path);
writer.AppendProtoAsArrayOfBytes(account_id);
proxy_->CallMethod(
&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT,
base::BindOnce(&CryptohomeClientImpl::OnBoolMethod,
weak_ptr_factory_.GetWeakPtr(), std::move(callback)));
}
void GetRsuDeviceId( void GetRsuDeviceId(
DBusMethodCallback<cryptohome::BaseReply> callback) override { DBusMethodCallback<cryptohome::BaseReply> callback) override {
cryptohome::GetRsuDeviceIdRequest request; cryptohome::GetRsuDeviceIdRequest request;
......
...@@ -466,6 +466,22 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) CryptohomeClient { ...@@ -466,6 +466,22 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) CryptohomeClient {
virtual void GetCurrentSpaceForGid(const gid_t android_gid, virtual void GetCurrentSpaceForGid(const gid_t android_gid,
DBusMethodCallback<int64_t> callback) = 0; DBusMethodCallback<int64_t> callback) = 0;
// Calls GetCurrentSpaceForProjectId to get the current disk space for a
// project ID.
virtual void GetCurrentSpaceForProjectId(
const int project_id,
DBusMethodCallback<int64_t> callback) = 0;
// Calls SetProjectId to set the project ID to the file/directory pointed by
// path. |parent_path|, |child_path| and |account_id| are used for
// constructing the target path.
virtual void SetProjectId(
const int project_id,
const cryptohome::SetProjectIdAllowedPathType parent_path,
const std::string& child_path,
const cryptohome::AccountIdentifier& account_id,
DBusMethodCallback<bool> callback) = 0;
// Calls CheckHealth to get current health state. // Calls CheckHealth to get current health state.
virtual void CheckHealth( virtual void CheckHealth(
const cryptohome::CheckHealthRequest& request, const cryptohome::CheckHealthRequest& request,
......
...@@ -533,6 +533,17 @@ void FakeCryptohomeClient::GetCurrentSpaceForGid( ...@@ -533,6 +533,17 @@ void FakeCryptohomeClient::GetCurrentSpaceForGid(
gid_t android_gid, gid_t android_gid,
DBusMethodCallback<int64_t> callback) {} DBusMethodCallback<int64_t> callback) {}
void FakeCryptohomeClient::GetCurrentSpaceForProjectId(
int project_id,
DBusMethodCallback<int64_t> callback) {}
void FakeCryptohomeClient::SetProjectId(
const int project_id,
const cryptohome::SetProjectIdAllowedPathType parent_path,
const std::string& child_path,
const cryptohome::AccountIdentifier& account_id,
DBusMethodCallback<bool> callback) {}
void FakeCryptohomeClient::CheckHealth( void FakeCryptohomeClient::CheckHealth(
const cryptohome::CheckHealthRequest& request, const cryptohome::CheckHealthRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) { DBusMethodCallback<cryptohome::BaseReply> callback) {
......
...@@ -161,6 +161,14 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient ...@@ -161,6 +161,14 @@ class COMPONENT_EXPORT(CRYPTOHOME_CLIENT) FakeCryptohomeClient
DBusMethodCallback<int64_t> callback) override; DBusMethodCallback<int64_t> callback) override;
void GetCurrentSpaceForGid(gid_t android_gid, void GetCurrentSpaceForGid(gid_t android_gid,
DBusMethodCallback<int64_t> callback) override; DBusMethodCallback<int64_t> callback) override;
void GetCurrentSpaceForProjectId(
int project_id,
DBusMethodCallback<int64_t> callback) override;
void SetProjectId(const int project_id,
const cryptohome::SetProjectIdAllowedPathType parent_path,
const std::string& child_path,
const cryptohome::AccountIdentifier& account_id,
DBusMethodCallback<bool> callback) override;
void CheckHealth(const cryptohome::CheckHealthRequest& request, void CheckHealth(const cryptohome::CheckHealthRequest& request,
DBusMethodCallback<cryptohome::BaseReply> callback) override; DBusMethodCallback<cryptohome::BaseReply> callback) override;
void StartFingerprintAuthSession( void StartFingerprintAuthSession(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment