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 "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "webkit/browser/fileapi/async_file_util.h" | 10 #include "webkit/browser/fileapi/async_file_util.h" |
11 | 11 |
12 namespace chrome { | |
13 | |
14 class MediaPathFilter; | 12 class MediaPathFilter; |
15 | 13 |
16 // This class handles native file system operations with media type filtering. | 14 // This class handles native file system operations with media type filtering. |
17 // To support virtual file systems it implements the AsyncFileUtil interface | 15 // To support virtual file systems it implements the AsyncFileUtil interface |
18 // from scratch and provides synchronous override points. | 16 // from scratch and provides synchronous override points. |
19 class NativeMediaFileUtil : public fileapi::AsyncFileUtil { | 17 class NativeMediaFileUtil : public fileapi::AsyncFileUtil { |
20 public: | 18 public: |
21 explicit NativeMediaFileUtil(MediaPathFilter* media_path_filter); | 19 explicit NativeMediaFileUtil(MediaPathFilter* media_path_filter); |
22 virtual ~NativeMediaFileUtil(); | 20 virtual ~NativeMediaFileUtil(); |
23 | 21 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 fileapi::FileSystemOperationContext* context, | 163 fileapi::FileSystemOperationContext* context, |
166 const fileapi::FileSystemURL& url); | 164 const fileapi::FileSystemURL& url); |
167 virtual base::PlatformFileError CreateSnapshotFileSync( | 165 virtual base::PlatformFileError CreateSnapshotFileSync( |
168 fileapi::FileSystemOperationContext* context, | 166 fileapi::FileSystemOperationContext* context, |
169 const fileapi::FileSystemURL& url, | 167 const fileapi::FileSystemURL& url, |
170 base::PlatformFileInfo* file_info, | 168 base::PlatformFileInfo* file_info, |
171 base::FilePath* platform_path, | 169 base::FilePath* platform_path, |
172 scoped_refptr<webkit_blob::ShareableFileReference>* file_ref); | 170 scoped_refptr<webkit_blob::ShareableFileReference>* file_ref); |
173 | 171 |
174 protected: | 172 protected: |
175 chrome::MediaPathFilter* media_path_filter() { | 173 MediaPathFilter* media_path_filter() { |
176 return media_path_filter_; | 174 return media_path_filter_; |
177 } | 175 } |
178 | 176 |
179 private: | 177 private: |
180 // Like GetLocalFilePath(), but always take media_path_filter() into | 178 // Like GetLocalFilePath(), but always take media_path_filter() into |
181 // consideration. If the media_path_filter() check fails, return | 179 // consideration. If the media_path_filter() check fails, return |
182 // PLATFORM_FILE_ERROR_SECURITY. |local_file_path| does not have to exist. | 180 // PLATFORM_FILE_ERROR_SECURITY. |local_file_path| does not have to exist. |
183 base::PlatformFileError GetFilteredLocalFilePath( | 181 base::PlatformFileError GetFilteredLocalFilePath( |
184 fileapi::FileSystemOperationContext* context, | 182 fileapi::FileSystemOperationContext* context, |
185 const fileapi::FileSystemURL& file_system_url, | 183 const fileapi::FileSystemURL& file_system_url, |
186 base::FilePath* local_file_path); | 184 base::FilePath* local_file_path); |
187 | 185 |
188 // Like GetLocalFilePath(), but if the file does not exist, then return | 186 // Like GetLocalFilePath(), but if the file does not exist, then return |
189 // |failure_error|. | 187 // |failure_error|. |
190 // If |local_file_path| is a file, then take media_path_filter() into | 188 // If |local_file_path| is a file, then take media_path_filter() into |
191 // consideration. | 189 // consideration. |
192 // If the media_path_filter() check fails, return |failure_error|. | 190 // If the media_path_filter() check fails, return |failure_error|. |
193 // If |local_file_path| is a directory, return PLATFORM_FILE_OK. | 191 // If |local_file_path| is a directory, return PLATFORM_FILE_OK. |
194 base::PlatformFileError GetFilteredLocalFilePathForExistingFileOrDirectory( | 192 base::PlatformFileError GetFilteredLocalFilePathForExistingFileOrDirectory( |
195 fileapi::FileSystemOperationContext* context, | 193 fileapi::FileSystemOperationContext* context, |
196 const fileapi::FileSystemURL& file_system_url, | 194 const fileapi::FileSystemURL& file_system_url, |
197 base::PlatformFileError failure_error, | 195 base::PlatformFileError failure_error, |
198 base::FilePath* local_file_path); | 196 base::FilePath* local_file_path); |
199 | 197 |
200 | 198 |
201 base::WeakPtrFactory<NativeMediaFileUtil> weak_factory_; | 199 base::WeakPtrFactory<NativeMediaFileUtil> weak_factory_; |
202 | 200 |
203 // Not owned, owned by the backend which owns this. | 201 // Not owned, owned by the backend which owns this. |
204 chrome::MediaPathFilter* media_path_filter_; | 202 MediaPathFilter* media_path_filter_; |
205 | 203 |
206 DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtil); | 204 DISALLOW_COPY_AND_ASSIGN(NativeMediaFileUtil); |
207 }; | 205 }; |
208 | 206 |
209 } // namespace chrome | |
210 | |
211 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ | 207 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_NATIVE_MEDIA_FILE_UTIL_H_ |
OLD | NEW |