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 "content/browser/fileapi/browser_file_system_helper.h" | 5 #include "content/browser/fileapi/browser_file_system_helper.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "base/task_scheduler/post_task.h" | 16 #include "base/threading/sequenced_worker_pool.h" |
17 #include "content/browser/child_process_security_policy_impl.h" | 17 #include "content/browser/child_process_security_policy_impl.h" |
18 #include "content/public/browser/browser_context.h" | 18 #include "content/public/browser/browser_context.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/child_process_security_policy.h" | 20 #include "content/public/browser/child_process_security_policy.h" |
21 #include "content/public/browser/content_browser_client.h" | 21 #include "content/public/browser/content_browser_client.h" |
22 #include "content/public/common/content_client.h" | 22 #include "content/public/common/content_client.h" |
23 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
24 #include "content/public/common/drop_data.h" | 24 #include "content/public/common/drop_data.h" |
25 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
26 #include "net/base/filename_util.h" | 26 #include "net/base/filename_util.h" |
(...skipping 29 matching lines...) Expand all Loading... |
56 return FileSystemOptions(profile_mode, additional_allowed_schemes, NULL); | 56 return FileSystemOptions(profile_mode, additional_allowed_schemes, NULL); |
57 } | 57 } |
58 | 58 |
59 } // namespace | 59 } // namespace |
60 | 60 |
61 scoped_refptr<storage::FileSystemContext> CreateFileSystemContext( | 61 scoped_refptr<storage::FileSystemContext> CreateFileSystemContext( |
62 BrowserContext* browser_context, | 62 BrowserContext* browser_context, |
63 const base::FilePath& profile_path, | 63 const base::FilePath& profile_path, |
64 bool is_incognito, | 64 bool is_incognito, |
65 storage::QuotaManagerProxy* quota_manager_proxy) { | 65 storage::QuotaManagerProxy* quota_manager_proxy) { |
| 66 base::SequencedWorkerPool* pool = BrowserThread::GetBlockingPool(); |
| 67 scoped_refptr<base::SequencedTaskRunner> file_task_runner = |
| 68 pool->GetSequencedTaskRunnerWithShutdownBehavior( |
| 69 pool->GetNamedSequenceToken("FileAPI"), |
| 70 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); |
| 71 |
66 // Setting up additional filesystem backends. | 72 // Setting up additional filesystem backends. |
67 std::vector<std::unique_ptr<storage::FileSystemBackend>> additional_backends; | 73 std::vector<std::unique_ptr<storage::FileSystemBackend>> additional_backends; |
68 GetContentClient()->browser()->GetAdditionalFileSystemBackends( | 74 GetContentClient()->browser()->GetAdditionalFileSystemBackends( |
69 browser_context, | 75 browser_context, |
70 profile_path, | 76 profile_path, |
71 &additional_backends); | 77 &additional_backends); |
72 | 78 |
73 // Set up the auto mount handlers for url requests. | 79 // Set up the auto mount handlers for url requests. |
74 std::vector<storage::URLRequestAutoMountHandler> | 80 std::vector<storage::URLRequestAutoMountHandler> |
75 url_request_auto_mount_handlers; | 81 url_request_auto_mount_handlers; |
76 GetContentClient()->browser()->GetURLRequestAutoMountHandlers( | 82 GetContentClient()->browser()->GetURLRequestAutoMountHandlers( |
77 &url_request_auto_mount_handlers); | 83 &url_request_auto_mount_handlers); |
78 | 84 |
79 scoped_refptr<storage::FileSystemContext> file_system_context = | 85 scoped_refptr<storage::FileSystemContext> file_system_context = |
80 new storage::FileSystemContext( | 86 new storage::FileSystemContext( |
81 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(), | 87 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(), |
82 base::CreateSequencedTaskRunnerWithTraits( | 88 file_task_runner.get(), |
83 {base::MayBlock(), base::TaskPriority::BACKGROUND, | |
84 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}) | |
85 .get(), | |
86 BrowserContext::GetMountPoints(browser_context), | 89 BrowserContext::GetMountPoints(browser_context), |
87 browser_context->GetSpecialStoragePolicy(), quota_manager_proxy, | 90 browser_context->GetSpecialStoragePolicy(), quota_manager_proxy, |
88 std::move(additional_backends), url_request_auto_mount_handlers, | 91 std::move(additional_backends), url_request_auto_mount_handlers, |
89 profile_path, CreateBrowserFileSystemOptions(is_incognito)); | 92 profile_path, CreateBrowserFileSystemOptions(is_incognito)); |
90 | 93 |
91 std::vector<storage::FileSystemType> types; | 94 std::vector<storage::FileSystemType> types; |
92 file_system_context->GetFileSystemTypes(&types); | 95 file_system_context->GetFileSystemTypes(&types); |
93 for (size_t i = 0; i < types.size(); ++i) { | 96 for (size_t i = 0; i < types.size(); ++i) { |
94 ChildProcessSecurityPolicyImpl::GetInstance() | 97 ChildProcessSecurityPolicyImpl::GetInstance() |
95 ->RegisterFileSystemPermissionPolicy( | 98 ->RegisterFileSystemPermissionPolicy( |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 // different from the receiver's. | 214 // different from the receiver's. |
212 file_system_file.url = | 215 file_system_file.url = |
213 GURL(storage::GetIsolatedFileSystemRootURIString( | 216 GURL(storage::GetIsolatedFileSystemRootURIString( |
214 file_system_url.origin(), filesystem_id, std::string()) | 217 file_system_url.origin(), filesystem_id, std::string()) |
215 .append(register_name)); | 218 .append(register_name)); |
216 file_system_file.filesystem_id = filesystem_id; | 219 file_system_file.filesystem_id = filesystem_id; |
217 } | 220 } |
218 } | 221 } |
219 | 222 |
220 } // namespace content | 223 } // namespace content |
OLD | NEW |