| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef WEBKIT_FILEAPI_MEDIA_NATIVE_MEDIA_FILE_UTIL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ |
| 6 #define WEBKIT_FILEAPI_MEDIA_NATIVE_MEDIA_FILE_UTIL_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ |
| 7 | 7 |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "webkit/fileapi/isolated_file_util.h" | 9 #include "webkit/fileapi/isolated_file_util.h" |
| 10 #include "webkit/storage/webkit_storage_export.h" | |
| 11 | 10 |
| 12 namespace fileapi { | 11 namespace chrome { |
| 13 | 12 |
| 14 // This class handles native file system operations with media type filtering | 13 // This class handles native file system operations with media type filtering |
| 15 // which is passed to each method via FileSystemOperationContext as | 14 // which is passed to each method via fileapi::FileSystemOperationContext as |
| 16 // MediaPathFilter. | 15 // MediaPathFilter. |
| 17 class WEBKIT_STORAGE_EXPORT_PRIVATE NativeMediaFileUtil | 16 class NativeMediaFileUtil : public fileapi::IsolatedFileUtil { |
| 18 : public IsolatedFileUtil { | |
| 19 public: | 17 public: |
| 20 NativeMediaFileUtil(); | 18 NativeMediaFileUtil(); |
| 21 | 19 |
| 22 virtual base::PlatformFileError CreateOrOpen( | 20 virtual base::PlatformFileError CreateOrOpen( |
| 23 FileSystemOperationContext* context, | 21 fileapi::FileSystemOperationContext* context, |
| 24 const FileSystemURL& url, | 22 const fileapi::FileSystemURL& url, |
| 25 int file_flags, | 23 int file_flags, |
| 26 base::PlatformFile* file_handle, | 24 base::PlatformFile* file_handle, |
| 27 bool* created) OVERRIDE; | 25 bool* created) OVERRIDE; |
| 28 virtual base::PlatformFileError EnsureFileExists( | 26 virtual base::PlatformFileError EnsureFileExists( |
| 29 FileSystemOperationContext* context, | 27 fileapi::FileSystemOperationContext* context, |
| 30 const FileSystemURL& url, bool* created) OVERRIDE; | 28 const fileapi::FileSystemURL& url, bool* created) OVERRIDE; |
| 31 virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator( | 29 virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator( |
| 32 FileSystemOperationContext* context, | 30 fileapi::FileSystemOperationContext* context, |
| 33 const FileSystemURL& root_url) OVERRIDE; | 31 const fileapi::FileSystemURL& root_url) OVERRIDE; |
| 34 virtual base::PlatformFileError Touch( | 32 virtual base::PlatformFileError Touch( |
| 35 FileSystemOperationContext* context, | 33 fileapi::FileSystemOperationContext* context, |
| 36 const FileSystemURL& url, | 34 const fileapi::FileSystemURL& url, |
| 37 const base::Time& last_access_time, | 35 const base::Time& last_access_time, |
| 38 const base::Time& last_modified_time) OVERRIDE; | 36 const base::Time& last_modified_time) OVERRIDE; |
| 39 virtual base::PlatformFileError Truncate( | 37 virtual base::PlatformFileError Truncate( |
| 40 FileSystemOperationContext* context, | 38 fileapi::FileSystemOperationContext* context, |
| 41 const FileSystemURL& url, | 39 const fileapi::FileSystemURL& url, |
| 42 int64 length) OVERRIDE; | 40 int64 length) OVERRIDE; |
| 43 virtual base::PlatformFileError CopyOrMoveFile( | 41 virtual base::PlatformFileError CopyOrMoveFile( |
| 44 FileSystemOperationContext* context, | 42 fileapi::FileSystemOperationContext* context, |
| 45 const FileSystemURL& src_url, | 43 const fileapi::FileSystemURL& src_url, |
| 46 const FileSystemURL& dest_url, | 44 const fileapi::FileSystemURL& dest_url, |
| 47 bool copy) OVERRIDE; | 45 bool copy) OVERRIDE; |
| 48 virtual base::PlatformFileError CopyInForeignFile( | 46 virtual base::PlatformFileError CopyInForeignFile( |
| 49 FileSystemOperationContext* context, | 47 fileapi::FileSystemOperationContext* context, |
| 50 const base::FilePath& src_file_path, | 48 const base::FilePath& src_file_path, |
| 51 const FileSystemURL& dest_url) OVERRIDE; | 49 const fileapi::FileSystemURL& dest_url) OVERRIDE; |
| 52 virtual base::PlatformFileError DeleteFile( | 50 virtual base::PlatformFileError DeleteFile( |
| 53 FileSystemOperationContext* context, | 51 fileapi::FileSystemOperationContext* context, |
| 54 const FileSystemURL& url) OVERRIDE; | 52 const fileapi::FileSystemURL& url) OVERRIDE; |
| 55 virtual base::PlatformFileError GetFileInfo( | 53 virtual base::PlatformFileError GetFileInfo( |
| 56 FileSystemOperationContext* context, | 54 fileapi::FileSystemOperationContext* context, |
| 57 const FileSystemURL& url, | 55 const fileapi::FileSystemURL& url, |
| 58 base::PlatformFileInfo* file_info, | 56 base::PlatformFileInfo* file_info, |
| 59 base::FilePath* platform_path) OVERRIDE; | 57 base::FilePath* platform_path) OVERRIDE; |
| 60 | 58 |
| 61 private: | 59 private: |
| 62 // Like GetLocalFilePath(), but always take media_path_filter() into | 60 // Like GetLocalFilePath(), but always take media_path_filter() into |
| 63 // consideration. If the media_path_filter() check fails, return | 61 // consideration. If the media_path_filter() check fails, return |
| 64 // PLATFORM_FILE_ERROR_SECURITY. |local_file_path| does not have to exist. | 62 // PLATFORM_FILE_ERROR_SECURITY. |local_file_path| does not have to exist. |
| 65 base::PlatformFileError GetFilteredLocalFilePath( | 63 base::PlatformFileError GetFilteredLocalFilePath( |
| 66 FileSystemOperationContext* context, | 64 fileapi::FileSystemOperationContext* context, |
| 67 const FileSystemURL& file_system_url, | 65 const fileapi::FileSystemURL& file_system_url, |
| 68 base::FilePath* local_file_path); | 66 base::FilePath* local_file_path); |
| 69 | 67 |
| 70 // Like GetLocalFilePath(), but if the file does not exist, then return | 68 // Like GetLocalFilePath(), but if the file does not exist, then return |
| 71 // |failure_error|. | 69 // |failure_error|. |
| 72 // If |local_file_path| is a file, then take media_path_filter() into | 70 // If |local_file_path| is a file, then take media_path_filter() into |
| 73 // consideration. | 71 // consideration. |
| 74 // If the media_path_filter() check fails, return |failure_error|. | 72 // If the media_path_filter() check fails, return |failure_error|. |
| 75 // If |local_file_path| is a directory, return PLATFORM_FILE_OK. | 73 // If |local_file_path| is a directory, return PLATFORM_FILE_OK. |
| 76 base::PlatformFileError GetFilteredLocalFilePathForExistingFileOrDirectory( | 74 base::PlatformFileError GetFilteredLocalFilePathForExistingFileOrDirectory( |
| 77 FileSystemOperationContext* context, | 75 fileapi::FileSystemOperationContext* context, |
| 78 const FileSystemURL& file_system_url, | 76 const fileapi::FileSystemURL& file_system_url, |
| 79 base::PlatformFileError failure_error, | 77 base::PlatformFileError failure_error, |
| 80 base::FilePath* local_file_path); | 78 base::FilePath* local_file_path); |
| 81 | 79 |
| 82 DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtil); | 80 DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtil); |
| 83 }; | 81 }; |
| 84 | 82 |
| 85 } // namespace fileapi | 83 } // namespace chrome |
| 86 | 84 |
| 87 #endif // WEBKIT_FILEAPI_MEDIA_NATIVE_MEDIA_FILE_UTIL_H_ | 85 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ |
| OLD | NEW |