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_types.h" | 18 #include "webkit/fileapi/file_system_types.h" |
19 #include "webkit/fileapi/file_system_util.h" | 19 #include "webkit/fileapi/file_system_util.h" |
20 #include "webkit/fileapi/isolated_context.h" | 20 #include "webkit/fileapi/isolated_context.h" |
21 #include "webkit/fileapi/isolated_file_util.h" | 21 #include "webkit/fileapi/isolated_file_util.h" |
22 #include "webkit/fileapi/local_file_stream_writer.h" | 22 #include "webkit/fileapi/local_file_stream_writer.h" |
23 #include "webkit/fileapi/local_file_system_operation.h" | 23 #include "webkit/fileapi/local_file_system_operation.h" |
| 24 #include "webkit/fileapi/media/media_file_system_config.h" |
24 #include "webkit/fileapi/media/media_path_filter.h" | 25 #include "webkit/fileapi/media/media_path_filter.h" |
25 #include "webkit/fileapi/media/native_media_file_util.h" | 26 #include "webkit/fileapi/media/native_media_file_util.h" |
26 #include "webkit/fileapi/native_file_util.h" | 27 #include "webkit/fileapi/native_file_util.h" |
27 | 28 |
| 29 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
| 30 #include "webkit/fileapi/media/device_media_file_util.h" |
| 31 #include "webkit/fileapi/media/media_device_map_service.h" |
| 32 #endif |
| 33 |
28 namespace fileapi { | 34 namespace fileapi { |
29 | 35 |
30 namespace { | 36 namespace { |
31 | 37 |
32 IsolatedContext* isolated_context() { | 38 IsolatedContext* isolated_context() { |
33 return IsolatedContext::GetInstance(); | 39 return IsolatedContext::GetInstance(); |
34 } | 40 } |
35 | 41 |
| 42 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
| 43 MediaDeviceInterfaceImpl* GetDeviceForUrl(const FileSystemURL& url, |
| 44 FileSystemContext* context) { |
| 45 return MediaDeviceMapService::GetInstance()->CreateOrGetMediaDevice( |
| 46 url.filesystem_id(), context->file_task_runner()); |
| 47 } |
| 48 #endif |
| 49 |
36 } // namespace | 50 } // namespace |
37 | 51 |
38 IsolatedMountPointProvider::IsolatedMountPointProvider() | 52 IsolatedMountPointProvider::IsolatedMountPointProvider( |
39 : media_path_filter_(new MediaPathFilter()), | 53 const FilePath& profile_path) |
| 54 : profile_path_(profile_path), |
| 55 media_path_filter_(new MediaPathFilter()), |
40 isolated_file_util_(new IsolatedFileUtil()), | 56 isolated_file_util_(new IsolatedFileUtil()), |
41 dragged_file_util_(new DraggedFileUtil()), | 57 dragged_file_util_(new DraggedFileUtil()), |
42 native_media_file_util_(new NativeMediaFileUtil()) { | 58 native_media_file_util_(new NativeMediaFileUtil()) { |
| 59 // TODO(kmadhusu): Initialize device_media_file_util_ in initialization list. |
| 60 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
| 61 device_media_file_util_.reset(new DeviceMediaFileUtil(profile_path_)); |
| 62 #endif |
43 } | 63 } |
44 | 64 |
45 IsolatedMountPointProvider::~IsolatedMountPointProvider() { | 65 IsolatedMountPointProvider::~IsolatedMountPointProvider() { |
46 } | 66 } |
47 | 67 |
48 void IsolatedMountPointProvider::ValidateFileSystemRoot( | 68 void IsolatedMountPointProvider::ValidateFileSystemRoot( |
49 const GURL& origin_url, | 69 const GURL& origin_url, |
50 FileSystemType type, | 70 FileSystemType type, |
51 bool create, | 71 bool create, |
52 const ValidateFileSystemCallback& callback) { | 72 const ValidateFileSystemCallback& callback) { |
(...skipping 27 matching lines...) Expand all Loading... |
80 | 100 |
81 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil( | 101 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil( |
82 FileSystemType type) { | 102 FileSystemType type) { |
83 switch (type) { | 103 switch (type) { |
84 case kFileSystemTypeIsolated: | 104 case kFileSystemTypeIsolated: |
85 return isolated_file_util_.get(); | 105 return isolated_file_util_.get(); |
86 case kFileSystemTypeDragged: | 106 case kFileSystemTypeDragged: |
87 return dragged_file_util_.get(); | 107 return dragged_file_util_.get(); |
88 case kFileSystemTypeNativeMedia: | 108 case kFileSystemTypeNativeMedia: |
89 return native_media_file_util_.get(); | 109 return native_media_file_util_.get(); |
| 110 case kFileSystemTypeDeviceMedia: |
| 111 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
| 112 return device_media_file_util_.get(); |
| 113 #endif |
90 | 114 |
91 case kFileSystemTypeDeviceMedia: | |
92 case kFileSystemTypeTemporary: | 115 case kFileSystemTypeTemporary: |
93 case kFileSystemTypePersistent: | 116 case kFileSystemTypePersistent: |
94 case kFileSystemTypeExternal: | 117 case kFileSystemTypeExternal: |
95 case kFileSystemTypeTest: | 118 case kFileSystemTypeTest: |
96 case kFileSystemTypeUnknown: | 119 case kFileSystemTypeUnknown: |
97 NOTREACHED(); | 120 NOTREACHED(); |
98 } | 121 } |
99 return NULL; | 122 return NULL; |
100 } | 123 } |
101 | 124 |
102 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck( | 125 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck( |
103 const FilePath& virtual_path) const { | 126 const FilePath& virtual_path) const { |
104 // For isolated filesystems we only check per-filesystem permissions. | 127 // For isolated filesystems we only check per-filesystem permissions. |
105 NOTREACHED(); | 128 NOTREACHED(); |
106 return virtual_path; | 129 return virtual_path; |
107 } | 130 } |
108 | 131 |
109 FileSystemOperationInterface* | 132 FileSystemOperationInterface* |
110 IsolatedMountPointProvider::CreateFileSystemOperation( | 133 IsolatedMountPointProvider::CreateFileSystemOperation( |
111 const FileSystemURL& url, | 134 const FileSystemURL& url, |
112 FileSystemContext* context) const { | 135 FileSystemContext* context) const { |
113 scoped_ptr<FileSystemOperationContext> operation_context( | 136 scoped_ptr<FileSystemOperationContext> operation_context( |
114 new FileSystemOperationContext(context)); | 137 new FileSystemOperationContext(context)); |
115 if (url.type() == kFileSystemTypeNativeMedia || | 138 if (url.type() == kFileSystemTypeNativeMedia || |
116 url.type() == kFileSystemTypeDeviceMedia) | 139 url.type() == kFileSystemTypeDeviceMedia) |
117 operation_context->set_media_path_filter(media_path_filter_.get()); | 140 operation_context->set_media_path_filter(media_path_filter_.get()); |
| 141 |
| 142 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
| 143 if (url.type() == kFileSystemTypeDeviceMedia) { |
| 144 // GetDeviceForUrl can return NULL. We will handle in DeviceMediaFileUtil. |
| 145 operation_context->set_media_device(GetDeviceForUrl(url, context)); |
| 146 } |
| 147 #endif |
| 148 |
118 return new LocalFileSystemOperation(context, operation_context.Pass()); | 149 return new LocalFileSystemOperation(context, operation_context.Pass()); |
119 } | 150 } |
120 | 151 |
121 webkit_blob::FileStreamReader* | 152 webkit_blob::FileStreamReader* |
122 IsolatedMountPointProvider::CreateFileStreamReader( | 153 IsolatedMountPointProvider::CreateFileStreamReader( |
123 const FileSystemURL& url, | 154 const FileSystemURL& url, |
124 int64 offset, | 155 int64 offset, |
125 FileSystemContext* context) const { | 156 FileSystemContext* context) const { |
126 return new webkit_blob::LocalFileStreamReader( | 157 return new webkit_blob::LocalFileStreamReader( |
127 context->file_task_runner(), url.path(), offset, base::Time()); | 158 context->file_task_runner(), url.path(), offset, base::Time()); |
(...skipping 14 matching lines...) Expand all Loading... |
142 void IsolatedMountPointProvider::DeleteFileSystem( | 173 void IsolatedMountPointProvider::DeleteFileSystem( |
143 const GURL& origin_url, | 174 const GURL& origin_url, |
144 FileSystemType type, | 175 FileSystemType type, |
145 FileSystemContext* context, | 176 FileSystemContext* context, |
146 const DeleteFileSystemCallback& callback) { | 177 const DeleteFileSystemCallback& callback) { |
147 NOTREACHED(); | 178 NOTREACHED(); |
148 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); | 179 callback.Run(base::PLATFORM_FILE_ERROR_INVALID_OPERATION); |
149 } | 180 } |
150 | 181 |
151 } // namespace fileapi | 182 } // namespace fileapi |
OLD | NEW |