Chromium Code Reviews| Index: chrome/browser/media_galleries/fileapi/native_media_file_util.h |
| diff --git a/chrome/browser/media_galleries/fileapi/native_media_file_util.h b/chrome/browser/media_galleries/fileapi/native_media_file_util.h |
| index 0cfa71002c83c412ec0fb0054d3849dc0167352c..29cd3a96292d73655385098e35900d6dc94492f1 100644 |
| --- a/chrome/browser/media_galleries/fileapi/native_media_file_util.h |
| +++ b/chrome/browser/media_galleries/fileapi/native_media_file_util.h |
| @@ -6,67 +6,131 @@ |
| #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ |
| #include "base/memory/scoped_ptr.h" |
| -#include "webkit/browser/fileapi/isolated_file_util.h" |
| +#include "webkit/browser/fileapi/async_file_util.h" |
| namespace chrome { |
| // This class handles native file system operations with media type filtering |
| // which is passed to each method via fileapi::FileSystemOperationContext as |
| // MediaPathFilter. |
| -class NativeMediaFileUtil : public fileapi::IsolatedFileUtil { |
| +class NativeMediaFileUtil : public fileapi::AsyncFileUtil { |
| public: |
| NativeMediaFileUtil(); |
| - virtual base::PlatformFileError CreateOrOpen( |
| + // AsyncFileUtil overrides. |
| + virtual bool CreateOrOpen( |
| fileapi::FileSystemOperationContext* context, |
| const fileapi::FileSystemURL& url, |
| int file_flags, |
| - base::PlatformFile* file_handle, |
| - bool* created) OVERRIDE; |
| - virtual base::PlatformFileError EnsureFileExists( |
| + const CreateOrOpenCallback& callback) OVERRIDE; |
| + virtual bool EnsureFileExists( |
| fileapi::FileSystemOperationContext* context, |
| - const fileapi::FileSystemURL& url, bool* created) OVERRIDE; |
| - virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator( |
| + const fileapi::FileSystemURL& url, |
| + const EnsureFileExistsCallback& callback) OVERRIDE; |
| + virtual bool CreateDirectory( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& url, |
| + bool exclusive, |
| + bool recursive, |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual bool GetFileInfo( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& url, |
| + const GetFileInfoCallback& callback) OVERRIDE; |
| + virtual bool ReadDirectory( |
| fileapi::FileSystemOperationContext* context, |
| - const fileapi::FileSystemURL& root_url) OVERRIDE; |
| - virtual base::PlatformFileError Touch( |
| + const fileapi::FileSystemURL& url, |
| + const ReadDirectoryCallback& callback) OVERRIDE; |
| + virtual bool Touch( |
| fileapi::FileSystemOperationContext* context, |
| const fileapi::FileSystemURL& url, |
| const base::Time& last_access_time, |
| - const base::Time& last_modified_time) OVERRIDE; |
| - virtual base::PlatformFileError Truncate( |
| + const base::Time& last_modified_time, |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual bool Truncate( |
| fileapi::FileSystemOperationContext* context, |
| const fileapi::FileSystemURL& url, |
| - int64 length) OVERRIDE; |
| - virtual base::PlatformFileError CopyOrMoveFile( |
| + int64 length, |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual bool CopyFileLocal( |
| fileapi::FileSystemOperationContext* context, |
| const fileapi::FileSystemURL& src_url, |
| const fileapi::FileSystemURL& dest_url, |
| - bool copy) OVERRIDE; |
| - virtual base::PlatformFileError CopyInForeignFile( |
| - fileapi::FileSystemOperationContext* context, |
| - const base::FilePath& src_file_path, |
| - const fileapi::FileSystemURL& dest_url) OVERRIDE; |
| - virtual base::PlatformFileError DeleteFile( |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual bool MoveFileLocal( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& src_url, |
| + const fileapi::FileSystemURL& dest_url, |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual bool CopyInForeignFile( |
| + fileapi::FileSystemOperationContext* context, |
| + const base::FilePath& src_file_path, |
| + const fileapi::FileSystemURL& dest_url, |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual bool DeleteFile( |
| fileapi::FileSystemOperationContext* context, |
| - const fileapi::FileSystemURL& url) OVERRIDE; |
| - virtual base::PlatformFileError GetFileInfo( |
| + const fileapi::FileSystemURL& url, |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual bool DeleteDirectory( |
| fileapi::FileSystemOperationContext* context, |
| const fileapi::FileSystemURL& url, |
| - base::PlatformFileInfo* file_info, |
| - base::FilePath* platform_path) OVERRIDE; |
| - virtual webkit_blob::ScopedFile CreateSnapshotFile( |
| + const StatusCallback& callback) OVERRIDE; |
| + virtual bool CreateSnapshotFile( |
| fileapi::FileSystemOperationContext* context, |
| const fileapi::FileSystemURL& url, |
| - base::PlatformFileError* error, |
| - base::PlatformFileInfo* file_info, |
| - base::FilePath* platform_path) OVERRIDE; |
| + const CreateSnapshotFileCallback& callback) OVERRIDE; |
| // Uses the MIME sniffer code, which actually looks into the file, |
| // to determine if it is really a media file (to avoid exposing |
| // non-media files with a media file extension.) |
| static base::PlatformFileError IsMediaFile(const base::FilePath& path); |
| + protected: |
| + // Necessary for copy/move to succeed. |
| + virtual base::PlatformFileError CreateDirectorySync( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& url, |
| + bool exclusive, |
| + bool recursive); |
| + // Used by MoveFile and CopyFile. |
| + virtual base::PlatformFileError CopyOrMoveFileSync( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& src_url, |
| + const fileapi::FileSystemURL& dest_url, |
| + bool copy); |
| + // Used by CopyInForeignFile |
| + virtual base::PlatformFileError CopyInForeignFileSync( |
| + fileapi::FileSystemOperationContext* context, |
| + const base::FilePath& src_file_path, |
| + const fileapi::FileSystemURL& dest_url); |
| + // Synchronous for convenience reasons. Call only on the task runner thread. |
|
vandebo (ex-Chrome)
2013/06/02 04:30:24
All these methods should only called on the task r
|
| + virtual base::PlatformFileError GetFileInfoSync( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& url, |
| + base::PlatformFileInfo* file_info, |
| + base::FilePath* platform_path); |
| + // Called by GetFileInfoSync. Meant to be overridden by subclasses that |
| + // have special mappings from URLs to platform paths (virtual filesystems). |
| + virtual base::PlatformFileError GetLocalFilePath( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& file_system_url, |
| + base::FilePath* local_file_path); |
| + // Posted by ReadDirectory onto the task runner thread. |
|
vandebo (ex-Chrome)
2013/06/02 04:30:24
Comments should be about what the methods does, no
|
| + virtual base::PlatformFileError ReadDirectorySync( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& url, |
| + EntryList* file_list); |
| + // Necessary for copy/move to succeed. |
| + virtual base::PlatformFileError DeleteDirectorySync( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& url); |
| + virtual base::PlatformFileError CreateSnapshotFileSync( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& url, |
| + base::PlatformFileInfo* file_info, |
| + base::FilePath* platform_path, |
| + scoped_refptr<webkit_blob::ShareableFileReference>* file_ref); |
| + |
| private: |
| // Like GetLocalFilePath(), but always take media_path_filter() into |
| // consideration. If the media_path_filter() check fails, return |
| @@ -88,6 +152,20 @@ class NativeMediaFileUtil : public fileapi::IsolatedFileUtil { |
| base::PlatformFileError failure_error, |
| base::FilePath* local_file_path); |
| + // Methods to perform asynchronous methods without heap allocations. |
|
vandebo (ex-Chrome)
2013/06/02 04:30:24
nit: this comment isn't helpful to the future read
|
| + virtual void GetFileInfoOnTaskRunnerThread( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& url, |
| + const GetFileInfoCallback& callback); |
| + virtual void ReadDirectoryOnTaskRunnerThread( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& url, |
| + const ReadDirectoryCallback& callback); |
| + virtual void CreateSnapshotFileOnTaskRunnerThread( |
| + fileapi::FileSystemOperationContext* context, |
| + const fileapi::FileSystemURL& url, |
| + const CreateSnapshotFileCallback& callback); |
| + |
| DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtil); |
| }; |