Index: chrome/browser/extensions/extension_file_browser_private_api.h |
diff --git a/chrome/browser/extensions/extension_file_browser_private_api.h b/chrome/browser/extensions/extension_file_browser_private_api.h |
index 39c3deae0fdb013d54aa0ddb49bf2397b898777c..fff7bd050acab14e9a85256a9ae4f6e56cf85dbc 100644 |
--- a/chrome/browser/extensions/extension_file_browser_private_api.h |
+++ b/chrome/browser/extensions/extension_file_browser_private_api.h |
@@ -16,7 +16,7 @@ |
#include "webkit/fileapi/file_system_callback_dispatcher.h" |
#ifdef OS_CHROMEOS |
-#include "chrome/browser/chromeos/cros/mount_library.h" |
+#include "chrome/browser/chromeos/disks/disk_mount_manager.h" |
#endif |
class GURL; |
@@ -24,9 +24,12 @@ class GURL; |
// Implements the chrome.fileBrowserPrivate.requestLocalFileSystem method. |
class RequestLocalFileSystemFunction : public AsyncExtensionFunction { |
protected: |
- friend class LocalFileSystemCallbackDispatcher; |
// AsyncExtensionFunction overrides. |
virtual bool RunImpl() OVERRIDE; |
+ |
+ private: |
+ class LocalFileSystemCallbackDispatcher; |
+ |
void RespondSuccessOnUIThread(const std::string& name, |
const GURL& root_path); |
void RespondFailedOnUIThread(base::PlatformFileError error_code); |
@@ -99,7 +102,7 @@ class ExecuteTasksFileBrowserFunction : public AsyncExtensionFunction { |
bool is_directory; |
}; |
typedef std::vector<FileDefinition> FileDefinitionList; |
- friend class ExecuteTasksFileSystemCallbackDispatcher; |
+ class ExecuteTasksFileSystemCallbackDispatcher; |
// Initates execution of context menu tasks identified with |task_id| for |
// each element of |files_list|. |
bool InitiateFileTaskExecution(const std::string& task_id, |
@@ -125,19 +128,25 @@ class FileBrowserFunction |
protected: |
typedef std::vector<GURL> UrlList; |
typedef std::vector<FilePath> FilePathList; |
+ typedef base::Callback<void(const FilePathList&)> GetLocalPathsCallback; |
virtual ~FileBrowserFunction(); |
- // Convert virtual paths to local paths on the file thread. |
- void GetLocalPathsOnFileThread(const UrlList& file_urls, |
- void* context); |
- |
- // Callback with converted local paths. |
- virtual void GetLocalPathsResponseOnUIThread(const FilePathList& files, |
- void* context) {} |
+ // Converts virtual paths to local paths by calling GetLocalPathsOnFileThread |
+ // on the file thread and call |callback| on the UI thread with the result. |
+ void GetLocalPathsOnFileThreadAndRunCallbackOnUIThread( |
+ const UrlList& file_urls, |
+ GetLocalPathsCallback callback); |
// Figure out the tab_id of the hosting tab. |
int32 GetTabId() const; |
+ |
+ private: |
+ // Converts virtual paths to local paths and call |callback| (on the UI |
+ // thread) with the results. |
+ // This method must be called from the file thread. |
+ void GetLocalPathsOnFileThread(const UrlList& file_urls, |
+ GetLocalPathsCallback callback); |
}; |
// Select a single file. Closes the dialog window. |
@@ -152,11 +161,11 @@ class SelectFileFunction |
// AsyncExtensionFunction overrides. |
virtual bool RunImpl() OVERRIDE; |
- // FileBrowserFunction overrides. |
- virtual void GetLocalPathsResponseOnUIThread(const FilePathList& files, |
- void* context) OVERRIDE; |
- |
private: |
+ // A callback method to handle the result of |
+ // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. |
+ void GetLocalPathsResponseOnUIThread(const FilePathList& files); |
+ |
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.selectFile"); |
}; |
@@ -172,11 +181,12 @@ class ViewFilesFunction |
// AsyncExtensionFunction overrides. |
virtual bool RunImpl() OVERRIDE; |
- // FileBrowserFunction overrides. |
- virtual void GetLocalPathsResponseOnUIThread(const FilePathList& files, |
- void* context) OVERRIDE; |
- |
private: |
+ // A callback method to handle the result of |
+ // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. |
+ void GetLocalPathsResponseOnUIThread(const std::string& internal_task_id, |
+ const FilePathList& files); |
+ |
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.viewFiles"); |
}; |
@@ -192,11 +202,11 @@ class SelectFilesFunction |
// AsyncExtensionFunction overrides. |
virtual bool RunImpl() OVERRIDE; |
- // FileBrowserFunction overrides. |
- virtual void GetLocalPathsResponseOnUIThread(const FilePathList& files, |
- void* context) OVERRIDE; |
- |
private: |
+ // A callback method to handle the result of |
+ // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. |
+ void GetLocalPathsResponseOnUIThread(const FilePathList& files); |
+ |
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.selectFiles"); |
}; |
@@ -225,23 +235,14 @@ class AddMountFunction |
protected: |
virtual ~AddMountFunction(); |
+ // AsyncExtensionFunction overrides. |
virtual bool RunImpl() OVERRIDE; |
- // FileBrowserFunction overrides. |
- virtual void GetLocalPathsResponseOnUIThread(const FilePathList& files, |
- void* context) OVERRIDE; |
- |
private: |
-#if defined(OS_CHROMEOS) |
- struct MountParamaters { |
- MountParamaters(const std::string& type, |
- const chromeos::MountPathOptions& options) |
- : mount_type(type), mount_options(options) {} |
- ~MountParamaters() {} |
- std::string mount_type; |
- chromeos::MountPathOptions mount_options; |
- }; |
-#endif |
+ // A callback method to handle the result of |
+ // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. |
+ void GetLocalPathsResponseOnUIThread(const std::string& mount_type_str, |
+ const FilePathList& files); |
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.addMount"); |
}; |
@@ -255,12 +256,14 @@ class RemoveMountFunction |
protected: |
virtual ~RemoveMountFunction(); |
- // FileBrowserFunction overrides. |
+ // AsyncExtensionFunction overrides. |
virtual bool RunImpl() OVERRIDE; |
- virtual void GetLocalPathsResponseOnUIThread(const FilePathList& files, |
- void* context) OVERRIDE; |
private: |
+ // A callback method to handle the result of |
+ // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. |
+ void GetLocalPathsResponseOnUIThread(const FilePathList& files); |
+ |
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.removeMount"); |
}; |
@@ -272,6 +275,7 @@ class GetMountPointsFunction |
protected: |
virtual ~GetMountPointsFunction(); |
+ // AsyncExtensionFunction overrides. |
virtual bool RunImpl() OVERRIDE; |
private: |
@@ -287,13 +291,14 @@ class FormatDeviceFunction |
protected: |
virtual ~FormatDeviceFunction(); |
+ // AsyncExtensionFunction overrides. |
virtual bool RunImpl() OVERRIDE; |
-// FileBrowserFunction overrides. |
- virtual void GetLocalPathsResponseOnUIThread(const FilePathList& files, |
- void* context) OVERRIDE; |
- |
private: |
+ // A callback method to handle the result of |
+ // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. |
+ void GetLocalPathsResponseOnUIThread(const FilePathList& files); |
+ |
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.formatDevice"); |
}; |
@@ -305,16 +310,18 @@ class GetSizeStatsFunction |
protected: |
virtual ~GetSizeStatsFunction(); |
- // FileBrowserFunction overrides. |
+ // AsyncExtensionFunction overrides. |
virtual bool RunImpl() OVERRIDE; |
- virtual void GetLocalPathsResponseOnUIThread(const FilePathList& files, |
- void* context) OVERRIDE; |
private: |
- void GetSizeStatsCallbackOnUIThread(const char* mount_path, |
+ // A callback method to handle the result of |
+ // GetLocalPathsOnFileThreadAndRunCallbackOnUIThread. |
+ void GetLocalPathsResponseOnUIThread(const FilePathList& files); |
+ |
+ void GetSizeStatsCallbackOnUIThread(const std::string& mount_path, |
size_t total_size_kb, |
size_t remaining_size_kb); |
- void CallGetSizeStatsOnFileThread(const char* mount_path); |
+ void CallGetSizeStatsOnFileThread(const std::string& mount_path); |
DECLARE_EXTENSION_FUNCTION_NAME("fileBrowserPrivate.getSizeStats"); |
}; |