| 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 "content/browser/dom_storage/dom_storage_context_wrapper.h" | 5 #include "content/browser/dom_storage/dom_storage_context_wrapper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 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/location.h" | 14 #include "base/location.h" |
| 15 #include "base/memory/memory_coordinator_client_registry.h" | 15 #include "base/memory/memory_coordinator_client_registry.h" |
| 16 #include "base/memory/ptr_util.h" | 16 #include "base/memory/ptr_util.h" |
| 17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/sequenced_task_runner.h" | 18 #include "base/sequenced_task_runner.h" |
| 19 #include "base/single_thread_task_runner.h" | 19 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 21 #include "base/task_scheduler/post_task.h" | 21 #include "base/task_scheduler/post_task.h" |
| 22 #include "base/threading/sequenced_worker_pool.h" | |
| 23 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
| 24 #include "content/browser/dom_storage/dom_storage_area.h" | 23 #include "content/browser/dom_storage/dom_storage_area.h" |
| 25 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 24 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
| 26 #include "content/browser/dom_storage/dom_storage_task_runner.h" | 25 #include "content/browser/dom_storage/dom_storage_task_runner.h" |
| 27 #include "content/browser/dom_storage/local_storage_context_mojo.h" | 26 #include "content/browser/dom_storage/local_storage_context_mojo.h" |
| 28 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 27 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
| 29 #include "content/public/browser/browser_thread.h" | |
| 30 #include "content/public/browser/content_browser_client.h" | 28 #include "content/public/browser/content_browser_client.h" |
| 31 #include "content/public/browser/local_storage_usage_info.h" | 29 #include "content/public/browser/local_storage_usage_info.h" |
| 32 #include "content/public/browser/session_storage_usage_info.h" | 30 #include "content/public/browser/session_storage_usage_info.h" |
| 33 #include "content/public/common/content_client.h" | 31 #include "content/public/common/content_client.h" |
| 34 #include "content/public/common/content_features.h" | 32 #include "content/public/common/content_features.h" |
| 35 #include "content/public/common/content_switches.h" | 33 #include "content/public/common/content_switches.h" |
| 36 | 34 |
| 37 namespace content { | 35 namespace content { |
| 38 namespace { | 36 namespace { |
| 39 | 37 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 79 |
| 82 DOMStorageContextWrapper::DOMStorageContextWrapper( | 80 DOMStorageContextWrapper::DOMStorageContextWrapper( |
| 83 service_manager::Connector* connector, | 81 service_manager::Connector* connector, |
| 84 const base::FilePath& profile_path, | 82 const base::FilePath& profile_path, |
| 85 const base::FilePath& local_partition_path, | 83 const base::FilePath& local_partition_path, |
| 86 storage::SpecialStoragePolicy* special_storage_policy) { | 84 storage::SpecialStoragePolicy* special_storage_policy) { |
| 87 base::FilePath data_path; | 85 base::FilePath data_path; |
| 88 if (!profile_path.empty()) | 86 if (!profile_path.empty()) |
| 89 data_path = profile_path.Append(local_partition_path); | 87 data_path = profile_path.Append(local_partition_path); |
| 90 | 88 |
| 91 scoped_refptr<base::SequencedTaskRunner> primary_sequence; | 89 scoped_refptr<base::SequencedTaskRunner> primary_sequence = |
| 92 scoped_refptr<base::SequencedTaskRunner> commit_sequence; | 90 base::CreateSequencedTaskRunnerWithTraits( |
| 93 if (GetContentClient()->browser()->ShouldRedirectDOMStorageTaskRunner()) { | 91 {base::MayBlock(), base::TaskPriority::USER_BLOCKING, |
| 94 // TaskPriority::USER_BLOCKING as an experiment because this is currently | 92 base::TaskShutdownBehavior::BLOCK_SHUTDOWN}); |
| 95 // believed to be blocking synchronous IPCs from the renderers: | 93 scoped_refptr<base::SequencedTaskRunner> commit_sequence = |
| 96 // http://crbug.com/665588 (yes we want to fix that bug, but are taking it | 94 base::CreateSequencedTaskRunnerWithTraits( |
| 97 // as an opportunity to experiment with the scheduler). | 95 {base::MayBlock(), base::TaskPriority::BACKGROUND, |
| 98 base::TaskTraits dom_storage_traits = { | 96 base::TaskShutdownBehavior::BLOCK_SHUTDOWN}); |
| 99 base::MayBlock(), base::TaskPriority::USER_BLOCKING, | |
| 100 base::TaskShutdownBehavior::BLOCK_SHUTDOWN}; | |
| 101 primary_sequence = | |
| 102 base::CreateSequencedTaskRunnerWithTraits(dom_storage_traits); | |
| 103 commit_sequence = | |
| 104 base::CreateSequencedTaskRunnerWithTraits(dom_storage_traits); | |
| 105 } else { | |
| 106 base::SequencedWorkerPool* worker_pool = BrowserThread::GetBlockingPool(); | |
| 107 primary_sequence = worker_pool->GetSequencedTaskRunner( | |
| 108 worker_pool->GetNamedSequenceToken("dom_storage_primary")); | |
| 109 commit_sequence = worker_pool->GetSequencedTaskRunner( | |
| 110 worker_pool->GetNamedSequenceToken("dom_storage_commit")); | |
| 111 } | |
| 112 DCHECK(primary_sequence); | |
| 113 DCHECK(commit_sequence); | |
| 114 | 97 |
| 115 context_ = new DOMStorageContextImpl( | 98 context_ = new DOMStorageContextImpl( |
| 116 data_path.empty() ? data_path | 99 data_path.empty() ? data_path |
| 117 : data_path.AppendASCII(kLocalStorageDirectory), | 100 : data_path.AppendASCII(kLocalStorageDirectory), |
| 118 data_path.empty() ? data_path | 101 data_path.empty() ? data_path |
| 119 : data_path.AppendASCII(kSessionStorageDirectory), | 102 : data_path.AppendASCII(kSessionStorageDirectory), |
| 120 special_storage_policy, | 103 special_storage_policy, |
| 121 new DOMStorageWorkerPoolTaskRunner(std::move(primary_sequence), | 104 new DOMStorageWorkerPoolTaskRunner(std::move(primary_sequence), |
| 122 std::move(commit_sequence))); | 105 std::move(commit_sequence))); |
| 123 | 106 |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 base::SingleThreadTaskRunner* reply_task_runner, | 342 base::SingleThreadTaskRunner* reply_task_runner, |
| 360 std::vector<LocalStorageUsageInfo> usage) { | 343 std::vector<LocalStorageUsageInfo> usage) { |
| 361 context_->task_runner()->PostShutdownBlockingTask( | 344 context_->task_runner()->PostShutdownBlockingTask( |
| 362 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, | 345 FROM_HERE, DOMStorageTaskRunner::PRIMARY_SEQUENCE, |
| 363 base::Bind(&GetLocalStorageUsageHelper, base::Passed(&usage), | 346 base::Bind(&GetLocalStorageUsageHelper, base::Passed(&usage), |
| 364 base::RetainedRef(reply_task_runner), | 347 base::RetainedRef(reply_task_runner), |
| 365 base::RetainedRef(context_), callback)); | 348 base::RetainedRef(context_), callback)); |
| 366 } | 349 } |
| 367 | 350 |
| 368 } // namespace content | 351 } // namespace content |
| OLD | NEW |