OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chrome/browser/chromeos/fileapi/cros_mount_point_provider.h" | 5 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
14 #include "chrome/browser/chromeos/fileapi/cros_mount_point_provider_delegate.h" | |
15 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" | 14 #include "chrome/browser/chromeos/fileapi/file_access_permissions.h" |
| 15 #include "chrome/browser/chromeos/fileapi/file_system_backend_delegate.h" |
16 #include "chromeos/dbus/cros_disks_client.h" | 16 #include "chromeos/dbus/cros_disks_client.h" |
17 #include "webkit/browser/blob/file_stream_reader.h" | 17 #include "webkit/browser/blob/file_stream_reader.h" |
18 #include "webkit/browser/fileapi/async_file_util_adapter.h" | 18 #include "webkit/browser/fileapi/async_file_util_adapter.h" |
19 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" | 19 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" |
20 #include "webkit/browser/fileapi/external_mount_points.h" | 20 #include "webkit/browser/fileapi/external_mount_points.h" |
21 #include "webkit/browser/fileapi/file_system_context.h" | 21 #include "webkit/browser/fileapi/file_system_context.h" |
22 #include "webkit/browser/fileapi/file_system_file_stream_reader.h" | 22 #include "webkit/browser/fileapi/file_system_file_stream_reader.h" |
23 #include "webkit/browser/fileapi/file_system_operation_context.h" | 23 #include "webkit/browser/fileapi/file_system_operation_context.h" |
24 #include "webkit/browser/fileapi/file_system_task_runners.h" | 24 #include "webkit/browser/fileapi/file_system_task_runners.h" |
25 #include "webkit/browser/fileapi/file_system_url.h" | 25 #include "webkit/browser/fileapi/file_system_url.h" |
26 #include "webkit/browser/fileapi/isolated_context.h" | 26 #include "webkit/browser/fileapi/isolated_context.h" |
27 #include "webkit/browser/fileapi/isolated_file_util.h" | 27 #include "webkit/browser/fileapi/isolated_file_util.h" |
28 #include "webkit/browser/fileapi/local_file_stream_writer.h" | 28 #include "webkit/browser/fileapi/local_file_stream_writer.h" |
29 #include "webkit/browser/fileapi/local_file_system_operation.h" | 29 #include "webkit/browser/fileapi/local_file_system_operation.h" |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 const char kChromeUIScheme[] = "chrome"; | 33 const char kChromeUIScheme[] = "chrome"; |
34 | 34 |
35 } // namespace | 35 } // namespace |
36 | 36 |
37 namespace chromeos { | 37 namespace chromeos { |
38 | 38 |
39 // static | 39 // static |
40 bool CrosMountPointProvider::CanHandleURL(const fileapi::FileSystemURL& url) { | 40 bool FileSystemBackend::CanHandleURL(const fileapi::FileSystemURL& url) { |
41 if (!url.is_valid()) | 41 if (!url.is_valid()) |
42 return false; | 42 return false; |
43 return url.type() == fileapi::kFileSystemTypeNativeLocal || | 43 return url.type() == fileapi::kFileSystemTypeNativeLocal || |
44 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal || | 44 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal || |
45 url.type() == fileapi::kFileSystemTypeDrive; | 45 url.type() == fileapi::kFileSystemTypeDrive; |
46 } | 46 } |
47 | 47 |
48 CrosMountPointProvider::CrosMountPointProvider( | 48 FileSystemBackend::FileSystemBackend( |
49 CrosMountPointProviderDelegate* drive_delegate, | 49 FileSystemBackendDelegate* drive_delegate, |
50 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, | 50 scoped_refptr<quota::SpecialStoragePolicy> special_storage_policy, |
51 scoped_refptr<fileapi::ExternalMountPoints> mount_points, | 51 scoped_refptr<fileapi::ExternalMountPoints> mount_points, |
52 fileapi::ExternalMountPoints* system_mount_points) | 52 fileapi::ExternalMountPoints* system_mount_points) |
53 : special_storage_policy_(special_storage_policy), | 53 : special_storage_policy_(special_storage_policy), |
54 file_access_permissions_(new FileAccessPermissions()), | 54 file_access_permissions_(new FileAccessPermissions()), |
55 local_file_util_(new fileapi::AsyncFileUtilAdapter( | 55 local_file_util_(new fileapi::AsyncFileUtilAdapter( |
56 new fileapi::IsolatedFileUtil())), | 56 new fileapi::IsolatedFileUtil())), |
57 drive_delegate_(drive_delegate), | 57 drive_delegate_(drive_delegate), |
58 mount_points_(mount_points), | 58 mount_points_(mount_points), |
59 system_mount_points_(system_mount_points) { | 59 system_mount_points_(system_mount_points) { |
60 } | 60 } |
61 | 61 |
62 CrosMountPointProvider::~CrosMountPointProvider() { | 62 FileSystemBackend::~FileSystemBackend() { |
63 } | 63 } |
64 | 64 |
65 void CrosMountPointProvider::AddSystemMountPoints() { | 65 void FileSystemBackend::AddSystemMountPoints() { |
66 // RegisterFileSystem() is no-op if the mount point with the same name | 66 // RegisterFileSystem() is no-op if the mount point with the same name |
67 // already exists, hence it's safe to call without checking if a mount | 67 // already exists, hence it's safe to call without checking if a mount |
68 // point already exists or not. | 68 // point already exists or not. |
69 | 69 |
70 // TODO(satorux): "Downloads" directory should probably be per-profile. For | 70 // TODO(satorux): "Downloads" directory should probably be per-profile. For |
71 // this to be per-profile, a unique directory path should be chosen per | 71 // this to be per-profile, a unique directory path should be chosen per |
72 // profile, and the mount point should be added to | 72 // profile, and the mount point should be added to |
73 // mount_points_. crbug.com/247236 | 73 // mount_points_. crbug.com/247236 |
74 base::FilePath home_path; | 74 base::FilePath home_path; |
75 if (PathService::Get(base::DIR_HOME, &home_path)) { | 75 if (PathService::Get(base::DIR_HOME, &home_path)) { |
(...skipping 10 matching lines...) Expand all Loading... |
86 system_mount_points_->RegisterFileSystem( | 86 system_mount_points_->RegisterFileSystem( |
87 "removable", | 87 "removable", |
88 fileapi::kFileSystemTypeNativeLocal, | 88 fileapi::kFileSystemTypeNativeLocal, |
89 chromeos::CrosDisksClient::GetRemovableDiskMountPoint()); | 89 chromeos::CrosDisksClient::GetRemovableDiskMountPoint()); |
90 system_mount_points_->RegisterFileSystem( | 90 system_mount_points_->RegisterFileSystem( |
91 "oem", | 91 "oem", |
92 fileapi::kFileSystemTypeRestrictedNativeLocal, | 92 fileapi::kFileSystemTypeRestrictedNativeLocal, |
93 base::FilePath(FILE_PATH_LITERAL("/usr/share/oem"))); | 93 base::FilePath(FILE_PATH_LITERAL("/usr/share/oem"))); |
94 } | 94 } |
95 | 95 |
96 bool CrosMountPointProvider::CanHandleType(fileapi::FileSystemType type) const { | 96 bool FileSystemBackend::CanHandleType(fileapi::FileSystemType type) const { |
97 switch (type) { | 97 switch (type) { |
98 case fileapi::kFileSystemTypeExternal: | 98 case fileapi::kFileSystemTypeExternal: |
99 case fileapi::kFileSystemTypeDrive: | 99 case fileapi::kFileSystemTypeDrive: |
100 case fileapi::kFileSystemTypeRestrictedNativeLocal: | 100 case fileapi::kFileSystemTypeRestrictedNativeLocal: |
101 case fileapi::kFileSystemTypeNativeLocal: | 101 case fileapi::kFileSystemTypeNativeLocal: |
102 case fileapi::kFileSystemTypeNativeForPlatformApp: | 102 case fileapi::kFileSystemTypeNativeForPlatformApp: |
103 return true; | 103 return true; |
104 default: | 104 default: |
105 return false; | 105 return false; |
106 } | 106 } |
107 } | 107 } |
108 | 108 |
109 void CrosMountPointProvider::OpenFileSystem( | 109 void FileSystemBackend::OpenFileSystem( |
110 const GURL& origin_url, | 110 const GURL& origin_url, |
111 fileapi::FileSystemType type, | 111 fileapi::FileSystemType type, |
112 fileapi::OpenFileSystemMode mode, | 112 fileapi::OpenFileSystemMode mode, |
113 const OpenFileSystemCallback& callback) { | 113 const OpenFileSystemCallback& callback) { |
114 DCHECK(fileapi::IsolatedContext::IsIsolatedType(type)); | 114 DCHECK(fileapi::IsolatedContext::IsIsolatedType(type)); |
115 // Nothing to validate for external filesystem. | 115 // Nothing to validate for external filesystem. |
116 callback.Run(base::PLATFORM_FILE_OK); | 116 callback.Run(base::PLATFORM_FILE_OK); |
117 } | 117 } |
118 | 118 |
119 fileapi::FileSystemQuotaUtil* CrosMountPointProvider::GetQuotaUtil() { | 119 fileapi::FileSystemQuotaUtil* FileSystemBackend::GetQuotaUtil() { |
120 // No quota support. | 120 // No quota support. |
121 return NULL; | 121 return NULL; |
122 } | 122 } |
123 | 123 |
124 bool CrosMountPointProvider::IsAccessAllowed( | 124 bool FileSystemBackend::IsAccessAllowed( |
125 const fileapi::FileSystemURL& url) const { | 125 const fileapi::FileSystemURL& url) const { |
126 if (!url.is_valid()) | 126 if (!url.is_valid()) |
127 return false; | 127 return false; |
128 | 128 |
129 // Permit access to mount points from internal WebUI. | 129 // Permit access to mount points from internal WebUI. |
130 const GURL& origin_url = url.origin(); | 130 const GURL& origin_url = url.origin(); |
131 if (origin_url.SchemeIs(kChromeUIScheme)) | 131 if (origin_url.SchemeIs(kChromeUIScheme)) |
132 return true; | 132 return true; |
133 | 133 |
134 // No extra check is needed for isolated file systems. | 134 // No extra check is needed for isolated file systems. |
135 if (url.mount_type() == fileapi::kFileSystemTypeIsolated) | 135 if (url.mount_type() == fileapi::kFileSystemTypeIsolated) |
136 return true; | 136 return true; |
137 | 137 |
138 if (!CanHandleURL(url)) | 138 if (!CanHandleURL(url)) |
139 return false; | 139 return false; |
140 | 140 |
141 std::string extension_id = origin_url.host(); | 141 std::string extension_id = origin_url.host(); |
142 // Check first to make sure this extension has fileBrowserHander permissions. | 142 // Check first to make sure this extension has fileBrowserHander permissions. |
143 if (!special_storage_policy_->IsFileHandler(extension_id)) | 143 if (!special_storage_policy_->IsFileHandler(extension_id)) |
144 return false; | 144 return false; |
145 | 145 |
146 return file_access_permissions_->HasAccessPermission(extension_id, | 146 return file_access_permissions_->HasAccessPermission(extension_id, |
147 url.virtual_path()); | 147 url.virtual_path()); |
148 } | 148 } |
149 | 149 |
150 void CrosMountPointProvider::GrantFullAccessToExtension( | 150 void FileSystemBackend::GrantFullAccessToExtension( |
151 const std::string& extension_id) { | 151 const std::string& extension_id) { |
152 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); | 152 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); |
153 if (!special_storage_policy_->IsFileHandler(extension_id)) | 153 if (!special_storage_policy_->IsFileHandler(extension_id)) |
154 return; | 154 return; |
155 | 155 |
156 std::vector<fileapi::MountPoints::MountPointInfo> files; | 156 std::vector<fileapi::MountPoints::MountPointInfo> files; |
157 mount_points_->AddMountPointInfosTo(&files); | 157 mount_points_->AddMountPointInfosTo(&files); |
158 system_mount_points_->AddMountPointInfosTo(&files); | 158 system_mount_points_->AddMountPointInfosTo(&files); |
159 | 159 |
160 for (size_t i = 0; i < files.size(); ++i) { | 160 for (size_t i = 0; i < files.size(); ++i) { |
161 file_access_permissions_->GrantAccessPermission( | 161 file_access_permissions_->GrantAccessPermission( |
162 extension_id, | 162 extension_id, |
163 base::FilePath::FromUTF8Unsafe(files[i].name)); | 163 base::FilePath::FromUTF8Unsafe(files[i].name)); |
164 } | 164 } |
165 } | 165 } |
166 | 166 |
167 void CrosMountPointProvider::GrantFileAccessToExtension( | 167 void FileSystemBackend::GrantFileAccessToExtension( |
168 const std::string& extension_id, const base::FilePath& virtual_path) { | 168 const std::string& extension_id, const base::FilePath& virtual_path) { |
169 // All we care about here is access from extensions for now. | 169 // All we care about here is access from extensions for now. |
170 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); | 170 DCHECK(special_storage_policy_->IsFileHandler(extension_id)); |
171 if (!special_storage_policy_->IsFileHandler(extension_id)) | 171 if (!special_storage_policy_->IsFileHandler(extension_id)) |
172 return; | 172 return; |
173 | 173 |
174 std::string id; | 174 std::string id; |
175 fileapi::FileSystemType type; | 175 fileapi::FileSystemType type; |
176 base::FilePath path; | 176 base::FilePath path; |
177 if (!mount_points_->CrackVirtualPath(virtual_path, &id, &type, &path) && | 177 if (!mount_points_->CrackVirtualPath(virtual_path, &id, &type, &path) && |
178 !system_mount_points_->CrackVirtualPath(virtual_path, | 178 !system_mount_points_->CrackVirtualPath(virtual_path, |
179 &id, &type, &path)) { | 179 &id, &type, &path)) { |
180 return; | 180 return; |
181 } | 181 } |
182 | 182 |
183 if (type == fileapi::kFileSystemTypeRestrictedNativeLocal) { | 183 if (type == fileapi::kFileSystemTypeRestrictedNativeLocal) { |
184 LOG(ERROR) << "Can't grant access for restricted mount point"; | 184 LOG(ERROR) << "Can't grant access for restricted mount point"; |
185 return; | 185 return; |
186 } | 186 } |
187 | 187 |
188 file_access_permissions_->GrantAccessPermission(extension_id, virtual_path); | 188 file_access_permissions_->GrantAccessPermission(extension_id, virtual_path); |
189 } | 189 } |
190 | 190 |
191 void CrosMountPointProvider::RevokeAccessForExtension( | 191 void FileSystemBackend::RevokeAccessForExtension( |
192 const std::string& extension_id) { | 192 const std::string& extension_id) { |
193 file_access_permissions_->RevokePermissions(extension_id); | 193 file_access_permissions_->RevokePermissions(extension_id); |
194 } | 194 } |
195 | 195 |
196 std::vector<base::FilePath> CrosMountPointProvider::GetRootDirectories() const { | 196 std::vector<base::FilePath> FileSystemBackend::GetRootDirectories() const { |
197 std::vector<fileapi::MountPoints::MountPointInfo> mount_points; | 197 std::vector<fileapi::MountPoints::MountPointInfo> mount_points; |
198 mount_points_->AddMountPointInfosTo(&mount_points); | 198 mount_points_->AddMountPointInfosTo(&mount_points); |
199 system_mount_points_->AddMountPointInfosTo(&mount_points); | 199 system_mount_points_->AddMountPointInfosTo(&mount_points); |
200 | 200 |
201 std::vector<base::FilePath> root_dirs; | 201 std::vector<base::FilePath> root_dirs; |
202 for (size_t i = 0; i < mount_points.size(); ++i) | 202 for (size_t i = 0; i < mount_points.size(); ++i) |
203 root_dirs.push_back(mount_points[i].path); | 203 root_dirs.push_back(mount_points[i].path); |
204 return root_dirs; | 204 return root_dirs; |
205 } | 205 } |
206 | 206 |
207 fileapi::FileSystemFileUtil* CrosMountPointProvider::GetFileUtil( | 207 fileapi::FileSystemFileUtil* FileSystemBackend::GetFileUtil( |
208 fileapi::FileSystemType type) { | 208 fileapi::FileSystemType type) { |
209 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || | 209 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || |
210 type == fileapi::kFileSystemTypeRestrictedNativeLocal); | 210 type == fileapi::kFileSystemTypeRestrictedNativeLocal); |
211 return local_file_util_->sync_file_util(); | 211 return local_file_util_->sync_file_util(); |
212 } | 212 } |
213 | 213 |
214 fileapi::AsyncFileUtil* CrosMountPointProvider::GetAsyncFileUtil( | 214 fileapi::AsyncFileUtil* FileSystemBackend::GetAsyncFileUtil( |
215 fileapi::FileSystemType type) { | 215 fileapi::FileSystemType type) { |
216 if (type == fileapi::kFileSystemTypeDrive) | 216 if (type == fileapi::kFileSystemTypeDrive) |
217 return drive_delegate_->GetAsyncFileUtil(type); | 217 return drive_delegate_->GetAsyncFileUtil(type); |
218 | 218 |
219 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || | 219 DCHECK(type == fileapi::kFileSystemTypeNativeLocal || |
220 type == fileapi::kFileSystemTypeRestrictedNativeLocal); | 220 type == fileapi::kFileSystemTypeRestrictedNativeLocal); |
221 return local_file_util_.get(); | 221 return local_file_util_.get(); |
222 } | 222 } |
223 | 223 |
224 fileapi::CopyOrMoveFileValidatorFactory* | 224 fileapi::CopyOrMoveFileValidatorFactory* |
225 CrosMountPointProvider::GetCopyOrMoveFileValidatorFactory( | 225 FileSystemBackend::GetCopyOrMoveFileValidatorFactory( |
226 fileapi::FileSystemType type, base::PlatformFileError* error_code) { | 226 fileapi::FileSystemType type, base::PlatformFileError* error_code) { |
227 DCHECK(error_code); | 227 DCHECK(error_code); |
228 *error_code = base::PLATFORM_FILE_OK; | 228 *error_code = base::PLATFORM_FILE_OK; |
229 return NULL; | 229 return NULL; |
230 } | 230 } |
231 | 231 |
232 fileapi::FileSystemOperation* CrosMountPointProvider::CreateFileSystemOperation( | 232 fileapi::FileSystemOperation* FileSystemBackend::CreateFileSystemOperation( |
233 const fileapi::FileSystemURL& url, | 233 const fileapi::FileSystemURL& url, |
234 fileapi::FileSystemContext* context, | 234 fileapi::FileSystemContext* context, |
235 base::PlatformFileError* error_code) const { | 235 base::PlatformFileError* error_code) const { |
236 DCHECK(url.is_valid()); | 236 DCHECK(url.is_valid()); |
237 | 237 |
238 if (!IsAccessAllowed(url)) { | 238 if (!IsAccessAllowed(url)) { |
239 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; | 239 *error_code = base::PLATFORM_FILE_ERROR_SECURITY; |
240 return NULL; | 240 return NULL; |
241 } | 241 } |
242 | 242 |
243 if (url.type() == fileapi::kFileSystemTypeDrive) | 243 if (url.type() == fileapi::kFileSystemTypeDrive) |
244 return drive_delegate_->CreateFileSystemOperation(url, context, error_code); | 244 return drive_delegate_->CreateFileSystemOperation(url, context, error_code); |
245 | 245 |
246 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || | 246 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || |
247 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal); | 247 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal); |
248 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( | 248 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( |
249 new fileapi::FileSystemOperationContext(context)); | 249 new fileapi::FileSystemOperationContext(context)); |
250 operation_context->set_root_path(GetFileSystemRootPath(url)); | 250 operation_context->set_root_path(GetFileSystemRootPath(url)); |
251 return new fileapi::LocalFileSystemOperation(url, context, | 251 return new fileapi::LocalFileSystemOperation(url, context, |
252 operation_context.Pass()); | 252 operation_context.Pass()); |
253 } | 253 } |
254 | 254 |
255 scoped_ptr<webkit_blob::FileStreamReader> | 255 scoped_ptr<webkit_blob::FileStreamReader> |
256 CrosMountPointProvider::CreateFileStreamReader( | 256 FileSystemBackend::CreateFileStreamReader( |
257 const fileapi::FileSystemURL& url, | 257 const fileapi::FileSystemURL& url, |
258 int64 offset, | 258 int64 offset, |
259 const base::Time& expected_modification_time, | 259 const base::Time& expected_modification_time, |
260 fileapi::FileSystemContext* context) const { | 260 fileapi::FileSystemContext* context) const { |
261 DCHECK(url.is_valid()); | 261 DCHECK(url.is_valid()); |
262 | 262 |
263 if (!IsAccessAllowed(url)) | 263 if (!IsAccessAllowed(url)) |
264 return scoped_ptr<webkit_blob::FileStreamReader>(); | 264 return scoped_ptr<webkit_blob::FileStreamReader>(); |
265 | 265 |
266 if (url.type() == fileapi::kFileSystemTypeDrive) { | 266 if (url.type() == fileapi::kFileSystemTypeDrive) { |
267 return drive_delegate_->CreateFileStreamReader( | 267 return drive_delegate_->CreateFileStreamReader( |
268 url, offset, expected_modification_time, context); | 268 url, offset, expected_modification_time, context); |
269 } | 269 } |
270 | 270 |
271 return scoped_ptr<webkit_blob::FileStreamReader>( | 271 return scoped_ptr<webkit_blob::FileStreamReader>( |
272 new fileapi::FileSystemFileStreamReader( | 272 new fileapi::FileSystemFileStreamReader( |
273 context, url, offset, expected_modification_time)); | 273 context, url, offset, expected_modification_time)); |
274 } | 274 } |
275 | 275 |
276 scoped_ptr<fileapi::FileStreamWriter> | 276 scoped_ptr<fileapi::FileStreamWriter> |
277 CrosMountPointProvider::CreateFileStreamWriter( | 277 FileSystemBackend::CreateFileStreamWriter( |
278 const fileapi::FileSystemURL& url, | 278 const fileapi::FileSystemURL& url, |
279 int64 offset, | 279 int64 offset, |
280 fileapi::FileSystemContext* context) const { | 280 fileapi::FileSystemContext* context) const { |
281 DCHECK(url.is_valid()); | 281 DCHECK(url.is_valid()); |
282 | 282 |
283 if (!IsAccessAllowed(url)) | 283 if (!IsAccessAllowed(url)) |
284 return scoped_ptr<fileapi::FileStreamWriter>(); | 284 return scoped_ptr<fileapi::FileStreamWriter>(); |
285 | 285 |
286 if (url.type() == fileapi::kFileSystemTypeDrive) | 286 if (url.type() == fileapi::kFileSystemTypeDrive) |
287 return drive_delegate_->CreateFileStreamWriter(url, offset, context); | 287 return drive_delegate_->CreateFileStreamWriter(url, offset, context); |
288 | 288 |
289 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) | 289 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) |
290 return scoped_ptr<fileapi::FileStreamWriter>(); | 290 return scoped_ptr<fileapi::FileStreamWriter>(); |
291 | 291 |
292 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); | 292 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); |
293 return scoped_ptr<fileapi::FileStreamWriter>( | 293 return scoped_ptr<fileapi::FileStreamWriter>( |
294 new fileapi::LocalFileStreamWriter( | 294 new fileapi::LocalFileStreamWriter( |
295 context->task_runners()->file_task_runner(), url.path(), offset)); | 295 context->task_runners()->file_task_runner(), url.path(), offset)); |
296 } | 296 } |
297 | 297 |
298 bool CrosMountPointProvider::GetVirtualPath( | 298 bool FileSystemBackend::GetVirtualPath( |
299 const base::FilePath& filesystem_path, | 299 const base::FilePath& filesystem_path, |
300 base::FilePath* virtual_path) { | 300 base::FilePath* virtual_path) { |
301 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || | 301 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || |
302 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); | 302 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); |
303 } | 303 } |
304 | 304 |
305 base::FilePath CrosMountPointProvider::GetFileSystemRootPath( | 305 base::FilePath FileSystemBackend::GetFileSystemRootPath( |
306 const fileapi::FileSystemURL& url) const { | 306 const fileapi::FileSystemURL& url) const { |
307 DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); | 307 DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); |
308 if (!url.is_valid()) | 308 if (!url.is_valid()) |
309 return base::FilePath(); | 309 return base::FilePath(); |
310 | 310 |
311 base::FilePath root_path; | 311 base::FilePath root_path; |
312 std::string mount_name = url.filesystem_id(); | 312 std::string mount_name = url.filesystem_id(); |
313 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) && | 313 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) && |
314 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) { | 314 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) { |
315 return base::FilePath(); | 315 return base::FilePath(); |
316 } | 316 } |
317 | 317 |
318 return root_path.DirName(); | 318 return root_path.DirName(); |
319 } | 319 } |
320 | 320 |
321 } // namespace chromeos | 321 } // namespace chromeos |
OLD | NEW |