Commit f27ebb8c authored by hirono@chromium.org's avatar hirono@chromium.org

Files.app: Let the file browser private filesystem APIs use the auto-generated helper classes.

Originally, the file browser private filesystem APIs parse the arguments and generate the results manually. This CL lets the APIs use the auto generated helper
classes to parse the arguments.

BUG=241693
TEST=file_manager_browsertests

Review URL: https://chromiumcodereview.appspot.com/23766029

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@223534 0039d316-1c4b-4281-b951-d872f2087c98
parent 1a9921e9
......@@ -297,14 +297,6 @@ void CancelCopyOnIOThread(
} // namespace
FileBrowserPrivateRequestFileSystemFunction::
FileBrowserPrivateRequestFileSystemFunction() {
}
FileBrowserPrivateRequestFileSystemFunction::
~FileBrowserPrivateRequestFileSystemFunction() {
}
void FileBrowserPrivateRequestFileSystemFunction::DidOpenFileSystem(
scoped_refptr<fileapi::FileSystemContext> file_system_context,
base::PlatformFileError result,
......@@ -423,12 +415,6 @@ bool FileBrowserPrivateRequestFileSystemFunction::RunImpl() {
return true;
}
FileWatchFunctionBase::FileWatchFunctionBase() {
}
FileWatchFunctionBase::~FileWatchFunctionBase() {
}
void FileWatchFunctionBase::Respond(bool success) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......@@ -463,14 +449,6 @@ bool FileWatchFunctionBase::RunImpl() {
return true;
}
FileBrowserPrivateAddFileWatchFunction::
FileBrowserPrivateAddFileWatchFunction() {
}
FileBrowserPrivateAddFileWatchFunction::
~FileBrowserPrivateAddFileWatchFunction() {
}
void FileBrowserPrivateAddFileWatchFunction::PerformFileWatchOperation(
const base::FilePath& local_path,
const base::FilePath& virtual_path,
......@@ -486,14 +464,6 @@ void FileBrowserPrivateAddFileWatchFunction::PerformFileWatchOperation(
base::Bind(&FileBrowserPrivateAddFileWatchFunction::Respond, this));
}
FileBrowserPrivateRemoveFileWatchFunction::
FileBrowserPrivateRemoveFileWatchFunction() {
}
FileBrowserPrivateRemoveFileWatchFunction::
~FileBrowserPrivateRemoveFileWatchFunction() {
}
void FileBrowserPrivateRemoveFileWatchFunction::PerformFileWatchOperation(
const base::FilePath& local_path,
const base::FilePath& unused,
......@@ -506,62 +476,33 @@ void FileBrowserPrivateRemoveFileWatchFunction::PerformFileWatchOperation(
Respond(true);
}
FileBrowserPrivateSetLastModifiedFunction::
FileBrowserPrivateSetLastModifiedFunction() {
}
FileBrowserPrivateSetLastModifiedFunction::
~FileBrowserPrivateSetLastModifiedFunction() {
}
bool FileBrowserPrivateSetLastModifiedFunction::RunImpl() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (args_->GetSize() != 2) {
return false;
}
std::string file_url;
if (!args_->GetString(0, &file_url))
return false;
std::string timestamp;
if (!args_->GetString(1, &timestamp))
return false;
using extensions::api::file_browser_private::SetLastModified::Params;
const scoped_ptr<Params> params(Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
base::FilePath local_path = file_manager::util::GetLocalPathFromURL(
render_view_host(), profile(), GURL(file_url));
render_view_host(), profile(), GURL(params->file_url));
base::PostTaskAndReplyWithResult(
BrowserThread::GetBlockingPool(),
FROM_HERE,
base::Bind(&SetLastModifiedOnBlockingPool,
local_path,
strtoul(timestamp.c_str(), NULL, 0)),
strtoul(params->last_modified.c_str(), NULL, 0)),
base::Bind(&FileBrowserPrivateSetLastModifiedFunction::SendResponse,
this));
return true;
}
FileBrowserPrivateGetSizeStatsFunction::
FileBrowserPrivateGetSizeStatsFunction() {
}
FileBrowserPrivateGetSizeStatsFunction::
~FileBrowserPrivateGetSizeStatsFunction() {
}
bool FileBrowserPrivateGetSizeStatsFunction::RunImpl() {
if (args_->GetSize() != 1) {
return false;
}
std::string mount_url;
if (!args_->GetString(0, &mount_url))
return false;
using extensions::api::file_browser_private::GetSizeStats::Params;
const scoped_ptr<Params> params(Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
base::FilePath file_path = file_manager::util::GetLocalPathFromURL(
render_view_host(), profile(), GURL(mount_url));
render_view_host(), profile(), GURL(params->mount_path));
if (file_path.empty())
return false;
......@@ -625,28 +566,13 @@ void FileBrowserPrivateGetSizeStatsFunction::GetSizeStatsCallback(
SendResponse(true);
}
FileBrowserPrivateGetVolumeMetadataFunction::
FileBrowserPrivateGetVolumeMetadataFunction() {
}
FileBrowserPrivateGetVolumeMetadataFunction::
~FileBrowserPrivateGetVolumeMetadataFunction() {
}
bool FileBrowserPrivateGetVolumeMetadataFunction::RunImpl() {
if (args_->GetSize() != 1) {
error_ = "Invalid argument count";
return false;
}
std::string volume_mount_url;
if (!args_->GetString(0, &volume_mount_url)) {
NOTREACHED();
return false;
}
using extensions::api::file_browser_private::GetVolumeMetadata::Params;
const scoped_ptr<Params> params(Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
base::FilePath file_path = file_manager::util::GetLocalPathFromURL(
render_view_host(), profile(), GURL(volume_mount_url));
render_view_host(), profile(), GURL(params->mount_url));
if (file_path.empty()) {
error_ = "Invalid mount path.";
return false;
......@@ -670,29 +596,17 @@ bool FileBrowserPrivateGetVolumeMetadataFunction::RunImpl() {
return true;
}
FileBrowserPrivateValidatePathNameLengthFunction::
FileBrowserPrivateValidatePathNameLengthFunction() {
}
FileBrowserPrivateValidatePathNameLengthFunction::
~FileBrowserPrivateValidatePathNameLengthFunction() {
}
bool FileBrowserPrivateValidatePathNameLengthFunction::RunImpl() {
std::string parent_url;
if (!args_->GetString(0, &parent_url))
return false;
std::string name;
if (!args_->GetString(1, &name))
return false;
using extensions::api::file_browser_private::ValidatePathNameLength::Params;
const scoped_ptr<Params> params(Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
scoped_refptr<fileapi::FileSystemContext> file_system_context =
file_manager::util::GetFileSystemContextForRenderViewHost(
profile(), render_view_host());
fileapi::FileSystemURL filesystem_url(
file_system_context->CrackURL(GURL(parent_url)));
file_system_context->CrackURL(GURL(params->parent_directory_url)));
if (!chromeos::FileSystemBackend::CanHandleURL(filesystem_url))
return false;
......@@ -710,7 +624,7 @@ bool FileBrowserPrivateValidatePathNameLengthFunction::RunImpl() {
filesystem_url.path().AsUTF8Unsafe()),
base::Bind(&FileBrowserPrivateValidatePathNameLengthFunction::
OnFilePathLimitRetrieved,
this, name.size()));
this, params->name.size()));
return true;
}
......@@ -721,27 +635,13 @@ void FileBrowserPrivateValidatePathNameLengthFunction::OnFilePathLimitRetrieved(
SendResponse(true);
}
FileBrowserPrivateFormatDeviceFunction::
FileBrowserPrivateFormatDeviceFunction() {
}
FileBrowserPrivateFormatDeviceFunction::
~FileBrowserPrivateFormatDeviceFunction() {
}
bool FileBrowserPrivateFormatDeviceFunction::RunImpl() {
if (args_->GetSize() != 1) {
return false;
}
std::string volume_file_url;
if (!args_->GetString(0, &volume_file_url)) {
NOTREACHED();
return false;
}
using extensions::api::file_browser_private::FormatDevice::Params;
const scoped_ptr<Params> params(Params::Create(*args_));
EXTENSION_FUNCTION_VALIDATE(params);
base::FilePath file_path = file_manager::util::GetLocalPathFromURL(
render_view_host(), profile(), GURL(volume_file_url));
render_view_host(), profile(), GURL(params->mount_path));
if (file_path.empty())
return false;
......@@ -750,12 +650,6 @@ bool FileBrowserPrivateFormatDeviceFunction::RunImpl() {
return true;
}
FileBrowserPrivateStartCopyFunction::FileBrowserPrivateStartCopyFunction() {
}
FileBrowserPrivateStartCopyFunction::~FileBrowserPrivateStartCopyFunction() {
}
bool FileBrowserPrivateStartCopyFunction::RunImpl() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......@@ -802,12 +696,6 @@ void FileBrowserPrivateStartCopyFunction::RunAfterStartCopy(
SendResponse(true);
}
FileBrowserPrivateCancelCopyFunction::FileBrowserPrivateCancelCopyFunction() {
}
FileBrowserPrivateCancelCopyFunction::~FileBrowserPrivateCancelCopyFunction() {
}
bool FileBrowserPrivateCancelCopyFunction::RunImpl() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
......
......@@ -32,10 +32,8 @@ class FileBrowserPrivateRequestFileSystemFunction
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.requestFileSystem",
FILEBROWSERPRIVATE_REQUESTFILESYSTEM)
FileBrowserPrivateRequestFileSystemFunction();
protected:
virtual ~FileBrowserPrivateRequestFileSystemFunction();
virtual ~FileBrowserPrivateRequestFileSystemFunction() {}
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
......@@ -69,11 +67,8 @@ class FileBrowserPrivateRequestFileSystemFunction
// the class and its sub classes are used only for watching changes in
// directories.
class FileWatchFunctionBase : public LoggedAsyncExtensionFunction {
public:
FileWatchFunctionBase();
protected:
virtual ~FileWatchFunctionBase();
virtual ~FileWatchFunctionBase() {}
// Performs a file watch operation (ex. adds or removes a file watch).
virtual void PerformFileWatchOperation(
......@@ -95,10 +90,8 @@ class FileBrowserPrivateAddFileWatchFunction : public FileWatchFunctionBase {
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.addFileWatch",
FILEBROWSERPRIVATE_ADDFILEWATCH)
FileBrowserPrivateAddFileWatchFunction();
protected:
virtual ~FileBrowserPrivateAddFileWatchFunction();
virtual ~FileBrowserPrivateAddFileWatchFunction() {}
// FileWatchFunctionBase override.
virtual void PerformFileWatchOperation(
......@@ -115,10 +108,8 @@ class FileBrowserPrivateRemoveFileWatchFunction : public FileWatchFunctionBase {
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.removeFileWatch",
FILEBROWSERPRIVATE_REMOVEFILEWATCH)
FileBrowserPrivateRemoveFileWatchFunction();
protected:
virtual ~FileBrowserPrivateRemoveFileWatchFunction();
virtual ~FileBrowserPrivateRemoveFileWatchFunction() {}
// FileWatchFunctionBase override.
virtual void PerformFileWatchOperation(
......@@ -135,10 +126,8 @@ class FileBrowserPrivateSetLastModifiedFunction
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.setLastModified",
FILEBROWSERPRIVATE_SETLASTMODIFIED)
FileBrowserPrivateSetLastModifiedFunction();
protected:
virtual ~FileBrowserPrivateSetLastModifiedFunction();
virtual ~FileBrowserPrivateSetLastModifiedFunction() {}
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
......@@ -151,10 +140,8 @@ class FileBrowserPrivateGetSizeStatsFunction
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getSizeStats",
FILEBROWSERPRIVATE_GETSIZESTATS)
FileBrowserPrivateGetSizeStatsFunction();
protected:
virtual ~FileBrowserPrivateGetSizeStatsFunction();
virtual ~FileBrowserPrivateGetSizeStatsFunction() {}
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
......@@ -176,10 +163,8 @@ class FileBrowserPrivateGetVolumeMetadataFunction
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.getVolumeMetadata",
FILEBROWSERPRIVATE_GETVOLUMEMETADATA)
FileBrowserPrivateGetVolumeMetadataFunction();
protected:
virtual ~FileBrowserPrivateGetVolumeMetadataFunction();
virtual ~FileBrowserPrivateGetVolumeMetadataFunction() {}
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
......@@ -192,10 +177,8 @@ class FileBrowserPrivateValidatePathNameLengthFunction
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.validatePathNameLength",
FILEBROWSERPRIVATE_VALIDATEPATHNAMELENGTH)
FileBrowserPrivateValidatePathNameLengthFunction();
protected:
virtual ~FileBrowserPrivateValidatePathNameLengthFunction();
virtual ~FileBrowserPrivateValidatePathNameLengthFunction() {}
void OnFilePathLimitRetrieved(size_t current_length, size_t max_length);
......@@ -211,10 +194,8 @@ class FileBrowserPrivateFormatDeviceFunction
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.formatDevice",
FILEBROWSERPRIVATE_FORMATDEVICE)
FileBrowserPrivateFormatDeviceFunction();
protected:
virtual ~FileBrowserPrivateFormatDeviceFunction();
virtual ~FileBrowserPrivateFormatDeviceFunction() {}
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
......@@ -227,10 +208,8 @@ class FileBrowserPrivateStartCopyFunction
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.startCopy",
FILEBROWSERPRIVATE_STARTCOPY)
FileBrowserPrivateStartCopyFunction();
protected:
virtual ~FileBrowserPrivateStartCopyFunction();
virtual ~FileBrowserPrivateStartCopyFunction() {}
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
......@@ -247,10 +226,8 @@ class FileBrowserPrivateCancelCopyFunction
DECLARE_EXTENSION_FUNCTION("fileBrowserPrivate.cancelCopy",
FILEBROWSERPRIVATE_CANCELCOPY)
FileBrowserPrivateCancelCopyFunction();
protected:
virtual ~FileBrowserPrivateCancelCopyFunction();
virtual ~FileBrowserPrivateCancelCopyFunction() {}
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
......
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