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/native_file_util.h" | 25 #include "webkit/fileapi/native_file_util.h" |
25 | 26 |
| 27 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
| 28 #include "webkit/fileapi/media/device_media_file_util.h" |
| 29 #include "webkit/fileapi/media/media_device_map_service.h" |
| 30 #endif |
| 31 |
26 namespace fileapi { | 32 namespace fileapi { |
27 | 33 |
28 namespace { | 34 namespace { |
29 | 35 |
30 IsolatedContext* isolated_context() { | 36 IsolatedContext* isolated_context() { |
31 return IsolatedContext::GetInstance(); | 37 return IsolatedContext::GetInstance(); |
32 } | 38 } |
33 | 39 |
| 40 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
| 41 MediaDeviceInterfaceImpl* GetDeviceForUrl(const FileSystemURL& url, |
| 42 FileSystemContext* context) { |
| 43 return MediaDeviceMapService::GetInstance()->CreateOrGetMediaDevice( |
| 44 url.filesystem_id(), context->file_task_runner()); |
| 45 } |
| 46 #endif |
| 47 |
34 } // namespace | 48 } // namespace |
35 | 49 |
36 IsolatedMountPointProvider::IsolatedMountPointProvider() | 50 IsolatedMountPointProvider::IsolatedMountPointProvider( |
37 : isolated_file_util_(new IsolatedFileUtil()), | 51 const FilePath& profile_path) |
| 52 : profile_path_(profile_path), |
| 53 isolated_file_util_(new IsolatedFileUtil()), |
38 dragged_file_util_(new DraggedFileUtil()) { | 54 dragged_file_util_(new DraggedFileUtil()) { |
| 55 // TODO(kmadhusu): Initialize device_media_file_util_ in initialization list. |
| 56 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
| 57 device_media_file_util_.reset(new DeviceMediaFileUtil(profile_path_)); |
| 58 #endif |
39 } | 59 } |
40 | 60 |
41 IsolatedMountPointProvider::~IsolatedMountPointProvider() { | 61 IsolatedMountPointProvider::~IsolatedMountPointProvider() { |
42 } | 62 } |
43 | 63 |
44 void IsolatedMountPointProvider::ValidateFileSystemRoot( | 64 void IsolatedMountPointProvider::ValidateFileSystemRoot( |
45 const GURL& origin_url, | 65 const GURL& origin_url, |
46 FileSystemType type, | 66 FileSystemType type, |
47 bool create, | 67 bool create, |
48 const ValidateFileSystemCallback& callback) { | 68 const ValidateFileSystemCallback& callback) { |
(...skipping 22 matching lines...) Expand all Loading... |
71 const FilePath& filename) const { | 91 const FilePath& filename) const { |
72 // TODO(kinuko): We need to check platform-specific restricted file names | 92 // TODO(kinuko): We need to check platform-specific restricted file names |
73 // before we actually start allowing file creation in isolated file systems. | 93 // before we actually start allowing file creation in isolated file systems. |
74 return false; | 94 return false; |
75 } | 95 } |
76 | 96 |
77 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil( | 97 FileSystemFileUtil* IsolatedMountPointProvider::GetFileUtil( |
78 FileSystemType type) { | 98 FileSystemType type) { |
79 if (type == kFileSystemTypeDragged) | 99 if (type == kFileSystemTypeDragged) |
80 return dragged_file_util_.get(); | 100 return dragged_file_util_.get(); |
| 101 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
| 102 else if (type == kFileSystemTypeDeviceMedia) |
| 103 return device_media_file_util_.get(); |
| 104 #endif |
81 else | 105 else |
82 return isolated_file_util_.get(); | 106 return isolated_file_util_.get(); |
83 } | 107 } |
84 | 108 |
85 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck( | 109 FilePath IsolatedMountPointProvider::GetPathForPermissionsCheck( |
86 const FilePath& virtual_path) const { | 110 const FilePath& virtual_path) const { |
87 // For isolated filesystems we only check per-filesystem permissions. | 111 // For isolated filesystems we only check per-filesystem permissions. |
88 NOTREACHED(); | 112 NOTREACHED(); |
89 return virtual_path; | 113 return virtual_path; |
90 } | 114 } |
91 | 115 |
92 FileSystemOperationInterface* | 116 FileSystemOperationInterface* |
93 IsolatedMountPointProvider::CreateFileSystemOperation( | 117 IsolatedMountPointProvider::CreateFileSystemOperation( |
94 const FileSystemURL& url, | 118 const FileSystemURL& url, |
95 FileSystemContext* context) const { | 119 FileSystemContext* context) const { |
96 scoped_ptr<FileSystemOperationContext> operation_context( | 120 scoped_ptr<FileSystemOperationContext> operation_context( |
97 new FileSystemOperationContext(context)); | 121 new FileSystemOperationContext(context)); |
| 122 |
| 123 #if defined(SUPPORT_MEDIA_FILESYSTEM) |
| 124 if (url.type() == kFileSystemTypeDeviceMedia) { |
| 125 // GetDeviceForUrl can return NULL. We will handle in DeviceMediaFileUtil. |
| 126 operation_context->set_media_device(GetDeviceForUrl(url, context)); |
| 127 } |
| 128 #endif |
| 129 |
98 return new LocalFileSystemOperation(context, operation_context.Pass()); | 130 return new LocalFileSystemOperation(context, operation_context.Pass()); |
99 } | 131 } |
100 | 132 |
101 webkit_blob::FileStreamReader* | 133 webkit_blob::FileStreamReader* |
102 IsolatedMountPointProvider::CreateFileStreamReader( | 134 IsolatedMountPointProvider::CreateFileStreamReader( |
103 const FileSystemURL& url, | 135 const FileSystemURL& url, |
104 int64 offset, | 136 int64 offset, |
105 FileSystemContext* context) const { | 137 FileSystemContext* context) const { |
106 return new webkit_blob::LocalFileStreamReader( | 138 return new webkit_blob::LocalFileStreamReader( |
107 context->file_task_runner(), url.path(), offset, base::Time()); | 139 context->file_task_runner(), url.path(), offset, base::Time()); |
108 } | 140 } |
109 | 141 |
110 FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter( | 142 FileStreamWriter* IsolatedMountPointProvider::CreateFileStreamWriter( |
111 const FileSystemURL& url, | 143 const FileSystemURL& url, |
112 int64 offset, | 144 int64 offset, |
113 FileSystemContext* context) const { | 145 FileSystemContext* context) const { |
114 return new LocalFileStreamWriter(url.path(), offset); | 146 return new LocalFileStreamWriter(url.path(), offset); |
115 } | 147 } |
116 | 148 |
117 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { | 149 FileSystemQuotaUtil* IsolatedMountPointProvider::GetQuotaUtil() { |
118 // No quota support. | 150 // No quota support. |
119 return NULL; | 151 return NULL; |
120 } | 152 } |
121 | 153 |
122 } // namespace fileapi | 154 } // namespace fileapi |
OLD | NEW |