Commit e820af9a authored by Jimmy Gong's avatar Jimmy Gong Committed by Commit Bot

Add UpdateMountCredentials SmbProviderClient

- Adds UpdateMountCredentials to SmbProviderClient.
- This function will interact with Dbus to call CrOS's
  SmbProvider::UpdateMountCredentials.
- Updated FakeSmbProviderClient.

Bug: chromium:913691
Test: emerges
Change-Id: I6311bc0d38282dacd659f82348189f96d29526bb
Reviewed-on: https://chromium-review.googlesource.com/c/1388029Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Commit-Queue: Zentaro Kavanagh <zentaro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#619852}
parent 94f12124
......@@ -259,6 +259,15 @@ void FakeSmbProviderClient::ContinueReadDirectory(
base::BindOnce(std::move(callback), smbprovider::ERROR_OK, entry_list));
}
void FakeSmbProviderClient::UpdateMountCredentials(int32_t mount_id,
std::string workgroup,
std::string username,
base::ScopedFD password_fd,
StatusCallback callback) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), smbprovider::ERROR_OK));
}
void FakeSmbProviderClient::ClearShares() {
shares_.clear();
}
......
......@@ -130,6 +130,12 @@ class CHROMEOS_EXPORT FakeSmbProviderClient : public SmbProviderClient {
int32_t read_dir_token,
ReadDirectoryCallback callback) override;
void UpdateMountCredentials(int32_t mount_id,
std::string workgroup,
std::string username,
base::ScopedFD password_fd,
StatusCallback callback) override;
// Adds |share| to the list of shares for |server_url| in |shares_|.
void AddToShares(const std::string& server_url, const std::string& share);
......
......@@ -360,6 +360,25 @@ class SmbProviderClientImpl : public SmbProviderClient {
&callback);
}
void UpdateMountCredentials(int32_t mount_id,
std::string workgroup,
std::string username,
base::ScopedFD password_fd,
StatusCallback callback) override {
smbprovider::UpdateMountCredentialsOptionsProto options;
options.set_mount_id(mount_id);
options.set_workgroup(workgroup);
options.set_username(username);
dbus::MethodCall method_call(smbprovider::kSmbProviderInterface,
smbprovider::kUpdateMountCredentialsMethod);
dbus::MessageWriter writer(&method_call);
writer.AppendProtoAsArrayOfBytes(options);
writer.AppendFileDescriptor(password_fd.get());
CallDefaultMethod(&method_call, &callback);
}
protected:
// DBusClient override.
void Init(dbus::Bus* bus) override {
......
......@@ -231,6 +231,16 @@ class CHROMEOS_EXPORT SmbProviderClient
int32_t read_dir_token,
ReadDirectoryCallback callback) = 0;
// Calls UpdateMountCredentials. This will update a mount's credentials with
// |workgroup|, |username|, and |password_fd|. Returns smbprovider::ERROR_OK
// if the mount's credentials successfully updated. Returns
// smbprovider::ERROR_NOT_FOUND if the mount's credentials were not updated.
virtual void UpdateMountCredentials(int32_t mount_id,
std::string workgroup,
std::string username,
base::ScopedFD password_fd,
StatusCallback callback) = 0;
protected:
// Create() should be used instead.
SmbProviderClient();
......
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