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/chromeos/fileapi/cros_mount_point_provider.h" | 5 #include "webkit/chromeos/fileapi/cros_mount_point_provider.h" |
6 | 6 |
7 #include "base/chromeos/chromeos_version.h" | 7 #include "base/chromeos/chromeos_version.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 272 } |
273 | 273 |
274 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || | 274 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal || |
275 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal); | 275 url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal); |
276 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( | 276 scoped_ptr<fileapi::FileSystemOperationContext> operation_context( |
277 new fileapi::FileSystemOperationContext(context)); | 277 new fileapi::FileSystemOperationContext(context)); |
278 return new fileapi::LocalFileSystemOperation(context, | 278 return new fileapi::LocalFileSystemOperation(context, |
279 operation_context.Pass()); | 279 operation_context.Pass()); |
280 } | 280 } |
281 | 281 |
282 webkit_blob::FileStreamReader* CrosMountPointProvider::CreateFileStreamReader( | 282 scoped_ptr<webkit_blob::FileStreamReader> |
| 283 CrosMountPointProvider::CreateFileStreamReader( |
283 const fileapi::FileSystemURL& url, | 284 const fileapi::FileSystemURL& url, |
284 int64 offset, | 285 int64 offset, |
285 const base::Time& expected_modification_time, | 286 const base::Time& expected_modification_time, |
286 fileapi::FileSystemContext* context) const { | 287 fileapi::FileSystemContext* context) const { |
287 // For now we return a generic Reader implementation which utilizes | 288 // For now we return a generic Reader implementation which utilizes |
288 // CreateSnapshotFile internally (i.e. will download everything first). | 289 // CreateSnapshotFile internally (i.e. will download everything first). |
289 // TODO(satorux,zel): implement more efficient reader for remote cases. | 290 // TODO(satorux,zel): implement more efficient reader for remote cases. |
290 return new fileapi::FileSystemFileStreamReader( | 291 return scoped_ptr<webkit_blob::FileStreamReader>( |
291 context, url, offset, expected_modification_time); | 292 new fileapi::FileSystemFileStreamReader( |
| 293 context, url, offset, expected_modification_time)); |
292 } | 294 } |
293 | 295 |
294 fileapi::FileStreamWriter* CrosMountPointProvider::CreateFileStreamWriter( | 296 scoped_ptr<fileapi::FileStreamWriter> |
| 297 CrosMountPointProvider::CreateFileStreamWriter( |
295 const fileapi::FileSystemURL& url, | 298 const fileapi::FileSystemURL& url, |
296 int64 offset, | 299 int64 offset, |
297 fileapi::FileSystemContext* context) const { | 300 fileapi::FileSystemContext* context) const { |
298 DCHECK(url.is_valid()); | 301 DCHECK(url.is_valid()); |
299 | 302 |
300 if (url.type() == fileapi::kFileSystemTypeDrive) { | 303 if (url.type() == fileapi::kFileSystemTypeDrive) { |
301 fileapi::RemoteFileSystemProxyInterface* remote_proxy = | 304 fileapi::RemoteFileSystemProxyInterface* remote_proxy = |
302 GetRemoteProxy(url.filesystem_id()); | 305 GetRemoteProxy(url.filesystem_id()); |
303 if (!remote_proxy) | 306 if (!remote_proxy) |
304 return NULL; | 307 return scoped_ptr<fileapi::FileStreamWriter>(); |
305 return new fileapi::RemoteFileStreamWriter(remote_proxy, url, offset); | 308 return scoped_ptr<fileapi::FileStreamWriter>( |
| 309 new fileapi::RemoteFileStreamWriter(remote_proxy, url, offset)); |
306 } | 310 } |
307 | 311 |
308 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) | 312 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) |
309 return NULL; | 313 return scoped_ptr<fileapi::FileStreamWriter>(); |
310 | 314 |
311 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); | 315 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); |
312 return new fileapi::LocalFileStreamWriter(url.path(), offset); | 316 return scoped_ptr<fileapi::FileStreamWriter>( |
| 317 new fileapi::LocalFileStreamWriter(url.path(), offset)); |
313 } | 318 } |
314 | 319 |
315 bool CrosMountPointProvider::GetVirtualPath( | 320 bool CrosMountPointProvider::GetVirtualPath( |
316 const base::FilePath& filesystem_path, | 321 const base::FilePath& filesystem_path, |
317 base::FilePath* virtual_path) { | 322 base::FilePath* virtual_path) { |
318 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || | 323 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || |
319 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); | 324 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); |
320 } | 325 } |
321 | 326 |
322 fileapi::RemoteFileSystemProxyInterface* CrosMountPointProvider::GetRemoteProxy( | 327 fileapi::RemoteFileSystemProxyInterface* CrosMountPointProvider::GetRemoteProxy( |
323 const std::string& mount_name) const { | 328 const std::string& mount_name) const { |
324 fileapi::RemoteFileSystemProxyInterface* proxy = | 329 fileapi::RemoteFileSystemProxyInterface* proxy = |
325 mount_points_->GetRemoteFileSystemProxy(mount_name); | 330 mount_points_->GetRemoteFileSystemProxy(mount_name); |
326 if (proxy) | 331 if (proxy) |
327 return proxy; | 332 return proxy; |
328 return system_mount_points_->GetRemoteFileSystemProxy(mount_name); | 333 return system_mount_points_->GetRemoteFileSystemProxy(mount_name); |
329 } | 334 } |
330 | 335 |
331 } // namespace chromeos | 336 } // namespace chromeos |
OLD | NEW |