Commit 76efdcf8 authored by Anand K. Mistry's avatar Anand K. Mistry Committed by Commit Bot

Migrate file_system file manager APIs to UIThreadExtensionFunction.

BUG=934541

Change-Id: Ibd06bda730bd10c270d187d83f68315159fa6a43
Reviewed-on: https://chromium-review.googlesource.com/c/1482172Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Anand Mistry <amistry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634562}
parent e1cf0f63
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h" #include "chrome/browser/chromeos/extensions/file_manager/private_api_base.h"
#include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/browser/extensions/chrome_extension_function_details.h" #include "chrome/browser/extensions/chrome_extension_function_details.h"
#include "components/drive/file_errors.h" #include "components/drive/file_errors.h"
#include "extensions/browser/extension_function.h" #include "extensions/browser/extension_function.h"
...@@ -87,12 +86,12 @@ class FileManagerPrivateGrantAccessFunction : public UIThreadExtensionFunction { ...@@ -87,12 +86,12 @@ class FileManagerPrivateGrantAccessFunction : public UIThreadExtensionFunction {
// "FileWatch", // "FileWatch",
// 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 LoggedUIThreadExtensionFunction {
public: public:
using ResponseCallback = base::Callback<void(bool success)>; using ResponseCallback = base::Callback<void(bool success)>;
// Calls SendResponse() with |success| converted to base::Value. // Calls Respond() with |success| converted to base::Value.
void Respond(bool success); void RespondWith(bool success);
protected: protected:
~FileWatchFunctionBase() override = default; ~FileWatchFunctionBase() override = default;
...@@ -112,8 +111,8 @@ class FileWatchFunctionBase : public LoggedAsyncExtensionFunction { ...@@ -112,8 +111,8 @@ class FileWatchFunctionBase : public LoggedAsyncExtensionFunction {
const storage::FileSystemURL& file_system_url, const storage::FileSystemURL& file_system_url,
base::WeakPtr<file_manager::EventRouter> event_router) = 0; base::WeakPtr<file_manager::EventRouter> event_router) = 0;
// ChromeAsyncExtensionFunction overrides. // ExtensionFunction overrides.
bool RunAsync() override; ResponseAction Run() override;
private: private:
void RunAsyncOnIOThread( void RunAsyncOnIOThread(
...@@ -169,7 +168,7 @@ class FileManagerPrivateInternalRemoveFileWatchFunction ...@@ -169,7 +168,7 @@ class FileManagerPrivateInternalRemoveFileWatchFunction
// Implements the chrome.fileManagerPrivate.getSizeStats method. // Implements the chrome.fileManagerPrivate.getSizeStats method.
class FileManagerPrivateGetSizeStatsFunction class FileManagerPrivateGetSizeStatsFunction
: public LoggedAsyncExtensionFunction { : public LoggedUIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getSizeStats", DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.getSizeStats",
FILEMANAGERPRIVATE_GETSIZESTATS) FILEMANAGERPRIVATE_GETSIZESTATS)
...@@ -177,8 +176,8 @@ class FileManagerPrivateGetSizeStatsFunction ...@@ -177,8 +176,8 @@ class FileManagerPrivateGetSizeStatsFunction
protected: protected:
~FileManagerPrivateGetSizeStatsFunction() override = default; ~FileManagerPrivateGetSizeStatsFunction() override = default;
// ChromeAsyncExtensionFunction overrides. // ExtensionFunction overrides.
bool RunAsync() override; ResponseAction Run() override;
private: private:
void OnGetDriveAvailableSpace(drive::FileError error, void OnGetDriveAvailableSpace(drive::FileError error,
...@@ -194,7 +193,7 @@ class FileManagerPrivateGetSizeStatsFunction ...@@ -194,7 +193,7 @@ class FileManagerPrivateGetSizeStatsFunction
// Implements the chrome.fileManagerPrivate.validatePathNameLength method. // Implements the chrome.fileManagerPrivate.validatePathNameLength method.
class FileManagerPrivateInternalValidatePathNameLengthFunction class FileManagerPrivateInternalValidatePathNameLengthFunction
: public LoggedAsyncExtensionFunction { : public LoggedUIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION( DECLARE_EXTENSION_FUNCTION(
"fileManagerPrivateInternal.validatePathNameLength", "fileManagerPrivateInternal.validatePathNameLength",
...@@ -206,14 +205,14 @@ class FileManagerPrivateInternalValidatePathNameLengthFunction ...@@ -206,14 +205,14 @@ class FileManagerPrivateInternalValidatePathNameLengthFunction
void OnFilePathLimitRetrieved(size_t current_length, size_t max_length); void OnFilePathLimitRetrieved(size_t current_length, size_t max_length);
// ChromeAsyncExtensionFunction overrides. // ExtensionFunction overrides.
bool RunAsync() override; ResponseAction Run() override;
}; };
// Implements the chrome.fileManagerPrivate.formatVolume method. // Implements the chrome.fileManagerPrivate.formatVolume method.
// Formats Volume given its mount path. // Formats Volume given its mount path.
class FileManagerPrivateFormatVolumeFunction class FileManagerPrivateFormatVolumeFunction
: public LoggedAsyncExtensionFunction { : public LoggedUIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.formatVolume", DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.formatVolume",
FILEMANAGERPRIVATE_FORMATVOLUME) FILEMANAGERPRIVATE_FORMATVOLUME)
...@@ -221,14 +220,14 @@ class FileManagerPrivateFormatVolumeFunction ...@@ -221,14 +220,14 @@ class FileManagerPrivateFormatVolumeFunction
protected: protected:
~FileManagerPrivateFormatVolumeFunction() override = default; ~FileManagerPrivateFormatVolumeFunction() override = default;
// ChromeAsyncExtensionFunction overrides. // ExtensionFunction overrides.
bool RunAsync() override; ResponseAction Run() override;
}; };
// Implements the chrome.fileManagerPrivate.renameVolume method. // Implements the chrome.fileManagerPrivate.renameVolume method.
// Renames Volume given its mount path and new Volume name. // Renames Volume given its mount path and new Volume name.
class FileManagerPrivateRenameVolumeFunction class FileManagerPrivateRenameVolumeFunction
: public LoggedAsyncExtensionFunction { : public LoggedUIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.renameVolume", DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.renameVolume",
FILEMANAGERPRIVATE_RENAMEVOLUME) FILEMANAGERPRIVATE_RENAMEVOLUME)
...@@ -236,22 +235,24 @@ class FileManagerPrivateRenameVolumeFunction ...@@ -236,22 +235,24 @@ class FileManagerPrivateRenameVolumeFunction
protected: protected:
~FileManagerPrivateRenameVolumeFunction() override = default; ~FileManagerPrivateRenameVolumeFunction() override = default;
// ChromeAsyncExtensionFunction overrides. // ExtensionFunction overrides.
bool RunAsync() override; ResponseAction Run() override;
}; };
// Implements the chrome.fileManagerPrivate.startCopy method. // Implements the chrome.fileManagerPrivate.startCopy method.
class FileManagerPrivateInternalStartCopyFunction class FileManagerPrivateInternalStartCopyFunction
: public LoggedAsyncExtensionFunction { : public LoggedUIThreadExtensionFunction {
public: public:
FileManagerPrivateInternalStartCopyFunction();
DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.startCopy", DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.startCopy",
FILEMANAGERPRIVATEINTERNAL_STARTCOPY) FILEMANAGERPRIVATEINTERNAL_STARTCOPY)
protected: protected:
~FileManagerPrivateInternalStartCopyFunction() override = default; ~FileManagerPrivateInternalStartCopyFunction() override = default;
// ChromeAsyncExtensionFunction overrides. // ExtensionFunction overrides.
bool RunAsync() override; ResponseAction Run() override;
private: private:
void RunAfterGetFileMetadata(base::File::Error result, void RunAfterGetFileMetadata(base::File::Error result,
...@@ -270,11 +271,12 @@ class FileManagerPrivateInternalStartCopyFunction ...@@ -270,11 +271,12 @@ class FileManagerPrivateInternalStartCopyFunction
storage::FileSystemURL source_url_; storage::FileSystemURL source_url_;
storage::FileSystemURL destination_url_; storage::FileSystemURL destination_url_;
const ChromeExtensionFunctionDetails chrome_details_;
}; };
// Implements the chrome.fileManagerPrivate.cancelCopy method. // Implements the chrome.fileManagerPrivate.cancelCopy method.
class FileManagerPrivateCancelCopyFunction class FileManagerPrivateCancelCopyFunction
: public LoggedAsyncExtensionFunction { : public LoggedUIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.cancelCopy", DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.cancelCopy",
FILEMANAGERPRIVATE_CANCELCOPY) FILEMANAGERPRIVATE_CANCELCOPY)
...@@ -282,8 +284,8 @@ class FileManagerPrivateCancelCopyFunction ...@@ -282,8 +284,8 @@ class FileManagerPrivateCancelCopyFunction
protected: protected:
~FileManagerPrivateCancelCopyFunction() override = default; ~FileManagerPrivateCancelCopyFunction() override = default;
// ChromeAsyncExtensionFunction overrides. // ExtensionFunction overrides.
bool RunAsync() override; ResponseAction Run() override;
}; };
// Implements the chrome.fileManagerPrivateInternal.resolveIsolatedEntries // Implements the chrome.fileManagerPrivateInternal.resolveIsolatedEntries
...@@ -309,7 +311,7 @@ class FileManagerPrivateInternalResolveIsolatedEntriesFunction ...@@ -309,7 +311,7 @@ class FileManagerPrivateInternalResolveIsolatedEntriesFunction
}; };
class FileManagerPrivateInternalComputeChecksumFunction class FileManagerPrivateInternalComputeChecksumFunction
: public LoggedAsyncExtensionFunction { : public LoggedUIThreadExtensionFunction {
public: public:
FileManagerPrivateInternalComputeChecksumFunction(); FileManagerPrivateInternalComputeChecksumFunction();
...@@ -319,20 +321,22 @@ class FileManagerPrivateInternalComputeChecksumFunction ...@@ -319,20 +321,22 @@ class FileManagerPrivateInternalComputeChecksumFunction
protected: protected:
~FileManagerPrivateInternalComputeChecksumFunction() override; ~FileManagerPrivateInternalComputeChecksumFunction() override;
// ChromeAsyncExtensionFunction overrides. // ExtensionFunction overrides.
bool RunAsync() override; ResponseAction Run() override;
private: private:
std::unique_ptr<drive::util::FileStreamMd5Digester> digester_; std::unique_ptr<drive::util::FileStreamMd5Digester> digester_;
void Respond(const std::string& hash); void RespondWith(const std::string& hash);
}; };
// Implements the chrome.fileManagerPrivate.searchFilesByHashes method. // Implements the chrome.fileManagerPrivate.searchFilesByHashes method.
// TODO(b/883628): Write some tests maybe? // TODO(b/883628): Write some tests maybe?
class FileManagerPrivateSearchFilesByHashesFunction class FileManagerPrivateSearchFilesByHashesFunction
: public LoggedAsyncExtensionFunction { : public LoggedUIThreadExtensionFunction {
public: public:
FileManagerPrivateSearchFilesByHashesFunction();
DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.searchFilesByHashes", DECLARE_EXTENSION_FUNCTION("fileManagerPrivate.searchFilesByHashes",
FILEMANAGERPRIVATE_SEARCHFILESBYHASHES) FILEMANAGERPRIVATE_SEARCHFILESBYHASHES)
...@@ -340,8 +344,8 @@ class FileManagerPrivateSearchFilesByHashesFunction ...@@ -340,8 +344,8 @@ class FileManagerPrivateSearchFilesByHashesFunction
~FileManagerPrivateSearchFilesByHashesFunction() override = default; ~FileManagerPrivateSearchFilesByHashesFunction() override = default;
private: private:
// ChromeAsyncExtensionFunction overrides. // ExtensionFunction overrides.
bool RunAsync() override; ResponseAction Run() override;
// Fallback to walking the filesystem and checking file attributes. // Fallback to walking the filesystem and checking file attributes.
std::vector<drive::HashAndFilePath> SearchByAttribute( std::vector<drive::HashAndFilePath> SearchByAttribute(
...@@ -355,6 +359,8 @@ class FileManagerPrivateSearchFilesByHashesFunction ...@@ -355,6 +359,8 @@ class FileManagerPrivateSearchFilesByHashesFunction
void OnSearchByHashes(const std::set<std::string>& hashes, void OnSearchByHashes(const std::set<std::string>& hashes,
drive::FileError error, drive::FileError error,
const std::vector<drive::HashAndFilePath>& results); const std::vector<drive::HashAndFilePath>& results);
const ChromeExtensionFunctionDetails chrome_details_;
}; };
// Implements the chrome.fileManagerPrivate.isUMAEnabled method. // Implements the chrome.fileManagerPrivate.isUMAEnabled method.
...@@ -394,7 +400,7 @@ class FileManagerPrivateInternalSetEntryTagFunction ...@@ -394,7 +400,7 @@ class FileManagerPrivateInternalSetEntryTagFunction
// Implements the chrome.fileManagerPrivate.getDirectorySize method. // Implements the chrome.fileManagerPrivate.getDirectorySize method.
class FileManagerPrivateInternalGetDirectorySizeFunction class FileManagerPrivateInternalGetDirectorySizeFunction
: public LoggedAsyncExtensionFunction { : public LoggedUIThreadExtensionFunction {
public: public:
DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.getDirectorySize", DECLARE_EXTENSION_FUNCTION("fileManagerPrivateInternal.getDirectorySize",
FILEMANAGERPRIVATEINTERNAL_GETDIRECTORYSIZE) FILEMANAGERPRIVATEINTERNAL_GETDIRECTORYSIZE)
...@@ -404,8 +410,8 @@ class FileManagerPrivateInternalGetDirectorySizeFunction ...@@ -404,8 +410,8 @@ class FileManagerPrivateInternalGetDirectorySizeFunction
void OnDirectorySizeRetrieved(int64_t size); void OnDirectorySizeRetrieved(int64_t size);
// ChromeAsyncExtensionFunction overrides // ExtensionFunction overrides
bool RunAsync() override; ResponseAction Run() override;
}; };
} // namespace extensions } // namespace extensions
......
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