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/threading/sequenced_worker_pool.h" | 16 #include "base/task_scheduler/post_task.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"), | |
fdoray
2017/05/17 14:38:49
Mutual exclusion is guaranteed between tasks poste
| |
70 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | |
71 | |
72 // Setting up additional filesystem backends. | 66 // Setting up additional filesystem backends. |
73 std::vector<std::unique_ptr<storage::FileSystemBackend>> additional_backends; | 67 std::vector<std::unique_ptr<storage::FileSystemBackend>> additional_backends; |
74 GetContentClient()->browser()->GetAdditionalFileSystemBackends( | 68 GetContentClient()->browser()->GetAdditionalFileSystemBackends( |
75 browser_context, | 69 browser_context, |
76 profile_path, | 70 profile_path, |
77 &additional_backends); | 71 &additional_backends); |
78 | 72 |
79 // Set up the auto mount handlers for url requests. | 73 // Set up the auto mount handlers for url requests. |
80 std::vector<storage::URLRequestAutoMountHandler> | 74 std::vector<storage::URLRequestAutoMountHandler> |
81 url_request_auto_mount_handlers; | 75 url_request_auto_mount_handlers; |
82 GetContentClient()->browser()->GetURLRequestAutoMountHandlers( | 76 GetContentClient()->browser()->GetURLRequestAutoMountHandlers( |
83 &url_request_auto_mount_handlers); | 77 &url_request_auto_mount_handlers); |
84 | 78 |
85 scoped_refptr<storage::FileSystemContext> file_system_context = | 79 scoped_refptr<storage::FileSystemContext> file_system_context = |
86 new storage::FileSystemContext( | 80 new storage::FileSystemContext( |
87 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(), | 81 BrowserThread::GetTaskRunnerForThread(BrowserThread::IO).get(), |
88 file_task_runner.get(), | 82 base::CreateSequencedTaskRunnerWithTraits( |
83 {base::MayBlock(), base::TaskPriority::BACKGROUND, | |
84 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN}) | |
85 .get(), | |
89 BrowserContext::GetMountPoints(browser_context), | 86 BrowserContext::GetMountPoints(browser_context), |
90 browser_context->GetSpecialStoragePolicy(), quota_manager_proxy, | 87 browser_context->GetSpecialStoragePolicy(), quota_manager_proxy, |
91 std::move(additional_backends), url_request_auto_mount_handlers, | 88 std::move(additional_backends), url_request_auto_mount_handlers, |
92 profile_path, CreateBrowserFileSystemOptions(is_incognito)); | 89 profile_path, CreateBrowserFileSystemOptions(is_incognito)); |
93 | 90 |
94 std::vector<storage::FileSystemType> types; | 91 std::vector<storage::FileSystemType> types; |
95 file_system_context->GetFileSystemTypes(&types); | 92 file_system_context->GetFileSystemTypes(&types); |
96 for (size_t i = 0; i < types.size(); ++i) { | 93 for (size_t i = 0; i < types.size(); ++i) { |
97 ChildProcessSecurityPolicyImpl::GetInstance() | 94 ChildProcessSecurityPolicyImpl::GetInstance() |
98 ->RegisterFileSystemPermissionPolicy( | 95 ->RegisterFileSystemPermissionPolicy( |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 // different from the receiver's. | 211 // different from the receiver's. |
215 file_system_file.url = | 212 file_system_file.url = |
216 GURL(storage::GetIsolatedFileSystemRootURIString( | 213 GURL(storage::GetIsolatedFileSystemRootURIString( |
217 file_system_url.origin(), filesystem_id, std::string()) | 214 file_system_url.origin(), filesystem_id, std::string()) |
218 .append(register_name)); | 215 .append(register_name)); |
219 file_system_file.filesystem_id = filesystem_id; | 216 file_system_file.filesystem_id = filesystem_id; |
220 } | 217 } |
221 } | 218 } |
222 | 219 |
223 } // namespace content | 220 } // namespace content |
OLD | NEW |