Chromium Code Reviews| 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/browser/fileapi/file_system_context.h" | 5 #include "webkit/browser/fileapi/file_system_context.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
| 11 #include "net/url_request/url_request.h" | |
| 11 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 12 #include "webkit/browser/blob/file_stream_reader.h" | 13 #include "webkit/browser/blob/file_stream_reader.h" |
| 13 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" | 14 #include "webkit/browser/fileapi/copy_or_move_file_validator.h" |
| 14 #include "webkit/browser/fileapi/external_mount_points.h" | 15 #include "webkit/browser/fileapi/external_mount_points.h" |
| 15 #include "webkit/browser/fileapi/file_permission_policy.h" | 16 #include "webkit/browser/fileapi/file_permission_policy.h" |
| 16 #include "webkit/browser/fileapi/file_stream_writer.h" | 17 #include "webkit/browser/fileapi/file_stream_writer.h" |
| 17 #include "webkit/browser/fileapi/file_system_file_util.h" | 18 #include "webkit/browser/fileapi/file_system_file_util.h" |
| 18 #include "webkit/browser/fileapi/file_system_operation.h" | 19 #include "webkit/browser/fileapi/file_system_operation.h" |
| 19 #include "webkit/browser/fileapi/file_system_operation_runner.h" | 20 #include "webkit/browser/fileapi/file_system_operation_runner.h" |
| 20 #include "webkit/browser/fileapi/file_system_options.h" | 21 #include "webkit/browser/fileapi/file_system_options.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 return FILE_PERMISSION_ALWAYS_DENY; | 107 return FILE_PERMISSION_ALWAYS_DENY; |
| 107 } | 108 } |
| 108 | 109 |
| 109 FileSystemContext::FileSystemContext( | 110 FileSystemContext::FileSystemContext( |
| 110 base::SingleThreadTaskRunner* io_task_runner, | 111 base::SingleThreadTaskRunner* io_task_runner, |
| 111 base::SequencedTaskRunner* file_task_runner, | 112 base::SequencedTaskRunner* file_task_runner, |
| 112 ExternalMountPoints* external_mount_points, | 113 ExternalMountPoints* external_mount_points, |
| 113 quota::SpecialStoragePolicy* special_storage_policy, | 114 quota::SpecialStoragePolicy* special_storage_policy, |
| 114 quota::QuotaManagerProxy* quota_manager_proxy, | 115 quota::QuotaManagerProxy* quota_manager_proxy, |
| 115 ScopedVector<FileSystemBackend> additional_backends, | 116 ScopedVector<FileSystemBackend> additional_backends, |
| 117 std::vector<URLRequestAutoMountHandler> auto_mount_handlers, | |
|
kinuko
2014/03/13 04:19:19
const ref?
vandebo (ex-Chrome)
2014/03/13 20:19:32
Oops. Fixed.
| |
| 116 const base::FilePath& partition_path, | 118 const base::FilePath& partition_path, |
| 117 const FileSystemOptions& options) | 119 const FileSystemOptions& options) |
| 118 : io_task_runner_(io_task_runner), | 120 : io_task_runner_(io_task_runner), |
| 119 default_file_task_runner_(file_task_runner), | 121 default_file_task_runner_(file_task_runner), |
| 120 quota_manager_proxy_(quota_manager_proxy), | 122 quota_manager_proxy_(quota_manager_proxy), |
| 121 sandbox_delegate_(new SandboxFileSystemBackendDelegate( | 123 sandbox_delegate_(new SandboxFileSystemBackendDelegate( |
| 122 quota_manager_proxy, | 124 quota_manager_proxy, |
| 123 file_task_runner, | 125 file_task_runner, |
| 124 partition_path, | 126 partition_path, |
| 125 special_storage_policy, | 127 special_storage_policy, |
| 126 options)), | 128 options)), |
| 127 sandbox_backend_(new SandboxFileSystemBackend( | 129 sandbox_backend_(new SandboxFileSystemBackend( |
| 128 sandbox_delegate_.get())), | 130 sandbox_delegate_.get())), |
| 129 isolated_backend_(new IsolatedFileSystemBackend()), | 131 isolated_backend_(new IsolatedFileSystemBackend()), |
| 130 plugin_private_backend_(new PluginPrivateFileSystemBackend( | 132 plugin_private_backend_(new PluginPrivateFileSystemBackend( |
| 131 file_task_runner, | 133 file_task_runner, |
| 132 partition_path, | 134 partition_path, |
| 133 special_storage_policy, | 135 special_storage_policy, |
| 134 options)), | 136 options)), |
| 135 additional_backends_(additional_backends.Pass()), | 137 additional_backends_(additional_backends.Pass()), |
| 138 auto_mount_handlers_(auto_mount_handlers), | |
| 136 external_mount_points_(external_mount_points), | 139 external_mount_points_(external_mount_points), |
| 137 partition_path_(partition_path), | 140 partition_path_(partition_path), |
| 138 is_incognito_(options.is_incognito()), | 141 is_incognito_(options.is_incognito()), |
| 139 operation_runner_(new FileSystemOperationRunner(this)) { | 142 operation_runner_(new FileSystemOperationRunner(this)) { |
| 140 RegisterBackend(sandbox_backend_.get()); | 143 RegisterBackend(sandbox_backend_.get()); |
| 141 RegisterBackend(isolated_backend_.get()); | 144 RegisterBackend(isolated_backend_.get()); |
| 142 RegisterBackend(plugin_private_backend_.get()); | 145 RegisterBackend(plugin_private_backend_.get()); |
| 143 | 146 |
| 144 for (ScopedVector<FileSystemBackend>::const_iterator iter = | 147 for (ScopedVector<FileSystemBackend>::const_iterator iter = |
| 145 additional_backends_.begin(); | 148 additional_backends_.begin(); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 | 333 |
| 331 backend->ResolveURL( | 334 backend->ResolveURL( |
| 332 url, | 335 url, |
| 333 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, | 336 OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT, |
| 334 base::Bind(&FileSystemContext::DidOpenFileSystemForResolveURL, | 337 base::Bind(&FileSystemContext::DidOpenFileSystemForResolveURL, |
| 335 this, | 338 this, |
| 336 url, | 339 url, |
| 337 callback)); | 340 callback)); |
| 338 } | 341 } |
| 339 | 342 |
| 343 void FileSystemContext::AttemptAutoMountForURLRequest( | |
|
kinuko
2014/03/12 05:50:40
Will you need this only for URL request? Do we als
vandebo (ex-Chrome)
2014/03/12 18:35:54
I initially tried making this part of ResolveURL o
kinuko
2014/03/13 04:19:19
(Assuming you're going to support toURL for media
vandebo (ex-Chrome)
2014/03/13 20:19:32
Hmm... That's specifically for "Local" filesystem
| |
| 344 const net::URLRequest* url_request, | |
| 345 const std::string& storage_domain, | |
| 346 const StatusCallback& callback) { | |
| 347 FileSystemURL filesystem_url = FileSystemURL(url_request->url()); | |
| 348 if (filesystem_url.type() == kFileSystemTypeExternal) { | |
| 349 for (size_t i = 0; i < auto_mount_handlers_.size(); i++) { | |
| 350 if (auto_mount_handlers_[i].Run(url_request, filesystem_url, | |
| 351 storage_domain, callback)) { | |
| 352 return; | |
| 353 } | |
| 354 } | |
| 355 } | |
| 356 callback.Run(base::File::FILE_ERROR_NOT_FOUND); | |
| 357 } | |
| 358 | |
| 340 void FileSystemContext::DeleteFileSystem( | 359 void FileSystemContext::DeleteFileSystem( |
| 341 const GURL& origin_url, | 360 const GURL& origin_url, |
| 342 FileSystemType type, | 361 FileSystemType type, |
| 343 const StatusCallback& callback) { | 362 const StatusCallback& callback) { |
| 344 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); | 363 DCHECK(io_task_runner_->RunsTasksOnCurrentThread()); |
| 345 DCHECK(origin_url == origin_url.GetOrigin()); | 364 DCHECK(origin_url == origin_url.GetOrigin()); |
| 346 DCHECK(!callback.is_null()); | 365 DCHECK(!callback.is_null()); |
| 347 | 366 |
| 348 FileSystemBackend* backend = GetFileSystemBackend(type); | 367 FileSystemBackend* backend = GetFileSystemBackend(type); |
| 349 if (!backend) { | 368 if (!backend) { |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 555 } else if (parent != child) { | 574 } else if (parent != child) { |
| 556 bool result = parent.AppendRelativePath(child, &path); | 575 bool result = parent.AppendRelativePath(child, &path); |
| 557 DCHECK(result); | 576 DCHECK(result); |
| 558 } | 577 } |
| 559 | 578 |
| 560 operation_runner()->GetMetadata( | 579 operation_runner()->GetMetadata( |
| 561 url, base::Bind(&DidGetMetadataForResolveURL, path, callback, info)); | 580 url, base::Bind(&DidGetMetadataForResolveURL, path, callback, info)); |
| 562 } | 581 } |
| 563 | 582 |
| 564 } // namespace fileapi | 583 } // namespace fileapi |
| OLD | NEW |