OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ | 5 #ifndef CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ |
6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ | 6 #define CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H_ |
7 | 7 |
8 #include "base/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 } | 23 } |
24 | 24 |
25 namespace net { | 25 namespace net { |
26 class IOBuffer; | 26 class IOBuffer; |
27 } | 27 } |
28 | 28 |
29 namespace webkit_blob { | 29 namespace webkit_blob { |
30 class FileStreamReader; | 30 class FileStreamReader; |
31 } | 31 } |
32 | 32 |
| 33 enum MediaFileValidationType { |
| 34 NO_MEDIA_FILE_VALIDATION, |
| 35 APPLY_MEDIA_FILE_VALIDATION, |
| 36 }; |
| 37 |
33 class DeviceMediaAsyncFileUtil : public fileapi::AsyncFileUtil { | 38 class DeviceMediaAsyncFileUtil : public fileapi::AsyncFileUtil { |
34 public: | 39 public: |
35 virtual ~DeviceMediaAsyncFileUtil(); | 40 virtual ~DeviceMediaAsyncFileUtil(); |
36 | 41 |
37 // Returns an instance of DeviceMediaAsyncFileUtil. Returns NULL if | 42 // Returns an instance of DeviceMediaAsyncFileUtil. Returns NULL if |
38 // asynchronous operation is not supported. Callers own the returned | 43 // asynchronous operation is not supported. Callers own the returned |
39 // object. | 44 // object. |
40 static DeviceMediaAsyncFileUtil* Create(const base::FilePath& profile_path); | 45 static DeviceMediaAsyncFileUtil* Create( |
| 46 const base::FilePath& profile_path, |
| 47 MediaFileValidationType validation_type); |
41 | 48 |
42 bool SupportsStreaming(const fileapi::FileSystemURL& url); | 49 bool SupportsStreaming(const fileapi::FileSystemURL& url); |
43 | 50 |
44 // AsyncFileUtil overrides. | 51 // AsyncFileUtil overrides. |
45 virtual void CreateOrOpen( | 52 virtual void CreateOrOpen( |
46 scoped_ptr<fileapi::FileSystemOperationContext> context, | 53 scoped_ptr<fileapi::FileSystemOperationContext> context, |
47 const fileapi::FileSystemURL& url, | 54 const fileapi::FileSystemURL& url, |
48 int file_flags, | 55 int file_flags, |
49 const CreateOrOpenCallback& callback) OVERRIDE; | 56 const CreateOrOpenCallback& callback) OVERRIDE; |
50 virtual void EnsureFileExists( | 57 virtual void EnsureFileExists( |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 // when the state of the underlying storage changes. Any errors associated | 124 // when the state of the underlying storage changes. Any errors associated |
118 // with reading this file are returned by the FileStreamReader itself. | 125 // with reading this file are returned by the FileStreamReader itself. |
119 virtual scoped_ptr<webkit_blob::FileStreamReader> GetFileStreamReader( | 126 virtual scoped_ptr<webkit_blob::FileStreamReader> GetFileStreamReader( |
120 const fileapi::FileSystemURL& url, | 127 const fileapi::FileSystemURL& url, |
121 int64 offset, | 128 int64 offset, |
122 const base::Time& expected_modification_time, | 129 const base::Time& expected_modification_time, |
123 fileapi::FileSystemContext* context); | 130 fileapi::FileSystemContext* context); |
124 | 131 |
125 private: | 132 private: |
126 // Use Create() to get an instance of DeviceMediaAsyncFileUtil. | 133 // Use Create() to get an instance of DeviceMediaAsyncFileUtil. |
127 explicit DeviceMediaAsyncFileUtil(const base::FilePath& profile_path); | 134 DeviceMediaAsyncFileUtil(const base::FilePath& profile_path, |
| 135 MediaFileValidationType validation_type); |
128 | 136 |
129 // Called when GetFileInfo method call succeeds. |file_info| contains the | 137 // Called when GetFileInfo method call succeeds. |file_info| contains the |
130 // file details of the requested url. |callback| is invoked to complete the | 138 // file details of the requested url. |callback| is invoked to complete the |
131 // GetFileInfo request. | 139 // GetFileInfo request. |
132 void OnDidGetFileInfo( | 140 void OnDidGetFileInfo( |
133 const AsyncFileUtil::GetFileInfoCallback& callback, | 141 const AsyncFileUtil::GetFileInfoCallback& callback, |
134 const base::File::Info& file_info); | 142 const base::File::Info& file_info); |
135 | 143 |
136 // Called when GetFileInfo method call failed to get the details of file | 144 // Called when GetFileInfo method call failed to get the details of file |
137 // specified by the requested url. |callback| is invoked to notify the | 145 // specified by the requested url. |callback| is invoked to notify the |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 // contents of url.path() to |snapshot_file_path|. | 202 // contents of url.path() to |snapshot_file_path|. |
195 void OnSnapshotFileCreatedRunTask( | 203 void OnSnapshotFileCreatedRunTask( |
196 scoped_ptr<fileapi::FileSystemOperationContext> context, | 204 scoped_ptr<fileapi::FileSystemOperationContext> context, |
197 const AsyncFileUtil::CreateSnapshotFileCallback& callback, | 205 const AsyncFileUtil::CreateSnapshotFileCallback& callback, |
198 const fileapi::FileSystemURL& url, | 206 const fileapi::FileSystemURL& url, |
199 const base::FilePath& snapshot_file_path); | 207 const base::FilePath& snapshot_file_path); |
200 | 208 |
201 // Profile path. | 209 // Profile path. |
202 const base::FilePath profile_path_; | 210 const base::FilePath profile_path_; |
203 | 211 |
| 212 const MediaFileValidationType validation_type_; |
| 213 |
204 // For callbacks that may run after destruction. | 214 // For callbacks that may run after destruction. |
205 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_; | 215 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_; |
206 | 216 |
207 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil); | 217 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil); |
208 }; | 218 }; |
209 | 219 |
210 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H
_ | 220 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H
_ |
OLD | NEW |