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