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 #include "webkit/fileapi/isolated_mount_point_provider.h" | 5 #include "webkit/fileapi/isolated_mount_point_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop_proxy.h" | 12 #include "base/message_loop_proxy.h" |
13 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
14 #include "webkit/blob/local_file_stream_reader.h" | 14 #include "webkit/blob/local_file_stream_reader.h" |
15 #include "webkit/fileapi/file_system_callback_dispatcher.h" | 15 #include "webkit/fileapi/file_system_callback_dispatcher.h" |
16 #include "webkit/fileapi/file_system_context.h" | 16 #include "webkit/fileapi/file_system_context.h" |
17 #include "webkit/fileapi/file_system_file_stream_reader.h" | 17 #include "webkit/fileapi/file_system_file_stream_reader.h" |
| 18 #include "webkit/fileapi/file_system_task_runners.h" |
18 #include "webkit/fileapi/file_system_types.h" | 19 #include "webkit/fileapi/file_system_types.h" |
19 #include "webkit/fileapi/file_system_util.h" | 20 #include "webkit/fileapi/file_system_util.h" |
20 #include "webkit/fileapi/isolated_context.h" | 21 #include "webkit/fileapi/isolated_context.h" |
21 #include "webkit/fileapi/isolated_file_util.h" | 22 #include "webkit/fileapi/isolated_file_util.h" |
22 #include "webkit/fileapi/local_file_stream_writer.h" | 23 #include "webkit/fileapi/local_file_stream_writer.h" |
23 #include "webkit/fileapi/local_file_system_operation.h" | 24 #include "webkit/fileapi/local_file_system_operation.h" |
24 #include "webkit/fileapi/media/media_file_system_config.h" | 25 #include "webkit/fileapi/media/media_file_system_config.h" |
25 #include "webkit/fileapi/media/media_path_filter.h" | 26 #include "webkit/fileapi/media/media_path_filter.h" |
26 #include "webkit/fileapi/media/native_media_file_util.h" | 27 #include "webkit/fileapi/media/native_media_file_util.h" |
27 #include "webkit/fileapi/native_file_util.h" | 28 #include "webkit/fileapi/native_file_util.h" |
28 | 29 |
29 #if defined(SUPPORT_MEDIA_FILESYSTEM) | 30 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
30 #include "webkit/fileapi/media/device_media_file_util.h" | 31 #include "webkit/fileapi/media/device_media_file_util.h" |
31 #include "webkit/fileapi/media/media_device_map_service.h" | 32 #include "webkit/fileapi/media/media_device_map_service.h" |
32 #endif | 33 #endif |
33 | 34 |
34 namespace fileapi { | 35 namespace fileapi { |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
38 IsolatedContext* isolated_context() { | 39 IsolatedContext* isolated_context() { |
39 return IsolatedContext::GetInstance(); | 40 return IsolatedContext::GetInstance(); |
40 } | 41 } |
41 | 42 |
42 #if defined(SUPPORT_MEDIA_FILESYSTEM) | 43 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
43 MediaDeviceInterfaceImpl* GetDeviceForUrl(const FileSystemURL& url, | 44 MediaDeviceInterfaceImpl* GetDeviceForUrl(const FileSystemURL& url, |
44 FileSystemContext* context) { | 45 FileSystemContext* context) { |
45 return MediaDeviceMapService::GetInstance()->CreateOrGetMediaDevice( | 46 return MediaDeviceMapService::GetInstance()->CreateOrGetMediaDevice( |
46 url.filesystem_id(), context->file_task_runner()); | 47 url.filesystem_id(), context->task_runners()->media_task_runner()); |
47 } | 48 } |
48 #endif | 49 #endif |
49 | 50 |
50 } // namespace | 51 } // namespace |
51 | 52 |
52 IsolatedMountPointProvider::IsolatedMountPointProvider( | 53 IsolatedMountPointProvider::IsolatedMountPointProvider( |
53 const FilePath& profile_path) | 54 const FilePath& profile_path) |
54 : profile_path_(profile_path), | 55 : profile_path_(profile_path), |
55 media_path_filter_(new MediaPathFilter()), | 56 media_path_filter_(new MediaPathFilter()), |
56 isolated_file_util_(new IsolatedFileUtil()), | 57 isolated_file_util_(new IsolatedFileUtil()), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 return virtual_path; | 130 return virtual_path; |
130 } | 131 } |
131 | 132 |
132 FileSystemOperationInterface* | 133 FileSystemOperationInterface* |
133 IsolatedMountPointProvider::CreateFileSystemOperation( | 134 IsolatedMountPointProvider::CreateFileSystemOperation( |
134 const FileSystemURL& url, | 135 const FileSystemURL& url, |
135 FileSystemContext* context) const { | 136 FileSystemContext* context) const { |
136 scoped_ptr<FileSystemOperationContext> operation_context( | 137 scoped_ptr<FileSystemOperationContext> operation_context( |
137 new FileSystemOperationContext(context)); | 138 new FileSystemOperationContext(context)); |
138 if (url.type() == kFileSystemTypeNativeMedia || | 139 if (url.type() == kFileSystemTypeNativeMedia || |
139 url.type() == kFileSystemTypeDeviceMedia) | 140 url.type() == kFileSystemTypeDeviceMedia) { |
140 operation_context->set_media_path_filter(media_path_filter_.get()); | 141 operation_context->set_media_path_filter(media_path_filter_.get()); |
| 142 operation_context->SetTaskRunner( |
| 143 context->task_runners()->media_task_runner()); |
| 144 } |
141 | 145 |
142 #if defined(SUPPORT_MEDIA_FILESYSTEM) | 146 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
143 if (url.type() == kFileSystemTypeDeviceMedia) { | 147 if (url.type() == kFileSystemTypeDeviceMedia) { |
144 // GetDeviceForUrl can return NULL. We will handle in DeviceMediaFileUtil. | 148 // GetDeviceForUrl can return NULL. We will handle in DeviceMediaFileUtil. |
145 operation_context->set_media_device(GetDeviceForUrl(url, context)); | 149 operation_context->set_media_device(GetDeviceForUrl(url, context)); |
146 } | 150 } |
147 #endif | 151 #endif |
148 | 152 |
149 return new LocalFileSystemOperation(context, operation_context.Pass()); | 153 return new LocalFileSystemOperation(context, operation_context.Pass()); |
150 } | 154 } |
151 | 155 |
152 webkit_blob::FileStreamReader* | 156 webkit_blob::FileStreamReader* |
153 IsolatedMountPointProvider::CreateFileStreamReader( | 157 IsolatedMountPointProvider::CreateFileStreamReader( |
154 const FileSystemURL& url, | 158 const FileSystemURL& url, |
155 int64 offset, | 159 int64 offset, |
156 FileSystemContext* context) const { | 160 FileSystemContext* context) const { |
157 return new webkit_blob::LocalFileStreamReader( | 161 return new webkit_blob::LocalFileStreamReader( |
158 context->file_task_runner(), url.path(), offset, base::Time()); | 162 context->task_runners()->file_task_runner(), |
| 163 url.path(), offset, base::Time()); |
159 } | 164 } |
160 | 165 |
161 FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter( | 166 FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter( |
162 const FileSystemURL& url, | 167 const FileSystemURL& url, |
163 int64 offset, | 168 int64 offset, |
164 FileSystemContext* context) const { | 169 FileSystemContext* context) const { |
165 return new LocalFileStreamWriter(url.path(), offset); | 170 return new LocalFileStreamWriter(url.path(), offset); |
166 } | 171 } |
167 | 172 |
168 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { | 173 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { |
169 // No quota support. | 174 // No quota support. |
170 return NULL; | 175 return NULL; |
171 } | 176 } |
172 | 177 |
173 void IsolatedMountPointProvider::DeleteFileSystem( | 178 void IsolatedMountPointProvider::DeleteFileSystem( |
174 const GURL& origin_url, | 179 const GURL& origin_url, |
175 FileSystemType type, | 180 FileSystemType type, |
176 FileSystemContext* context, | 181 FileSystemContext* context, |
177 const DeleteFileSystemCallback& callback) { | 182 const DeleteFileSystemCallback& callback) { |
178 NOTREACHED(); | 183 NOTREACHED(); |
179 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 184 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
180 } | 185 } |
181 | 186 |
182 } // namespace fileapi | 187 } // namespace fileapi |
OLD | NEW |