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, ...@@ -114,7 +114,8 @@ void SmbService::CallMount(const file_system_provider::MountOptions& options,
SmbUrl parsed_url; SmbUrl parsed_url;
if (!parsed_url.InitializeWithUrl(share_path.value())) { 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; return;
} }
...@@ -135,7 +136,7 @@ void SmbService::OnMountResponse( ...@@ -135,7 +136,7 @@ void SmbService::OnMountResponse(
smbprovider::ErrorType error, smbprovider::ErrorType error,
int32_t mount_id) { int32_t mount_id) {
if (error != smbprovider::ERROR_OK) { if (error != smbprovider::ERROR_OK) {
std::move(callback).Run(TranslateToFileError(error)); std::move(callback).Run(TranslateErrorToMountResult(error));
return; return;
} }
...@@ -147,7 +148,7 @@ void SmbService::OnMountResponse( ...@@ -147,7 +148,7 @@ void SmbService::OnMountResponse(
base::File::Error result = base::File::Error result =
GetProviderService()->MountFileSystem(provider_id_, mount_options); GetProviderService()->MountFileSystem(provider_id_, mount_options);
std::move(callback).Run(result); std::move(callback).Run(TranslateErrorToMountResult(result));
} }
base::File::Error SmbService::Unmount( base::File::Error SmbService::Unmount(
......
...@@ -49,7 +49,7 @@ using file_system_provider::Service; ...@@ -49,7 +49,7 @@ using file_system_provider::Service;
class SmbService : public KeyedService, class SmbService : public KeyedService,
public base::SupportsWeakPtr<SmbService> { public base::SupportsWeakPtr<SmbService> {
public: public:
using MountResponse = base::OnceCallback<void(base::File::Error error)>; using MountResponse = base::OnceCallback<void(SmbMountResult result)>;
explicit SmbService(Profile* profile); explicit SmbService(Profile* profile);
~SmbService() override; ~SmbService() override;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/chromeos/file_system_provider/provided_file_system_info.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 "chrome/browser/profiles/profile.h"
#include "content/public/browser/web_ui_message_handler.h" #include "content/public/browser/web_ui_message_handler.h"
...@@ -49,11 +48,11 @@ void SmbHandler::HandleSmbMount(const base::ListValue* args) { ...@@ -49,11 +48,11 @@ void SmbHandler::HandleSmbMount(const base::ListValue* args) {
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
void SmbHandler::HandleSmbMountResponse(base::File::Error error) { void SmbHandler::HandleSmbMountResponse(SmbMountResult result) {
std::string result = error == base::File::FILE_OK ? "success" : "failure"; std::string status =
result == smb_client::SmbMountResult::SUCCESS ? "success" : "failure";
AllowJavascript(); AllowJavascript();
FireWebUIListener("on-add-smb-share", base::Value(result)); FireWebUIListener("on-add-smb-share", base::Value(status));
} }
} // namespace settings } // namespace settings
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/files/file.h" #include "base/files/file.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.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" #include "chrome/browser/ui/webui/settings/settings_page_ui_handler.h"
class Profile; class Profile;
...@@ -15,6 +16,8 @@ class Profile; ...@@ -15,6 +16,8 @@ class Profile;
namespace chromeos { namespace chromeos {
namespace settings { namespace settings {
using smb_client::SmbMountResult;
class SmbHandler : public ::settings::SettingsPageUIHandler { class SmbHandler : public ::settings::SettingsPageUIHandler {
public: public:
explicit SmbHandler(Profile* profile); explicit SmbHandler(Profile* profile);
...@@ -29,7 +32,7 @@ class SmbHandler : public ::settings::SettingsPageUIHandler { ...@@ -29,7 +32,7 @@ class SmbHandler : public ::settings::SettingsPageUIHandler {
void HandleSmbMount(const base::ListValue* args); void HandleSmbMount(const base::ListValue* args);
// Callback handler for SmbMount. // Callback handler for SmbMount.
void HandleSmbMountResponse(base::File::Error error); void HandleSmbMountResponse(SmbMountResult result);
Profile* const profile_; Profile* const profile_;
base::WeakPtrFactory<SmbHandler> weak_ptr_factory_; 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