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/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "webkit/browser/fileapi/async_file_util.h" | 13 #include "storage/browser/fileapi/async_file_util.h" |
14 #include "webkit/common/blob/shareable_file_reference.h" | 14 #include "storage/common/blob/shareable_file_reference.h" |
15 | 15 |
16 namespace fileapi { | 16 namespace storage { |
17 class FileSystemOperationContext; | 17 class FileSystemOperationContext; |
18 class FileSystemURL; | 18 class FileSystemURL; |
19 } | 19 } |
20 | 20 |
21 namespace webkit_blob { | 21 namespace storage { |
22 class FileStreamReader; | 22 class FileStreamReader; |
23 } | 23 } |
24 | 24 |
25 enum MediaFileValidationType { | 25 enum MediaFileValidationType { |
26 NO_MEDIA_FILE_VALIDATION, | 26 NO_MEDIA_FILE_VALIDATION, |
27 APPLY_MEDIA_FILE_VALIDATION, | 27 APPLY_MEDIA_FILE_VALIDATION, |
28 }; | 28 }; |
29 | 29 |
30 class DeviceMediaAsyncFileUtil : public fileapi::AsyncFileUtil { | 30 class DeviceMediaAsyncFileUtil : public storage::AsyncFileUtil { |
31 public: | 31 public: |
32 virtual ~DeviceMediaAsyncFileUtil(); | 32 virtual ~DeviceMediaAsyncFileUtil(); |
33 | 33 |
34 // Returns an instance of DeviceMediaAsyncFileUtil. | 34 // Returns an instance of DeviceMediaAsyncFileUtil. |
35 static scoped_ptr<DeviceMediaAsyncFileUtil> Create( | 35 static scoped_ptr<DeviceMediaAsyncFileUtil> Create( |
36 const base::FilePath& profile_path, | 36 const base::FilePath& profile_path, |
37 MediaFileValidationType validation_type); | 37 MediaFileValidationType validation_type); |
38 | 38 |
39 bool SupportsStreaming(const fileapi::FileSystemURL& url); | 39 bool SupportsStreaming(const storage::FileSystemURL& url); |
40 | 40 |
41 // AsyncFileUtil overrides. | 41 // AsyncFileUtil overrides. |
42 virtual void CreateOrOpen( | 42 virtual void CreateOrOpen( |
43 scoped_ptr<fileapi::FileSystemOperationContext> context, | 43 scoped_ptr<storage::FileSystemOperationContext> context, |
44 const fileapi::FileSystemURL& url, | 44 const storage::FileSystemURL& url, |
45 int file_flags, | 45 int file_flags, |
46 const CreateOrOpenCallback& callback) OVERRIDE; | 46 const CreateOrOpenCallback& callback) OVERRIDE; |
47 virtual void EnsureFileExists( | 47 virtual void EnsureFileExists( |
48 scoped_ptr<fileapi::FileSystemOperationContext> context, | 48 scoped_ptr<storage::FileSystemOperationContext> context, |
49 const fileapi::FileSystemURL& url, | 49 const storage::FileSystemURL& url, |
50 const EnsureFileExistsCallback& callback) OVERRIDE; | 50 const EnsureFileExistsCallback& callback) OVERRIDE; |
51 virtual void CreateDirectory( | 51 virtual void CreateDirectory( |
52 scoped_ptr<fileapi::FileSystemOperationContext> context, | 52 scoped_ptr<storage::FileSystemOperationContext> context, |
53 const fileapi::FileSystemURL& url, | 53 const storage::FileSystemURL& url, |
54 bool exclusive, | 54 bool exclusive, |
55 bool recursive, | 55 bool recursive, |
56 const StatusCallback& callback) OVERRIDE; | 56 const StatusCallback& callback) OVERRIDE; |
57 virtual void GetFileInfo( | 57 virtual void GetFileInfo( |
58 scoped_ptr<fileapi::FileSystemOperationContext> context, | 58 scoped_ptr<storage::FileSystemOperationContext> context, |
59 const fileapi::FileSystemURL& url, | 59 const storage::FileSystemURL& url, |
60 const GetFileInfoCallback& callback) OVERRIDE; | 60 const GetFileInfoCallback& callback) OVERRIDE; |
61 virtual void ReadDirectory( | 61 virtual void ReadDirectory( |
62 scoped_ptr<fileapi::FileSystemOperationContext> context, | 62 scoped_ptr<storage::FileSystemOperationContext> context, |
63 const fileapi::FileSystemURL& url, | 63 const storage::FileSystemURL& url, |
64 const ReadDirectoryCallback& callback) OVERRIDE; | 64 const ReadDirectoryCallback& callback) OVERRIDE; |
65 virtual void Touch( | 65 virtual void Touch(scoped_ptr<storage::FileSystemOperationContext> context, |
66 scoped_ptr<fileapi::FileSystemOperationContext> context, | 66 const storage::FileSystemURL& url, |
67 const fileapi::FileSystemURL& url, | 67 const base::Time& last_access_time, |
68 const base::Time& last_access_time, | 68 const base::Time& last_modified_time, |
69 const base::Time& last_modified_time, | 69 const StatusCallback& callback) OVERRIDE; |
70 const StatusCallback& callback) OVERRIDE; | 70 virtual void Truncate(scoped_ptr<storage::FileSystemOperationContext> context, |
71 virtual void Truncate( | 71 const storage::FileSystemURL& url, |
72 scoped_ptr<fileapi::FileSystemOperationContext> context, | 72 int64 length, |
73 const fileapi::FileSystemURL& url, | 73 const StatusCallback& callback) OVERRIDE; |
74 int64 length, | |
75 const StatusCallback& callback) OVERRIDE; | |
76 virtual void CopyFileLocal( | 74 virtual void CopyFileLocal( |
77 scoped_ptr<fileapi::FileSystemOperationContext> context, | 75 scoped_ptr<storage::FileSystemOperationContext> context, |
78 const fileapi::FileSystemURL& src_url, | 76 const storage::FileSystemURL& src_url, |
79 const fileapi::FileSystemURL& dest_url, | 77 const storage::FileSystemURL& dest_url, |
80 CopyOrMoveOption option, | 78 CopyOrMoveOption option, |
81 const CopyFileProgressCallback& progress_callback, | 79 const CopyFileProgressCallback& progress_callback, |
82 const StatusCallback& callback) OVERRIDE; | 80 const StatusCallback& callback) OVERRIDE; |
83 virtual void MoveFileLocal( | 81 virtual void MoveFileLocal( |
84 scoped_ptr<fileapi::FileSystemOperationContext> context, | 82 scoped_ptr<storage::FileSystemOperationContext> context, |
85 const fileapi::FileSystemURL& src_url, | 83 const storage::FileSystemURL& src_url, |
86 const fileapi::FileSystemURL& dest_url, | 84 const storage::FileSystemURL& dest_url, |
87 CopyOrMoveOption option, | 85 CopyOrMoveOption option, |
88 const StatusCallback& callback) OVERRIDE; | 86 const StatusCallback& callback) OVERRIDE; |
89 virtual void CopyInForeignFile( | 87 virtual void CopyInForeignFile( |
90 scoped_ptr<fileapi::FileSystemOperationContext> context, | 88 scoped_ptr<storage::FileSystemOperationContext> context, |
91 const base::FilePath& src_file_path, | 89 const base::FilePath& src_file_path, |
92 const fileapi::FileSystemURL& dest_url, | 90 const storage::FileSystemURL& dest_url, |
93 const StatusCallback& callback) OVERRIDE; | 91 const StatusCallback& callback) OVERRIDE; |
94 virtual void DeleteFile( | 92 virtual void DeleteFile( |
95 scoped_ptr<fileapi::FileSystemOperationContext> context, | 93 scoped_ptr<storage::FileSystemOperationContext> context, |
96 const fileapi::FileSystemURL& url, | 94 const storage::FileSystemURL& url, |
97 const StatusCallback& callback) OVERRIDE; | 95 const StatusCallback& callback) OVERRIDE; |
98 virtual void DeleteDirectory( | 96 virtual void DeleteDirectory( |
99 scoped_ptr<fileapi::FileSystemOperationContext> context, | 97 scoped_ptr<storage::FileSystemOperationContext> context, |
100 const fileapi::FileSystemURL& url, | 98 const storage::FileSystemURL& url, |
101 const StatusCallback& callback) OVERRIDE; | 99 const StatusCallback& callback) OVERRIDE; |
102 virtual void DeleteRecursively( | 100 virtual void DeleteRecursively( |
103 scoped_ptr<fileapi::FileSystemOperationContext> context, | 101 scoped_ptr<storage::FileSystemOperationContext> context, |
104 const fileapi::FileSystemURL& url, | 102 const storage::FileSystemURL& url, |
105 const StatusCallback& callback) OVERRIDE; | 103 const StatusCallback& callback) OVERRIDE; |
106 virtual void CreateSnapshotFile( | 104 virtual void CreateSnapshotFile( |
107 scoped_ptr<fileapi::FileSystemOperationContext> context, | 105 scoped_ptr<storage::FileSystemOperationContext> context, |
108 const fileapi::FileSystemURL& url, | 106 const storage::FileSystemURL& url, |
109 const CreateSnapshotFileCallback& callback) OVERRIDE; | 107 const CreateSnapshotFileCallback& callback) OVERRIDE; |
110 | 108 |
111 // This method is called when existing Blobs are read. | 109 // This method is called when existing Blobs are read. |
112 // |expected_modification_time| indicates the expected snapshot state of the | 110 // |expected_modification_time| indicates the expected snapshot state of the |
113 // underlying storage. The returned FileStreamReader must return an error | 111 // underlying storage. The returned FileStreamReader must return an error |
114 // when the state of the underlying storage changes. Any errors associated | 112 // when the state of the underlying storage changes. Any errors associated |
115 // with reading this file are returned by the FileStreamReader itself. | 113 // with reading this file are returned by the FileStreamReader itself. |
116 virtual scoped_ptr<webkit_blob::FileStreamReader> GetFileStreamReader( | 114 virtual scoped_ptr<storage::FileStreamReader> GetFileStreamReader( |
117 const fileapi::FileSystemURL& url, | 115 const storage::FileSystemURL& url, |
118 int64 offset, | 116 int64 offset, |
119 const base::Time& expected_modification_time, | 117 const base::Time& expected_modification_time, |
120 fileapi::FileSystemContext* context); | 118 storage::FileSystemContext* context); |
121 | 119 |
122 private: | 120 private: |
123 class MediaPathFilterWrapper; | 121 class MediaPathFilterWrapper; |
124 | 122 |
125 // Use Create() to get an instance of DeviceMediaAsyncFileUtil. | 123 // Use Create() to get an instance of DeviceMediaAsyncFileUtil. |
126 DeviceMediaAsyncFileUtil(const base::FilePath& profile_path, | 124 DeviceMediaAsyncFileUtil(const base::FilePath& profile_path, |
127 MediaFileValidationType validation_type); | 125 MediaFileValidationType validation_type); |
128 | 126 |
129 // Called when GetFileInfo method call succeeds. |file_info| contains the | 127 // Called when GetFileInfo method call succeeds. |file_info| contains the |
130 // file details of the requested url. |callback| is invoked to complete the | 128 // file details of the requested url. |callback| is invoked to complete the |
(...skipping 28 matching lines...) Expand all Loading... |
159 | 157 |
160 scoped_refptr<MediaPathFilterWrapper> media_path_filter_wrapper_; | 158 scoped_refptr<MediaPathFilterWrapper> media_path_filter_wrapper_; |
161 | 159 |
162 // For callbacks that may run after destruction. | 160 // For callbacks that may run after destruction. |
163 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_; | 161 base::WeakPtrFactory<DeviceMediaAsyncFileUtil> weak_ptr_factory_; |
164 | 162 |
165 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil); | 163 DISALLOW_COPY_AND_ASSIGN(DeviceMediaAsyncFileUtil); |
166 }; | 164 }; |
167 | 165 |
168 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H
_ | 166 #endif // CHROME_BROWSER_MEDIA_GALLERIES_FILEAPI_DEVICE_MEDIA_ASYNC_FILE_UTIL_H
_ |
OLD | NEW |