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 CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_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/browser/fileapi/isolated_file_util.h" | 9 #include "webkit/browser/fileapi/async_file_util.h" |
10 | 10 |
11 namespace chrome { | 11 namespace chrome { |
12 | 12 |
13 // This class handles native file system operations with media type filtering | 13 // This class handles native file system operations with media type filtering |
14 // which is passed to each method via fileapi::FileSystemOperationContext as | 14 // which is passed to each method via fileapi::FileSystemOperationContext as |
15 // MediaPathFilter. | 15 // MediaPathFilter. |
16 class NativeMediaFileUtil : public fileapi::IsolatedFileUtil { | 16 class NativeMediaFileUtil : public fileapi::AsyncFileUtil { |
17 public: | 17 public: |
18 NativeMediaFileUtil(); | 18 NativeMediaFileUtil(); |
19 | 19 |
20 virtual base::PlatformFileError CreateOrOpen( | 20 // AsyncFileUtil overrides. |
21 virtual bool CreateOrOpen( | |
21 fileapi::FileSystemOperationContext* context, | 22 fileapi::FileSystemOperationContext* context, |
22 const fileapi::FileSystemURL& url, | 23 const fileapi::FileSystemURL& url, |
23 int file_flags, | 24 int file_flags, |
24 base::PlatformFile* file_handle, | 25 const CreateOrOpenCallback& callback) OVERRIDE; |
25 bool* created) OVERRIDE; | 26 virtual bool EnsureFileExists( |
26 virtual base::PlatformFileError EnsureFileExists( | |
27 fileapi::FileSystemOperationContext* context, | 27 fileapi::FileSystemOperationContext* context, |
28 const fileapi::FileSystemURL& url, bool* created) OVERRIDE; | 28 const fileapi::FileSystemURL& url, |
29 virtual scoped_ptr<AbstractFileEnumerator> CreateFileEnumerator( | 29 const EnsureFileExistsCallback& callback) OVERRIDE; |
30 virtual bool CreateDirectory( | |
30 fileapi::FileSystemOperationContext* context, | 31 fileapi::FileSystemOperationContext* context, |
31 const fileapi::FileSystemURL& root_url) OVERRIDE; | 32 const fileapi::FileSystemURL& url, |
32 virtual base::PlatformFileError Touch( | 33 bool exclusive, |
34 bool recursive, | |
35 const StatusCallback& callback) OVERRIDE; | |
36 virtual bool GetFileInfo( | |
37 fileapi::FileSystemOperationContext* context, | |
38 const fileapi::FileSystemURL& url, | |
39 const GetFileInfoCallback& callback) OVERRIDE; | |
40 virtual bool ReadDirectory( | |
41 fileapi::FileSystemOperationContext* context, | |
42 const fileapi::FileSystemURL& url, | |
43 const ReadDirectoryCallback& callback) OVERRIDE; | |
44 virtual bool Touch( | |
33 fileapi::FileSystemOperationContext* context, | 45 fileapi::FileSystemOperationContext* context, |
34 const fileapi::FileSystemURL& url, | 46 const fileapi::FileSystemURL& url, |
35 const base::Time& last_access_time, | 47 const base::Time& last_access_time, |
36 const base::Time& last_modified_time) OVERRIDE; | 48 const base::Time& last_modified_time, |
37 virtual base::PlatformFileError Truncate( | 49 const StatusCallback& callback) OVERRIDE; |
50 virtual bool Truncate( | |
38 fileapi::FileSystemOperationContext* context, | 51 fileapi::FileSystemOperationContext* context, |
39 const fileapi::FileSystemURL& url, | 52 const fileapi::FileSystemURL& url, |
40 int64 length) OVERRIDE; | 53 int64 length, |
41 virtual base::PlatformFileError CopyOrMoveFile( | 54 const StatusCallback& callback) OVERRIDE; |
55 virtual bool CopyFileLocal( | |
42 fileapi::FileSystemOperationContext* context, | 56 fileapi::FileSystemOperationContext* context, |
43 const fileapi::FileSystemURL& src_url, | 57 const fileapi::FileSystemURL& src_url, |
44 const fileapi::FileSystemURL& dest_url, | 58 const fileapi::FileSystemURL& dest_url, |
45 bool copy) OVERRIDE; | 59 const StatusCallback& callback) OVERRIDE; |
46 virtual base::PlatformFileError CopyInForeignFile( | 60 virtual bool MoveFileLocal( |
47 fileapi::FileSystemOperationContext* context, | |
48 const base::FilePath& src_file_path, | |
49 const fileapi::FileSystemURL& dest_url) OVERRIDE; | |
50 virtual base::PlatformFileError DeleteFile( | |
51 fileapi::FileSystemOperationContext* context, | 61 fileapi::FileSystemOperationContext* context, |
52 const fileapi::FileSystemURL& url) OVERRIDE; | 62 const fileapi::FileSystemURL& src_url, |
53 virtual base::PlatformFileError GetFileInfo( | 63 const fileapi::FileSystemURL& dest_url, |
64 const StatusCallback& callback) OVERRIDE; | |
65 virtual bool CopyInForeignFile( | |
66 fileapi::FileSystemOperationContext* context, | |
67 const base::FilePath& src_file_path, | |
68 const fileapi::FileSystemURL& dest_url, | |
69 const StatusCallback& callback) OVERRIDE; | |
70 virtual bool DeleteFile( | |
54 fileapi::FileSystemOperationContext* context, | 71 fileapi::FileSystemOperationContext* context, |
55 const fileapi::FileSystemURL& url, | 72 const fileapi::FileSystemURL& url, |
56 base::PlatformFileInfo* file_info, | 73 const StatusCallback& callback) OVERRIDE; |
57 base::FilePath* platform_path) OVERRIDE; | 74 virtual bool DeleteDirectory( |
58 virtual webkit_blob::ScopedFile CreateSnapshotFile( | |
59 fileapi::FileSystemOperationContext* context, | 75 fileapi::FileSystemOperationContext* context, |
60 const fileapi::FileSystemURL& url, | 76 const fileapi::FileSystemURL& url, |
61 base::PlatformFileError* error, | 77 const StatusCallback& callback) OVERRIDE; |
62 base::PlatformFileInfo* file_info, | 78 virtual bool CreateSnapshotFile( |
63 base::FilePath* platform_path) OVERRIDE; | 79 fileapi::FileSystemOperationContext* context, |
80 const fileapi::FileSystemURL& url, | |
81 const CreateSnapshotFileCallback& callback) OVERRIDE; | |
64 | 82 |
65 // Uses the MIME sniffer code, which actually looks into the file, | 83 // Uses the MIME sniffer code, which actually looks into the file, |
66 // to determine if it is really a media file (to avoid exposing | 84 // to determine if it is really a media file (to avoid exposing |
67 // non-media files with a media file extension.) | 85 // non-media files with a media file extension.) |
68 static base::PlatformFileError IsMediaFile(const base::FilePath& path); | 86 static base::PlatformFileError IsMediaFile(const base::FilePath& path); |
69 | 87 |
70 private: | 88 protected: |
71 // Like GetLocalFilePath(), but always take media_path_filter() into | 89 virtual base::PlatformFileError GetFileInfoSync( |
vandebo (ex-Chrome)
2013/05/30 18:39:19
These methods should be documented.
tommycli
2013/05/30 19:35:20
Done.
| |
72 // consideration. If the media_path_filter() check fails, return | 90 fileapi::FileSystemOperationContext* context, |
73 // PLATFORM_FILE_ERROR_SECURITY. |local_file_path| does not have to exist. | 91 const fileapi::FileSystemURL& url, |
74 base::PlatformFileError GetFilteredLocalFilePath( | 92 base::PlatformFileInfo* file_info, |
93 base::FilePath* platform_path); | |
94 virtual base::PlatformFileError GetLocalFilePath( | |
75 fileapi::FileSystemOperationContext* context, | 95 fileapi::FileSystemOperationContext* context, |
76 const fileapi::FileSystemURL& file_system_url, | 96 const fileapi::FileSystemURL& file_system_url, |
77 base::FilePath* local_file_path); | 97 base::FilePath* local_file_path); |
98 virtual base::PlatformFileError ReadDirectorySync( | |
99 fileapi::FileSystemOperationContext* context, | |
100 const fileapi::FileSystemURL& url, | |
101 EntryList* file_list); | |
78 | 102 |
79 // Like GetLocalFilePath(), but if the file does not exist, then return | 103 private: |
80 // |failure_error|. | |
81 // If |local_file_path| is a file, then take media_path_filter() into | |
82 // consideration. | |
83 // If the media_path_filter() check fails, return |failure_error|. | |
84 // If |local_file_path| is a directory, return PLATFORM_FILE_OK. | |
85 base::PlatformFileError GetFilteredLocalFilePathForExistingFileOrDirectory( | |
86 fileapi::FileSystemOperationContext* context, | |
87 const fileapi::FileSystemURL& file_system_url, | |
88 base::PlatformFileError failure_error, | |
89 base::FilePath* local_file_path); | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtil); | 104 DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtil); |
92 }; | 105 }; |
93 | 106 |
94 } // namespace chrome | 107 } // namespace chrome |
95 | 108 |
96 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ | 109 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ |
OLD | NEW |