Commit 0a6c168d authored by hidehiko@chromium.org's avatar hidehiko@chromium.org

Replace mountType by volumeType on fileBrowserPrivate APIs.

This is API clean up. The mountType is being replaced by VolumeType. This CL
refactors private APIs about the flag.
Note that this is preparation to return Drive as a Volume.

BUG=279276
TEST=Ran unit_tests, browser_tests --gtest_filter="*FileSystemExtensionApiTest*:*FileManagerBrowserTest*:*FileBrowserPrivateApiTest*" and tested manually.
R=benwells@chromium.org, kinaba@chromium.org, satorux@chromium.org, yoshiki@chromium.org

Review URL: https://codereview.chromium.org/23658009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@221978 0039d316-1c4b-4281-b951-d872f2087c98
parent 4bea1afb
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/drive/drive_integration_service.h" #include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_system_interface.h" #include "chrome/browser/chromeos/drive/file_system_interface.h"
#include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
#include "chrome/browser/chromeos/file_manager/app_id.h" #include "chrome/browser/chromeos/file_manager/app_id.h"
#include "chrome/browser/chromeos/file_manager/desktop_notifications.h" #include "chrome/browser/chromeos/file_manager/desktop_notifications.h"
#include "chrome/browser/chromeos/file_manager/fileapi_util.h" #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
...@@ -209,6 +210,23 @@ bool IsGooglePhotosInstalled(Profile *profile) { ...@@ -209,6 +210,23 @@ bool IsGooglePhotosInstalled(Profile *profile) {
return false; return false;
} }
// This method is temporarily introduced to make a change step by step.
// After mounting logic is moved to VolumeManager, this should be removed.
std::string MountTypeToString(chromeos::MountType type) {
switch (type) {
case chromeos::MOUNT_TYPE_INVALID:
return "";
case chromeos::MOUNT_TYPE_DEVICE:
return util::VolumeTypeToStringEnum(VOLUME_TYPE_REMOVABLE_DISK_PARTITION);
case chromeos::MOUNT_TYPE_ARCHIVE:
return util::VolumeTypeToStringEnum(VOLUME_TYPE_MOUNTED_ARCHIVE_FILE);
case chromeos::MOUNT_TYPE_GOOGLE_DRIVE:
return util::VolumeTypeToStringEnum(VOLUME_TYPE_GOOGLE_DRIVE);
}
NOTREACHED();
return "";
}
} // namespace } // namespace
// Pass dummy value to JobInfo's constructor for make it default constructible. // Pass dummy value to JobInfo's constructor for make it default constructible.
...@@ -690,8 +708,7 @@ void EventRouter::DispatchMountEvent( ...@@ -690,8 +708,7 @@ void EventRouter::DispatchMountEvent(
event == DiskMountManager::MOUNTING ? "mount" : "unmount"); event == DiskMountManager::MOUNTING ? "mount" : "unmount");
mount_info_value->SetString("status", MountErrorToString(error_code)); mount_info_value->SetString("status", MountErrorToString(error_code));
mount_info_value->SetString( mount_info_value->SetString(
"mountType", "volumeType", MountTypeToString(mount_info.mount_type));
DiskMountManager::MountTypeToString(mount_info.mount_type));
// Add sourcePath to the event. // Add sourcePath to the event.
mount_info_value->SetString("sourcePath", mount_info.source_path); mount_info_value->SetString("sourcePath", mount_info.source_path);
......
...@@ -25,34 +25,16 @@ using content::BrowserThread; ...@@ -25,34 +25,16 @@ using content::BrowserThread;
namespace extensions { namespace extensions {
namespace { namespace {
// Returns string representaion of VolumeType.
std::string VolumeTypeToString(file_manager::VolumeType type) {
switch (type) {
case file_manager::VOLUME_TYPE_GOOGLE_DRIVE:
return "drive";
case file_manager::VOLUME_TYPE_DOWNLOADS_DIRECTORY:
// Return empty string here for backword compatibility.
// TODO(hidehiko): Fix this to return "downloads".
return "";
case file_manager::VOLUME_TYPE_REMOVABLE_DISK_PARTITION:
return "device";
case file_manager::VOLUME_TYPE_MOUNTED_ARCHIVE_FILE:
return "file";
}
NOTREACHED();
return "";
}
// Returns the Value of the |volume_info|. // Returns the Value of the |volume_info|.
base::Value* CreateValueFromVolumeInfo( base::Value* CreateValueFromVolumeInfo(
const file_manager::VolumeInfo& volume_info, const file_manager::VolumeInfo& volume_info,
Profile* profile, Profile* profile,
const std::string& extension_id) { const std::string& extension_id) {
base::DictionaryValue* result = new base::DictionaryValue; base::DictionaryValue* result = new base::DictionaryValue;
std::string mount_type = VolumeTypeToString(volume_info.type); std::string volume_type =
if (!mount_type.empty()) file_manager::util::VolumeTypeToStringEnum(volume_info.type);
result->SetString("mountType", mount_type); if (!volume_type.empty())
result->SetString("volumeType", volume_type);
if (!volume_info.source_path.empty()) if (!volume_info.source_path.empty())
result->SetString("sourcePath", volume_info.source_path.value()); result->SetString("sourcePath", volume_info.source_path.value());
...@@ -86,83 +68,64 @@ bool FileBrowserPrivateAddMountFunction::RunImpl() { ...@@ -86,83 +68,64 @@ bool FileBrowserPrivateAddMountFunction::RunImpl() {
} }
std::string file_url; std::string file_url;
if (!args_->GetString(0, &file_url)) { if (!args_->GetString(0, &file_url))
return false; return false;
}
std::string mount_type_str; std::string mount_type;
if (!args_->GetString(1, &mount_type_str)) { if (!args_->GetString(1, &mount_type))
return false; return false;
}
drive::util::Log(logging::LOG_INFO, drive::util::Log(logging::LOG_INFO,
"%s[%d] called. (source: '%s', type:'%s')", "%s[%d] called. (source: '%s', type:'%s')",
name().c_str(), name().c_str(),
request_id(), request_id(),
file_url.empty() ? "(none)" : file_url.c_str(), file_url.empty() ? "(none)" : file_url.c_str(),
mount_type_str.c_str()); mount_type.c_str());
set_log_on_completion(true); set_log_on_completion(true);
// Set default return source path to the empty string. if (mount_type == "drive") {
SetResult(new base::StringValue("")); // Dispatch fake 'mounted' event because JS code depends on it.
// TODO(hashimoto): Remove this redanduncy.
chromeos::MountType mount_type = file_manager::FileBrowserPrivateAPI::Get(profile_)->event_router()->
DiskMountManager::MountTypeFromString(mount_type_str); OnFileSystemMounted();
switch (mount_type) {
case chromeos::MOUNT_TYPE_INVALID: { // Pass back the drive mount point path as source path.
error_ = "Invalid mount type"; const std::string& drive_path =
SendResponse(false); drive::util::GetDriveMountPointPathAsString();
break; SetResult(new base::StringValue(drive_path));
} SendResponse(true);
case chromeos::MOUNT_TYPE_GOOGLE_DRIVE: { } else if (mount_type == "archive") {
// Dispatch fake 'mounted' event because JS code depends on it. const base::FilePath path = file_manager::util::GetLocalPathFromURL(
// TODO(hashimoto): Remove this redanduncy. render_view_host(), profile(), GURL(file_url));
file_manager::FileBrowserPrivateAPI::Get(profile_)->event_router()->
OnFileSystemMounted(); if (path.empty())
return false;
// Pass back the drive mount point path as source path.
const std::string& drive_path = const base::FilePath::StringType display_name = path.BaseName().value();
drive::util::GetDriveMountPointPathAsString();
SetResult(new base::StringValue(drive_path)); // Check if the source path is under Drive cache directory.
SendResponse(true); if (drive::util::IsUnderDriveMountPoint(path)) {
break; drive::FileSystemInterface* file_system =
} drive::util::GetFileSystemByProfile(profile());
default: { if (!file_system)
const base::FilePath path = file_manager::util::GetLocalPathFromURL( return false;
render_view_host(), profile(), GURL(file_url));
file_system->MarkCacheFileAsMounted(
if (path.empty()) { drive::util::ExtractDrivePath(path),
SendResponse(false); base::Bind(&FileBrowserPrivateAddMountFunction::OnMountedStateSet,
break; this, display_name));
} } else {
OnMountedStateSet(display_name, drive::FILE_ERROR_OK, path);
const base::FilePath::StringType display_name = path.BaseName().value();
// Check if the source path is under Drive cache directory.
if (drive::util::IsUnderDriveMountPoint(path)) {
drive::FileSystemInterface* file_system =
drive::util::GetFileSystemByProfile(profile());
if (!file_system) {
SendResponse(false);
break;
}
file_system->MarkCacheFileAsMounted(
drive::util::ExtractDrivePath(path),
base::Bind(&FileBrowserPrivateAddMountFunction::OnMountedStateSet,
this, mount_type_str, display_name));
} else {
OnMountedStateSet(mount_type_str, display_name,
drive::FILE_ERROR_OK, path);
}
break;
} }
} else {
error_ = "Invalid mount type";
return false;
} }
return true; return true;
} }
void FileBrowserPrivateAddMountFunction::OnMountedStateSet( void FileBrowserPrivateAddMountFunction::OnMountedStateSet(
const std::string& mount_type,
const base::FilePath::StringType& file_name, const base::FilePath::StringType& file_name,
drive::FileError error, drive::FileError error,
const base::FilePath& file_path) { const base::FilePath& file_path) {
...@@ -180,7 +143,7 @@ void FileBrowserPrivateAddMountFunction::OnMountedStateSet( ...@@ -180,7 +143,7 @@ void FileBrowserPrivateAddMountFunction::OnMountedStateSet(
// MountPath() takes a std::string. // MountPath() takes a std::string.
disk_mount_manager->MountPath( disk_mount_manager->MountPath(
file_path.AsUTF8Unsafe(), base::FilePath(file_name).Extension(), file_path.AsUTF8Unsafe(), base::FilePath(file_name).Extension(),
file_name, DiskMountManager::MountTypeFromString(mount_type)); file_name, chromeos::MOUNT_TYPE_ARCHIVE);
} }
FileBrowserPrivateRemoveMountFunction::FileBrowserPrivateRemoveMountFunction() { FileBrowserPrivateRemoveMountFunction::FileBrowserPrivateRemoveMountFunction() {
......
...@@ -37,8 +37,7 @@ class FileBrowserPrivateAddMountFunction : public LoggedAsyncExtensionFunction { ...@@ -37,8 +37,7 @@ class FileBrowserPrivateAddMountFunction : public LoggedAsyncExtensionFunction {
private: private:
// A callback method to handle the result of MarkCacheAsMounted. // A callback method to handle the result of MarkCacheAsMounted.
void OnMountedStateSet(const std::string& mount_type, void OnMountedStateSet(const base::FilePath::StringType& file_name,
const base::FilePath::StringType& file_name,
drive::FileError error, drive::FileError error,
const base::FilePath& file_path); const base::FilePath& file_path);
}; };
......
...@@ -118,6 +118,23 @@ void ContinueGetSelectedFileInfo(Profile* profile, ...@@ -118,6 +118,23 @@ void ContinueGetSelectedFileInfo(Profile* profile,
} // namespace } // namespace
// Returns string representaion of VolumeType.
std::string VolumeTypeToStringEnum(VolumeType type) {
switch (type) {
case VOLUME_TYPE_GOOGLE_DRIVE:
return "drive";
case VOLUME_TYPE_DOWNLOADS_DIRECTORY:
return "downloads";
case VOLUME_TYPE_REMOVABLE_DISK_PARTITION:
return "removable";
case VOLUME_TYPE_MOUNTED_ARCHIVE_FILE:
return "archive";
}
NOTREACHED();
return "";
}
int32 GetTabId(ExtensionFunctionDispatcher* dispatcher) { int32 GetTabId(ExtensionFunctionDispatcher* dispatcher) {
if (!dispatcher) { if (!dispatcher) {
LOG(WARNING) << "No dispatcher"; LOG(WARNING) << "No dispatcher";
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_ #define CHROME_BROWSER_CHROMEOS_EXTENSIONS_FILE_MANAGER_PRIVATE_API_UTIL_H_
#include "base/callback_forward.h" #include "base/callback_forward.h"
#include "chrome/browser/chromeos/file_manager/volume_manager.h"
#include "chrome/browser/google_apis/gdata_wapi_parser.h" #include "chrome/browser/google_apis/gdata_wapi_parser.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -25,6 +26,9 @@ struct SelectedFileInfo; ...@@ -25,6 +26,9 @@ struct SelectedFileInfo;
namespace file_manager { namespace file_manager {
namespace util { namespace util {
// Converts VolumeType to a string enum (volumeType) used in the private API.
std::string VolumeTypeToStringEnum(VolumeType type);
// Returns the ID of the tab associated with the dispatcher. Returns 0 on // Returns the ID of the tab associated with the dispatcher. Returns 0 on
// error. // error.
int32 GetTabId(ExtensionFunctionDispatcher* dispatcher); int32 GetTabId(ExtensionFunctionDispatcher* dispatcher);
......
...@@ -514,7 +514,7 @@ VolumeManager.prototype.initMountPoints_ = function() { ...@@ -514,7 +514,7 @@ VolumeManager.prototype.initMountPoints_ = function() {
var mountPoint = mountPointList[i]; var mountPoint = mountPointList[i];
// TODO(hidehiko): It should be ok that the drive is mounted already. // TODO(hidehiko): It should be ok that the drive is mounted already.
if (mountPoint.mountType == 'drive') if (mountPoint.volumeType == 'drive')
console.error('Drive is not expected initially mounted'); console.error('Drive is not expected initially mounted');
var error = mountPoint.mountCondition ? var error = mountPoint.mountCondition ?
...@@ -562,7 +562,7 @@ VolumeManager.prototype.onMountCompleted_ = function(event) { ...@@ -562,7 +562,7 @@ VolumeManager.prototype.onMountCompleted_ = function(event) {
if (event.eventType == 'mount') { if (event.eventType == 'mount') {
if (event.mountPath) { if (event.mountPath) {
var requestKey = this.makeRequestKey_( var requestKey = this.makeRequestKey_(
'mount', event.mountType, event.sourcePath); 'mount', event.volumeType, event.sourcePath);
var error = event.status == 'success' ? '' : event.status; var error = event.status == 'success' ? '' : event.status;
volumeManagerUtil.createVolumeInfo( volumeManagerUtil.createVolumeInfo(
event.mountPath, error, function(volume) { event.mountPath, error, function(volume) {
...@@ -599,7 +599,7 @@ VolumeManager.prototype.onMountCompleted_ = function(event) { ...@@ -599,7 +599,7 @@ VolumeManager.prototype.onMountCompleted_ = function(event) {
} }
} }
if (event.mountType == 'drive') { if (event.volumeType == 'drive') {
if (event.status == 'success') { if (event.status == 'success') {
if (event.eventType == 'mount') { if (event.eventType == 'mount') {
// If the mount is not requested, the mount status will not be changed // If the mount is not requested, the mount status will not be changed
...@@ -657,16 +657,16 @@ VolumeManager.prototype.waitDriveLoaded_ = function(mountPath, callback) { ...@@ -657,16 +657,16 @@ VolumeManager.prototype.waitDriveLoaded_ = function(mountPath, callback) {
/** /**
* Creates string to match mount events with requests. * Creates string to match mount events with requests.
* @param {string} requestType 'mount' | 'unmount'. * @param {string} requestType 'mount' | 'unmount'.
* @param {string} mountType 'device' | 'file' | 'network' | 'drive'. * @param {string} volumeType 'drive' | 'downloads' | 'removable' | 'archive'.
* @param {string} mountOrSourcePath Source path provided by API after * @param {string} mountOrSourcePath Source path provided by API after
* resolving mount request or mountPath for unmount request. * resolving mount request or mountPath for unmount request.
* @return {string} Key for |this.requests_|. * @return {string} Key for |this.requests_|.
* @private * @private
*/ */
VolumeManager.prototype.makeRequestKey_ = function(requestType, VolumeManager.prototype.makeRequestKey_ = function(requestType,
mountType, volumeType,
mountOrSourcePath) { mountOrSourcePath) {
return requestType + ':' + mountType + ':' + mountOrSourcePath; return requestType + ':' + volumeType + ':' + mountOrSourcePath;
}; };
...@@ -702,7 +702,7 @@ VolumeManager.prototype.mountDrive = function(successCallback, errorCallback) { ...@@ -702,7 +702,7 @@ VolumeManager.prototype.mountDrive = function(successCallback, errorCallback) {
*/ */
VolumeManager.prototype.mountArchive = function(fileUrl, successCallback, VolumeManager.prototype.mountArchive = function(fileUrl, successCallback,
errorCallback) { errorCallback) {
this.mount_(fileUrl, 'file', successCallback, errorCallback); this.mount_(fileUrl, 'archive', successCallback, errorCallback);
}; };
/** /**
...@@ -743,25 +743,25 @@ VolumeManager.prototype.getVolumeInfo = function(mountPath) { ...@@ -743,25 +743,25 @@ VolumeManager.prototype.getVolumeInfo = function(mountPath) {
/** /**
* @param {string} url URL for for |fileBrowserPrivate.addMount|. * @param {string} url URL for for |fileBrowserPrivate.addMount|.
* @param {'drive'|'file'} mountType Mount type for * @param {'drive'|'archive'} volumeType Volume type for
* |fileBrowserPrivate.addMount|. * |fileBrowserPrivate.addMount|.
* @param {function(string)} successCallback Success callback. * @param {function(string)} successCallback Success callback.
* @param {function(VolumeManager.Error)} errorCallback Error callback. * @param {function(VolumeManager.Error)} errorCallback Error callback.
* @private * @private
*/ */
VolumeManager.prototype.mount_ = function(url, mountType, VolumeManager.prototype.mount_ = function(url, volumeType,
successCallback, errorCallback) { successCallback, errorCallback) {
if (this.deferredQueue_) { if (this.deferredQueue_) {
this.deferredQueue_.push(this.mount_.bind(this, this.deferredQueue_.push(this.mount_.bind(this,
url, mountType, successCallback, errorCallback)); url, volumeType, successCallback, errorCallback));
return; return;
} }
chrome.fileBrowserPrivate.addMount(url, mountType, {}, chrome.fileBrowserPrivate.addMount(url, volumeType, {},
function(sourcePath) { function(sourcePath) {
console.info('Mount request: url=' + url + '; mountType=' + mountType + console.info('Mount request: url=' + url + '; volumeType=' + volumeType +
'; sourceUrl=' + sourcePath); '; sourceUrl=' + sourcePath);
var requestKey = this.makeRequestKey_('mount', mountType, sourcePath); var requestKey = this.makeRequestKey_('mount', volumeType, sourcePath);
this.startRequest_(requestKey, successCallback, errorCallback); this.startRequest_(requestKey, successCallback, errorCallback);
}.bind(this)); }.bind(this));
}; };
......
...@@ -128,11 +128,11 @@ ...@@ -128,11 +128,11 @@
"optional": true, "optional": true,
"description": "The path to the mounted device, archive file or network resource." "description": "The path to the mounted device, archive file or network resource."
}, },
"mountType": { "volumeType": {
"type": "string", "type": "string",
"optional": true, "optional": true,
"enum": ["device", "file", "network"], "enum": ["drive", "downloads", "removable", "archive"],
"description": "Type of the mount." "description": "Type of the mounted volume."
}, },
"mountCondition": { "mountCondition": {
"type": "string", "type": "string",
...@@ -272,10 +272,10 @@ ...@@ -272,10 +272,10 @@
"optional": true, "optional": true,
"description": "Path that sourcePath was mounted to." "description": "Path that sourcePath was mounted to."
}, },
"mountType": { "volumeType": {
"type": "string", "type": "string",
"enum": ["device", "file", "network", "drive"], "enum": ["drive", "downloads", "removable", "archive"],
"description": "Type of the mount." "description": "Type of the mounted volume."
} }
} }
}, },
...@@ -731,11 +731,13 @@ ...@@ -731,11 +731,13 @@
"type": "string", "type": "string",
"description": "Mount point source. For compressed files it is relative file path within external file system" "description": "Mount point source. For compressed files it is relative file path within external file system"
}, },
// TODO(hidehiko): After the refactoring, we won't need to request
// mounting the Drive. Then remove this param.
{ {
"name": "mountType", "name": "volumeType",
"type": "string", "type": "string",
"enum": ["device", "file", "network", "drive"], "enum": ["drive", "archive"],
"description": "Mount point type. 'file' for compressed files" "description": "Type of the mounted volume"
}, },
{ {
"name": "options", "name": "options",
......
...@@ -59,30 +59,31 @@ var expectedDownloadsVolume = { ...@@ -59,30 +59,31 @@ var expectedDownloadsVolume = {
var expectedMountPoints = [ var expectedMountPoints = [
{ {
mountPath: 'Downloads', mountPath: 'Downloads',
volumeType: 'downloads',
mountCondition: '' mountCondition: ''
}, },
{ {
sourcePath: 'archive_path', sourcePath: 'archive_path',
mountPath: 'archive/archive_mount_path', mountPath: 'archive/archive_mount_path',
mountType: 'file', volumeType: 'archive',
mountCondition: '' mountCondition: ''
}, },
{ {
sourcePath: 'device_path1', sourcePath: 'device_path1',
mountPath: 'removable/mount_path1', mountPath: 'removable/mount_path1',
mountType: 'device', volumeType: 'removable',
mountCondition: '' mountCondition: ''
}, },
{ {
sourcePath: 'device_path2', sourcePath: 'device_path2',
mountPath: 'removable/mount_path2', mountPath: 'removable/mount_path2',
mountType: 'device', volumeType: 'removable',
mountCondition: '' mountCondition: ''
}, },
{ {
sourcePath: 'device_path3', sourcePath: 'device_path3',
mountPath: 'removable/mount_path3', mountPath: 'removable/mount_path3',
mountType: 'device', volumeType: 'removable',
mountCondition: '' mountCondition: ''
} }
]; ];
......
...@@ -33,8 +33,9 @@ enum MountType { ...@@ -33,8 +33,9 @@ enum MountType {
MOUNT_TYPE_INVALID, MOUNT_TYPE_INVALID,
MOUNT_TYPE_DEVICE, MOUNT_TYPE_DEVICE,
MOUNT_TYPE_ARCHIVE, MOUNT_TYPE_ARCHIVE,
// TODO(hidehiko): Drive is not managed by DiskMountManager nor
// CrosDisksClient. Remove this after fileBrowserPrivate API is cleaned.
MOUNT_TYPE_GOOGLE_DRIVE, MOUNT_TYPE_GOOGLE_DRIVE,
MOUNT_TYPE_NETWORK_STORAGE,
}; };
// Type of device. // Type of device.
......
...@@ -669,25 +669,6 @@ bool DiskMountManager::AddMountPointForTest(const MountPointInfo& mount_point) { ...@@ -669,25 +669,6 @@ bool DiskMountManager::AddMountPointForTest(const MountPointInfo& mount_point) {
return false; return false;
} }
// static
std::string DiskMountManager::MountTypeToString(MountType type) {
switch (type) {
case MOUNT_TYPE_DEVICE:
return "device";
case MOUNT_TYPE_ARCHIVE:
return "file";
case MOUNT_TYPE_NETWORK_STORAGE:
return "network";
case MOUNT_TYPE_GOOGLE_DRIVE:
return "drive";
case MOUNT_TYPE_INVALID:
return "invalid";
default:
NOTREACHED();
}
return "";
}
// static // static
std::string DiskMountManager::MountConditionToString(MountCondition condition) { std::string DiskMountManager::MountConditionToString(MountCondition condition) {
switch (condition) { switch (condition) {
...@@ -703,20 +684,6 @@ std::string DiskMountManager::MountConditionToString(MountCondition condition) { ...@@ -703,20 +684,6 @@ std::string DiskMountManager::MountConditionToString(MountCondition condition) {
return ""; return "";
} }
// static
MountType DiskMountManager::MountTypeFromString(const std::string& type_str) {
if (type_str == "device")
return MOUNT_TYPE_DEVICE;
else if (type_str == "network")
return MOUNT_TYPE_NETWORK_STORAGE;
else if (type_str == "file")
return MOUNT_TYPE_ARCHIVE;
else if (type_str == "drive")
return MOUNT_TYPE_GOOGLE_DRIVE;
else
return MOUNT_TYPE_INVALID;
}
// static // static
std::string DiskMountManager::DeviceTypeToString(DeviceType type) { std::string DiskMountManager::DeviceTypeToString(DeviceType type) {
switch (type) { switch (type) {
......
...@@ -272,12 +272,6 @@ class CHROMEOS_EXPORT DiskMountManager { ...@@ -272,12 +272,6 @@ class CHROMEOS_EXPORT DiskMountManager {
virtual bool AddDiskForTest(Disk* disk); virtual bool AddDiskForTest(Disk* disk);
virtual bool AddMountPointForTest(const MountPointInfo& mount_point); virtual bool AddMountPointForTest(const MountPointInfo& mount_point);
// Returns corresponding string to |type| like "device" or "file".
static std::string MountTypeToString(MountType type);
// The inverse function of MountTypeToString.
static MountType MountTypeFromString(const std::string& type_str);
// Returns corresponding string to |type| like "unknown_filesystem". // Returns corresponding string to |type| like "unknown_filesystem".
static std::string MountConditionToString(MountCondition type); static std::string MountConditionToString(MountCondition type);
......
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