Commit 7a882550 authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Refactor SMB mount logic into SmbService::MountInternal()

This allows common code to be factored out, and eventually allow the
same mount function to be used for re-mounting on login and mounting
policy pre-configured shares.

Bug: 939235
Change-Id: Id4c5bd518f505ccf33345325b8a9ada4198fc5eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2032467Reviewed-by: default avatarAustin Tankiang <austinct@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738108}
parent aa22abc9
...@@ -63,7 +63,6 @@ class SmbService : public KeyedService, ...@@ -63,7 +63,6 @@ class SmbService : public KeyedService,
// Starts the process of mounting an SMB file system. // Starts the process of mounting an SMB file system.
// |use_kerberos| indicates whether the share should be mounted with a user's // |use_kerberos| indicates whether the share should be mounted with a user's
// chromad kerberos tickets. // chromad kerberos tickets.
// Calls SmbProviderClient::Mount().
void Mount(const file_system_provider::MountOptions& options, void Mount(const file_system_provider::MountOptions& options,
const base::FilePath& share_path, const base::FilePath& share_path,
const std::string& username, const std::string& username,
...@@ -76,20 +75,6 @@ class SmbService : public KeyedService, ...@@ -76,20 +75,6 @@ class SmbService : public KeyedService,
// Unmounts the SmbFs share mounted at |mount_path|. // Unmounts the SmbFs share mounted at |mount_path|.
void UnmountSmbFs(const base::FilePath& mount_path); void UnmountSmbFs(const base::FilePath& mount_path);
// Completes the mounting of an SMB file system, passing |options| on to
// file_system_provider::Service::MountFileSystem(). Passes error status to
// callback.
void OnMountResponse(MountResponse callback,
const file_system_provider::MountOptions& options,
const base::FilePath& share_path,
bool is_kerberos_chromad,
bool should_open_file_manager_after_mount,
const std::string& username,
const std::string& workgroup,
bool save_credentials,
smbprovider::ErrorType error,
int32_t mount_id);
// Gathers the hosts in the network using |share_finder_| and gets the shares // Gathers the hosts in the network using |share_finder_| and gets the shares
// for each of the hosts found. |discovery_callback| is called as soon as host // for each of the hosts found. |discovery_callback| is called as soon as host
// discovery is complete. |shares_callback| may be called multiple times with // discovery is complete. |shares_callback| may be called multiple times with
...@@ -134,11 +119,43 @@ class SmbService : public KeyedService, ...@@ -134,11 +119,43 @@ class SmbService : public KeyedService,
private: private:
friend class SmbServiceTest; friend class SmbServiceTest;
using MountInternalCallback =
base::OnceCallback<void(SmbMountResult result,
const base::FilePath& mount_path)>;
// Callback passed to MountInternal().
void MountInternalDone(MountResponse callback,
bool should_open_file_manager_after_mount,
SmbMountResult result,
const base::FilePath& mount_path);
// Mounts an SMB share with url |share_url| using either smbprovider or smbfs
// based on feature flags.
// Calls SmbProviderClient::Mount() or start the smbfs mount process.
void MountInternal(const file_system_provider::MountOptions& options,
const SmbUrl& share_url,
const std::string& display_name,
const std::string& username,
const std::string& workgroup,
const std::string& password,
bool use_kerberos,
bool save_credentials,
MountInternalCallback callback);
// Handles the response from mounting an SMB share using smbprovider.
// Completes the mounting of an SMB file system, passing |options| on to
// file_system_provider::Service::MountFileSystem(). Passes error status to
// callback.
void OnProviderMountDone(MountInternalCallback callback,
const file_system_provider::MountOptions& options,
bool save_credentials,
smbprovider::ErrorType error,
int32_t mount_id);
// Handles the response from mounting an smbfs share. Passes |result| onto // Handles the response from mounting an smbfs share. Passes |result| onto
// |callback|. // |callback|.
void OnSmbfsMountDone(const std::string& smbfs_mount_id, void OnSmbfsMountDone(const std::string& smbfs_mount_id,
bool should_open_file_manager_after_mount, MountInternalCallback callback,
MountResponse callback,
SmbMountResult result); SmbMountResult result);
// Retrieves the mount_id for |file_system_info|. // Retrieves the mount_id for |file_system_info|.
...@@ -197,9 +214,6 @@ class SmbService : public KeyedService, ...@@ -197,9 +214,6 @@ class SmbService : public KeyedService,
// Handles the response from attempting to update Kerberos credentials. // Handles the response from attempting to update Kerberos credentials.
void OnUpdateKerberosCredentialsResponse(bool success); void OnUpdateKerberosCredentialsResponse(bool success);
// Fires |callback| with |result|.
void FireMountCallback(MountResponse callback, SmbMountResult result);
// Registers host locators for |share_finder_|. // Registers host locators for |share_finder_|.
void RegisterHostLocators(); void RegisterHostLocators();
...@@ -209,10 +223,6 @@ class SmbService : public KeyedService, ...@@ -209,10 +223,6 @@ class SmbService : public KeyedService,
// Set up NetBios host locator. // Set up NetBios host locator.
void SetUpNetBiosHostLocator(); void SetUpNetBiosHostLocator();
// Opens |file_system_id| in the File Manager. Must only be called on a
// mounted share.
void OpenFileManager(const std::string& file_system_id);
// Whether NetBios discovery should be used. Controlled via policy. // Whether NetBios discovery should be used. Controlled via policy.
bool IsNetBiosDiscoveryEnabled() const; bool IsNetBiosDiscoveryEnabled() const;
......
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