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 "storage/browser/fileapi/file_system_context.h" | 5 #include "storage/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 "base/thread_task_runner_handle.h" |
11 #include "net/url_request/url_request.h" | 12 #include "net/url_request/url_request.h" |
12 #include "storage/browser/fileapi/copy_or_move_file_validator.h" | 13 #include "storage/browser/fileapi/copy_or_move_file_validator.h" |
13 #include "storage/browser/fileapi/external_mount_points.h" | 14 #include "storage/browser/fileapi/external_mount_points.h" |
14 #include "storage/browser/fileapi/file_permission_policy.h" | 15 #include "storage/browser/fileapi/file_permission_policy.h" |
15 #include "storage/browser/fileapi/file_stream_reader.h" | 16 #include "storage/browser/fileapi/file_stream_reader.h" |
16 #include "storage/browser/fileapi/file_stream_writer.h" | 17 #include "storage/browser/fileapi/file_stream_writer.h" |
17 #include "storage/browser/fileapi/file_system_file_util.h" | 18 #include "storage/browser/fileapi/file_system_file_util.h" |
18 #include "storage/browser/fileapi/file_system_operation.h" | 19 #include "storage/browser/fileapi/file_system_operation.h" |
19 #include "storage/browser/fileapi/file_system_operation_runner.h" | 20 #include "storage/browser/fileapi/file_system_operation_runner.h" |
20 #include "storage/browser/fileapi/file_system_options.h" | 21 #include "storage/browser/fileapi/file_system_options.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 FileSystemContext::RESOLVED_ENTRY_NOT_FOUND); | 60 FileSystemContext::RESOLVED_ENTRY_NOT_FOUND); |
60 } | 61 } |
61 return; | 62 return; |
62 } | 63 } |
63 callback.Run(error, info, path, file_info.is_directory ? | 64 callback.Run(error, info, path, file_info.is_directory ? |
64 FileSystemContext::RESOLVED_ENTRY_DIRECTORY : | 65 FileSystemContext::RESOLVED_ENTRY_DIRECTORY : |
65 FileSystemContext::RESOLVED_ENTRY_FILE); | 66 FileSystemContext::RESOLVED_ENTRY_FILE); |
66 } | 67 } |
67 | 68 |
68 void RelayResolveURLCallback( | 69 void RelayResolveURLCallback( |
69 scoped_refptr<base::MessageLoopProxy> message_loop, | 70 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
70 const FileSystemContext::ResolveURLCallback& callback, | 71 const FileSystemContext::ResolveURLCallback& callback, |
71 base::File::Error result, | 72 base::File::Error result, |
72 const FileSystemInfo& info, | 73 const FileSystemInfo& info, |
73 const base::FilePath& file_path, | 74 const base::FilePath& file_path, |
74 FileSystemContext::ResolvedEntryType type) { | 75 FileSystemContext::ResolvedEntryType type) { |
75 message_loop->PostTask( | 76 task_runner->PostTask( |
76 FROM_HERE, base::Bind(callback, result, info, file_path, type)); | 77 FROM_HERE, base::Bind(callback, result, info, file_path, type)); |
77 } | 78 } |
78 | 79 |
79 } // namespace | 80 } // namespace |
80 | 81 |
81 // static | 82 // static |
82 int FileSystemContext::GetPermissionPolicy(FileSystemType type) { | 83 int FileSystemContext::GetPermissionPolicy(FileSystemType type) { |
83 switch (type) { | 84 switch (type) { |
84 case kFileSystemTypeTemporary: | 85 case kFileSystemTypeTemporary: |
85 case kFileSystemTypePersistent: | 86 case kFileSystemTypePersistent: |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 359 |
359 void FileSystemContext::ResolveURL( | 360 void FileSystemContext::ResolveURL( |
360 const FileSystemURL& url, | 361 const FileSystemURL& url, |
361 const ResolveURLCallback& callback) { | 362 const ResolveURLCallback& callback) { |
362 DCHECK(!callback.is_null()); | 363 DCHECK(!callback.is_null()); |
363 | 364 |
364 // If not on IO thread, forward before passing the task to the backend. | 365 // If not on IO thread, forward before passing the task to the backend. |
365 if (!io_task_runner_->RunsTasksOnCurrentThread()) { | 366 if (!io_task_runner_->RunsTasksOnCurrentThread()) { |
366 ResolveURLCallback relay_callback = | 367 ResolveURLCallback relay_callback = |
367 base::Bind(&RelayResolveURLCallback, | 368 base::Bind(&RelayResolveURLCallback, |
368 base::MessageLoopProxy::current(), callback); | 369 base::ThreadTaskRunnerHandle::Get(), callback); |
369 io_task_runner_->PostTask( | 370 io_task_runner_->PostTask( |
370 FROM_HERE, | 371 FROM_HERE, |
371 base::Bind(&FileSystemContext::ResolveURL, this, url, relay_callback)); | 372 base::Bind(&FileSystemContext::ResolveURL, this, url, relay_callback)); |
372 return; | 373 return; |
373 } | 374 } |
374 | 375 |
375 FileSystemBackend* backend = GetFileSystemBackend(url.type()); | 376 FileSystemBackend* backend = GetFileSystemBackend(url.type()); |
376 if (!backend) { | 377 if (!backend) { |
377 callback.Run(base::File::FILE_ERROR_SECURITY, | 378 callback.Run(base::File::FILE_ERROR_SECURITY, |
378 FileSystemInfo(), base::FilePath(), | 379 FileSystemInfo(), base::FilePath(), |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 } else if (parent != child) { | 625 } else if (parent != child) { |
625 bool result = parent.AppendRelativePath(child, &path); | 626 bool result = parent.AppendRelativePath(child, &path); |
626 DCHECK(result); | 627 DCHECK(result); |
627 } | 628 } |
628 | 629 |
629 operation_runner()->GetMetadata( | 630 operation_runner()->GetMetadata( |
630 url, base::Bind(&DidGetMetadataForResolveURL, path, callback, info)); | 631 url, base::Bind(&DidGetMetadataForResolveURL, path, callback, info)); |
631 } | 632 } |
632 | 633 |
633 } // namespace storage | 634 } // namespace storage |
OLD | NEW |