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