Commit d23f3ef7 authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Switch mount to use new mount result enum

Changes SmbService::Mount from returning a base::File::error as a result
to an SmbMountResult so that we can provide more valuable mount result
feedback to users.

Bug: chromium:757625
Change-Id: I8a7372529031a1ea6829f62119964b34c4a26465
Reviewed-on: https://chromium-review.googlesource.com/1058041Reviewed-by: default avatarScott Chen <scottchen@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#559296}
parent 2d0d04d5
......@@ -114,7 +114,8 @@ void SmbService::CallMount(const file_system_provider::MountOptions& options,
SmbUrl parsed_url;
if (!parsed_url.InitializeWithUrl(share_path.value())) {
std::move(callback).Run(base::File::Error::FILE_ERROR_INVALID_URL);
std::move(callback).Run(
TranslateErrorToMountResult(base::File::Error::FILE_ERROR_INVALID_URL));
return;
}
......@@ -135,7 +136,7 @@ void SmbService::OnMountResponse(
smbprovider::ErrorType error,
int32_t mount_id) {
if (error != smbprovider::ERROR_OK) {
std::move(callback).Run(TranslateToFileError(error));
std::move(callback).Run(TranslateErrorToMountResult(error));
return;
}
......@@ -147,7 +148,7 @@ void SmbService::OnMountResponse(
base::File::Error result =
GetProviderService()->MountFileSystem(provider_id_, mount_options);
std::move(callback).Run(result);
std::move(callback).Run(TranslateErrorToMountResult(result));
}
base::File::Error SmbService::Unmount(
......
......@@ -49,7 +49,7 @@ using file_system_provider::Service;
class SmbService : public KeyedService,
public base::SupportsWeakPtr<SmbService> {
public:
using MountResponse = base::OnceCallback<void(base::File::Error error)>;
using MountResponse = base::OnceCallback<void(SmbMountResult result)>;
explicit SmbService(Profile* profile);
~SmbService() override;
......
......@@ -10,7 +10,6 @@
#include "base/bind.h"
#include "base/values.h"
#include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.h"
#include "chrome/browser/chromeos/smb_client/smb_service.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/web_ui_message_handler.h"
......@@ -49,11 +48,11 @@ void SmbHandler::HandleSmbMount(const base::ListValue* args) {
weak_ptr_factory_.GetWeakPtr()));
}
void SmbHandler::HandleSmbMountResponse(base::File::Error error) {
std::string result = error == base::File::FILE_OK ? "success" : "failure";
void SmbHandler::HandleSmbMountResponse(SmbMountResult result) {
std::string status =
result == smb_client::SmbMountResult::SUCCESS ? "success" : "failure";
AllowJavascript();
FireWebUIListener("on-add-smb-share", base::Value(result));
FireWebUIListener("on-add-smb-share", base::Value(status));
}
} // namespace settings
......
......@@ -8,6 +8,7 @@
#include "base/files/file.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/smb_client/smb_service.h"
#include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
class Profile;
......@@ -15,6 +16,8 @@ class Profile;
namespace chromeos {
namespace settings {
using smb_client::SmbMountResult;
class SmbHandler : public ::settings::SettingsPageUIHandler {
public:
explicit SmbHandler(Profile* profile);
......@@ -29,7 +32,7 @@ class SmbHandler : public ::settings::SettingsPageUIHandler {
void HandleSmbMount(const base::ListValue* args);
// Callback handler for SmbMount.
void HandleSmbMountResponse(base::File::Error error);
void HandleSmbMountResponse(SmbMountResult result);
Profile* const profile_;
base::WeakPtrFactory<SmbHandler> weak_ptr_factory_;
......
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