| 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/file_system_backend.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/message_loop.h" | 9 #include "base/message_loop/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/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" | 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/external_mount_points.h" | 19 #include "webkit/browser/fileapi/external_mount_points.h" |
| 20 #include "webkit/browser/fileapi/file_system_context.h" | 20 #include "webkit/browser/fileapi/file_system_context.h" |
| 21 #include "webkit/browser/fileapi/file_system_file_stream_reader.h" | 21 #include "webkit/browser/fileapi/file_system_file_stream_reader.h" |
| 22 #include "webkit/browser/fileapi/file_system_operation_context.h" | 22 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 23 #include "webkit/browser/fileapi/file_system_operation_impl.h" | 23 #include "webkit/browser/fileapi/file_system_operation_impl.h" |
| 24 #include "webkit/browser/fileapi/file_system_task_runners.h" | |
| 25 #include "webkit/browser/fileapi/file_system_url.h" | 24 #include "webkit/browser/fileapi/file_system_url.h" |
| 26 #include "webkit/browser/fileapi/isolated_context.h" | 25 #include "webkit/browser/fileapi/isolated_context.h" |
| 27 #include "webkit/browser/fileapi/isolated_file_util.h" | 26 #include "webkit/browser/fileapi/isolated_file_util.h" |
| 28 #include "webkit/browser/fileapi/local_file_stream_writer.h" | 27 #include "webkit/browser/fileapi/local_file_stream_writer.h" |
| 29 | 28 |
| 30 namespace { | 29 namespace { |
| 31 | 30 |
| 32 const char kChromeUIScheme[] = "chrome"; | 31 const char kChromeUIScheme[] = "chrome"; |
| 33 | 32 |
| 34 } // namespace | 33 } // namespace |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 | 286 |
| 288 if (url.type() == fileapi::kFileSystemTypeDrive) | 287 if (url.type() == fileapi::kFileSystemTypeDrive) |
| 289 return drive_delegate_->CreateFileStreamWriter(url, offset, context); | 288 return drive_delegate_->CreateFileStreamWriter(url, offset, context); |
| 290 | 289 |
| 291 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) | 290 if (url.type() == fileapi::kFileSystemTypeRestrictedNativeLocal) |
| 292 return scoped_ptr<fileapi::FileStreamWriter>(); | 291 return scoped_ptr<fileapi::FileStreamWriter>(); |
| 293 | 292 |
| 294 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); | 293 DCHECK(url.type() == fileapi::kFileSystemTypeNativeLocal); |
| 295 return scoped_ptr<fileapi::FileStreamWriter>( | 294 return scoped_ptr<fileapi::FileStreamWriter>( |
| 296 new fileapi::LocalFileStreamWriter( | 295 new fileapi::LocalFileStreamWriter( |
| 297 context->task_runners()->file_task_runner(), url.path(), offset)); | 296 context->default_file_task_runner(), url.path(), offset)); |
| 298 } | 297 } |
| 299 | 298 |
| 300 bool FileSystemBackend::GetVirtualPath( | 299 bool FileSystemBackend::GetVirtualPath( |
| 301 const base::FilePath& filesystem_path, | 300 const base::FilePath& filesystem_path, |
| 302 base::FilePath* virtual_path) { | 301 base::FilePath* virtual_path) { |
| 303 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || | 302 return mount_points_->GetVirtualPath(filesystem_path, virtual_path) || |
| 304 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); | 303 system_mount_points_->GetVirtualPath(filesystem_path, virtual_path); |
| 305 } | 304 } |
| 306 | 305 |
| 307 base::FilePath FileSystemBackend::GetFileSystemRootPath( | 306 base::FilePath FileSystemBackend::GetFileSystemRootPath( |
| 308 const fileapi::FileSystemURL& url) const { | 307 const fileapi::FileSystemURL& url) const { |
| 309 DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); | 308 DCHECK(fileapi::IsolatedContext::IsIsolatedType(url.mount_type())); |
| 310 if (!url.is_valid()) | 309 if (!url.is_valid()) |
| 311 return base::FilePath(); | 310 return base::FilePath(); |
| 312 | 311 |
| 313 base::FilePath root_path; | 312 base::FilePath root_path; |
| 314 std::string mount_name = url.filesystem_id(); | 313 std::string mount_name = url.filesystem_id(); |
| 315 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) && | 314 if (!mount_points_->GetRegisteredPath(mount_name, &root_path) && |
| 316 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) { | 315 !system_mount_points_->GetRegisteredPath(mount_name, &root_path)) { |
| 317 return base::FilePath(); | 316 return base::FilePath(); |
| 318 } | 317 } |
| 319 | 318 |
| 320 return root_path.DirName(); | 319 return root_path.DirName(); |
| 321 } | 320 } |
| 322 | 321 |
| 323 } // namespace chromeos | 322 } // namespace chromeos |
| OLD | NEW |