[base] Make LazyTaskRunner explicitly ThreadPool-specific
TBR=fdoray@chromium.org (TBR for side-effects of mechanical change) Bug: 1026641 Change-Id: Ic0805fa52bd28aa93780749842f094e92a3e2ba9 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1994069 Commit-Queue: Gabriel Charette <gab@chromium.org> Reviewed-by: François Doray <fdoray@chromium.org> Auto-Submit: Gabriel Charette <gab@chromium.org> Cr-Commit-Position: refs/heads/master@{#736016}
This commit is contained in:

committed by
Commit Bot

parent
87494a9d89
commit
59ff6f67c9
base
BUILD.gn
task
lazy_thread_pool_task_runner.cclazy_thread_pool_task_runner.hlazy_thread_pool_task_runner_unittest.cc
test
chrome
browser
installer
chromeos/process_proxy
components
data_reduction_proxy
core
dbus
thread_linux
download
password_manager
core
browser
performance_manager
content
extensions/browser
net/nqe
@ -579,8 +579,8 @@ jumbo_component("base") {
|
||||
"task/common/scoped_defer_task_posting.h",
|
||||
"task/common/task_annotator.cc",
|
||||
"task/common/task_annotator.h",
|
||||
"task/lazy_task_runner.cc",
|
||||
"task/lazy_task_runner.h",
|
||||
"task/lazy_thread_pool_task_runner.cc",
|
||||
"task/lazy_thread_pool_task_runner.h",
|
||||
"task/post_job.cc",
|
||||
"task/post_job.h",
|
||||
"task/post_task.cc",
|
||||
@ -2651,7 +2651,7 @@ test("base_unittests") {
|
||||
"task/common/checked_lock_unittest.cc",
|
||||
"task/common/operations_controller_unittest.cc",
|
||||
"task/common/task_annotator_unittest.cc",
|
||||
"task/lazy_task_runner_unittest.cc",
|
||||
"task/lazy_thread_pool_task_runner_unittest.cc",
|
||||
"task/post_job_unittest.cc",
|
||||
"task/post_task_unittest.cc",
|
||||
"task/scoped_set_task_priority_for_current_thread_unittest.cc",
|
||||
|
@ -2,13 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "base/lazy_instance_helpers.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/task/thread_pool.h"
|
||||
|
||||
namespace base {
|
||||
namespace internal {
|
||||
@ -19,7 +19,7 @@ ScopedLazyTaskRunnerListForTesting* g_scoped_lazy_task_runner_list_for_testing =
|
||||
} // namespace
|
||||
|
||||
template <typename TaskRunnerType, bool com_sta>
|
||||
void LazyTaskRunner<TaskRunnerType, com_sta>::Reset() {
|
||||
void LazyThreadPoolTaskRunner<TaskRunnerType, com_sta>::Reset() {
|
||||
subtle::AtomicWord state = subtle::Acquire_Load(&state_);
|
||||
|
||||
DCHECK_NE(state, kLazyInstanceStateCreating) << "Race: all threads should be "
|
||||
@ -40,65 +40,68 @@ void LazyTaskRunner<TaskRunnerType, com_sta>::Reset() {
|
||||
|
||||
template <>
|
||||
scoped_refptr<SequencedTaskRunner>
|
||||
LazyTaskRunner<SequencedTaskRunner, false>::Create() {
|
||||
LazyThreadPoolTaskRunner<SequencedTaskRunner, false>::Create() {
|
||||
// It is invalid to specify a SingleThreadTaskRunnerThreadMode with a
|
||||
// LazySequencedTaskRunner.
|
||||
// LazyThreadPoolSequencedTaskRunner.
|
||||
DCHECK_EQ(thread_mode_, SingleThreadTaskRunnerThreadMode::SHARED);
|
||||
|
||||
return CreateSequencedTaskRunner(traits_);
|
||||
return ThreadPool::CreateSequencedTaskRunner(traits_);
|
||||
}
|
||||
|
||||
template <>
|
||||
scoped_refptr<SingleThreadTaskRunner>
|
||||
LazyTaskRunner<SingleThreadTaskRunner, false>::Create() {
|
||||
return CreateSingleThreadTaskRunner(traits_, thread_mode_);
|
||||
LazyThreadPoolTaskRunner<SingleThreadTaskRunner, false>::Create() {
|
||||
return ThreadPool::CreateSingleThreadTaskRunner(traits_, thread_mode_);
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
template <>
|
||||
scoped_refptr<SingleThreadTaskRunner>
|
||||
LazyTaskRunner<SingleThreadTaskRunner, true>::Create() {
|
||||
return CreateCOMSTATaskRunner(traits_, thread_mode_);
|
||||
LazyThreadPoolTaskRunner<SingleThreadTaskRunner, true>::Create() {
|
||||
return ThreadPool::CreateCOMSTATaskRunner(traits_, thread_mode_);
|
||||
}
|
||||
#endif
|
||||
|
||||
// static
|
||||
template <typename TaskRunnerType, bool com_sta>
|
||||
TaskRunnerType* LazyTaskRunner<TaskRunnerType, com_sta>::CreateRaw(
|
||||
TaskRunnerType* LazyThreadPoolTaskRunner<TaskRunnerType, com_sta>::CreateRaw(
|
||||
void* void_self) {
|
||||
auto self =
|
||||
reinterpret_cast<LazyTaskRunner<TaskRunnerType, com_sta>*>(void_self);
|
||||
reinterpret_cast<LazyThreadPoolTaskRunner<TaskRunnerType, com_sta>*>(
|
||||
void_self);
|
||||
|
||||
scoped_refptr<TaskRunnerType> task_runner = self->Create();
|
||||
|
||||
// Acquire a reference to the TaskRunner. The reference will either
|
||||
// never be released or be released in Reset(). The reference is not
|
||||
// managed by a scoped_refptr because adding a scoped_refptr member to
|
||||
// LazyTaskRunner would prevent its static initialization.
|
||||
// LazyThreadPoolTaskRunner would prevent its static initialization.
|
||||
task_runner->AddRef();
|
||||
|
||||
// Reset this instance when the current
|
||||
// ScopedLazyTaskRunnerListForTesting is destroyed, if any.
|
||||
if (g_scoped_lazy_task_runner_list_for_testing) {
|
||||
g_scoped_lazy_task_runner_list_for_testing->AddCallback(BindOnce(
|
||||
&LazyTaskRunner<TaskRunnerType, com_sta>::Reset, Unretained(self)));
|
||||
g_scoped_lazy_task_runner_list_for_testing->AddCallback(
|
||||
BindOnce(&LazyThreadPoolTaskRunner<TaskRunnerType, com_sta>::Reset,
|
||||
Unretained(self)));
|
||||
}
|
||||
|
||||
return task_runner.get();
|
||||
}
|
||||
|
||||
template <typename TaskRunnerType, bool com_sta>
|
||||
scoped_refptr<TaskRunnerType> LazyTaskRunner<TaskRunnerType, com_sta>::Get() {
|
||||
scoped_refptr<TaskRunnerType>
|
||||
LazyThreadPoolTaskRunner<TaskRunnerType, com_sta>::Get() {
|
||||
return WrapRefCounted(subtle::GetOrCreateLazyPointer(
|
||||
&state_, &LazyTaskRunner<TaskRunnerType, com_sta>::CreateRaw,
|
||||
&state_, &LazyThreadPoolTaskRunner<TaskRunnerType, com_sta>::CreateRaw,
|
||||
reinterpret_cast<void*>(this), nullptr, nullptr));
|
||||
}
|
||||
|
||||
template class LazyTaskRunner<SequencedTaskRunner, false>;
|
||||
template class LazyTaskRunner<SingleThreadTaskRunner, false>;
|
||||
template class LazyThreadPoolTaskRunner<SequencedTaskRunner, false>;
|
||||
template class LazyThreadPoolTaskRunner<SingleThreadTaskRunner, false>;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
template class LazyTaskRunner<SingleThreadTaskRunner, true>;
|
||||
template class LazyThreadPoolTaskRunner<SingleThreadTaskRunner, true>;
|
||||
#endif
|
||||
|
||||
ScopedLazyTaskRunnerListForTesting::ScopedLazyTaskRunnerListForTesting() {
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef BASE_TASK_LAZY_TASK_RUNNER_H_
|
||||
#define BASE_TASK_LAZY_TASK_RUNNER_H_
|
||||
#ifndef BASE_TASK_LAZY_THREAD_POOL_TASK_RUNNER_H_
|
||||
#define BASE_TASK_LAZY_THREAD_POOL_TASK_RUNNER_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
@ -28,23 +28,17 @@
|
||||
// TaskRunners do not outlive the scope of the TaskEnvironment in unit tests
|
||||
// (otherwise the next test in the same process will die in use-after-frees).
|
||||
//
|
||||
// Note: This is only meant for base::ThreadPool bound task runners. Task
|
||||
// runners bound to other destination which share an existing sequence (like
|
||||
// BrowserThreads) should just use the appropriate getter each time (e.g.
|
||||
// base::Create*TaskRunner({BrowserThread::UI})).
|
||||
// TODO(1026641): Rename this API to LazyThreadPoolTaskRunner.
|
||||
//
|
||||
// IMPORTANT: Only use this API as a last resort. Prefer storing a
|
||||
// (Sequenced|SingleThread)TaskRunner returned by
|
||||
// base::Create(Sequenced|SingleThread|COMSTA)TaskRunner() as a member on an
|
||||
// object accessible by all PostTask() call sites.
|
||||
// base::ThreadPool::Create(Sequenced|SingleThread|COMSTA)TaskRunner() as a
|
||||
// member on an object accessible by all PostTask() call sites.
|
||||
//
|
||||
// Example usage 1:
|
||||
//
|
||||
// namespace {
|
||||
// base::LazySequencedTaskRunner g_sequenced_task_runner =
|
||||
// LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
// base::TaskTraits(base::ThreadPool(), base::MayBlock(),
|
||||
// base::LazyThreadPoolSequencedTaskRunner g_sequenced_task_runner =
|
||||
// LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
// base::TaskTraits(base::MayBlock(),
|
||||
// base::TaskPriority::USER_VISIBLE));
|
||||
// } // namespace
|
||||
//
|
||||
@ -57,9 +51,9 @@
|
||||
// Example usage 2:
|
||||
//
|
||||
// namespace {
|
||||
// base::LazySequencedTaskRunner g_sequenced_task_task_runner =
|
||||
// LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
// base::TaskTraits(base::ThreadPool(), base::MayBlock()));
|
||||
// base::LazyThreadPoolSequencedTaskRunner g_sequenced_task_task_runner =
|
||||
// LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
// base::TaskTraits(base::MayBlock()));
|
||||
// } // namespace
|
||||
//
|
||||
// // Code from different files can access the SequencedTaskRunner via this
|
||||
@ -72,21 +66,21 @@ namespace base {
|
||||
|
||||
namespace internal {
|
||||
template <typename TaskRunnerType, bool com_sta>
|
||||
class BASE_EXPORT LazyTaskRunner;
|
||||
class BASE_EXPORT LazyThreadPoolTaskRunner;
|
||||
} // namespace internal
|
||||
|
||||
// Lazy SequencedTaskRunner.
|
||||
using LazySequencedTaskRunner =
|
||||
internal::LazyTaskRunner<SequencedTaskRunner, false>;
|
||||
using LazyThreadPoolSequencedTaskRunner =
|
||||
internal::LazyThreadPoolTaskRunner<SequencedTaskRunner, false>;
|
||||
|
||||
// Lazy SingleThreadTaskRunner.
|
||||
using LazySingleThreadTaskRunner =
|
||||
internal::LazyTaskRunner<SingleThreadTaskRunner, false>;
|
||||
using LazyThreadPoolSingleThreadTaskRunner =
|
||||
internal::LazyThreadPoolTaskRunner<SingleThreadTaskRunner, false>;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
// Lazy COM-STA enabled SingleThreadTaskRunner.
|
||||
using LazyCOMSTATaskRunner =
|
||||
internal::LazyTaskRunner<SingleThreadTaskRunner, true>;
|
||||
using LazyThreadPoolCOMSTATaskRunner =
|
||||
internal::LazyThreadPoolTaskRunner<SingleThreadTaskRunner, true>;
|
||||
#endif
|
||||
|
||||
// Helper macros to generate a variable name by concatenation.
|
||||
@ -94,14 +88,15 @@ using LazyCOMSTATaskRunner =
|
||||
#define LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(a, b) \
|
||||
LAZY_TASK_RUNNER_CONCATENATE_INTERNAL2(a, b)
|
||||
|
||||
// Use the macros below to initialize a LazyTaskRunner. These macros verify that
|
||||
// their arguments are constexpr, which is important to prevent the generation
|
||||
// of a static initializer.
|
||||
// Use the macros below to initialize a LazyThreadPoolTaskRunner. These macros
|
||||
// verify that their arguments are constexpr, which is important to prevent the
|
||||
// generation of a static initializer.
|
||||
|
||||
// |traits| are TaskTraits used when creating the SequencedTaskRunner.
|
||||
#define LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(traits) \
|
||||
base::LazySequencedTaskRunner::CreateInternal(traits); \
|
||||
static_assert(traits.use_thread_pool(), ""); \
|
||||
#define LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(traits) \
|
||||
base::LazyThreadPoolSequencedTaskRunner::CreateInternal(traits); \
|
||||
/* ThreadPool() as a trait is deprecated and implicit here */ \
|
||||
static_assert(!traits.use_thread_pool(), ""); \
|
||||
ALLOW_UNUSED_TYPE constexpr base::TaskTraits \
|
||||
LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyTraitsAreConstexpr, \
|
||||
__LINE__) = traits
|
||||
@ -109,46 +104,50 @@ using LazyCOMSTATaskRunner =
|
||||
// |traits| are TaskTraits used when creating the SingleThreadTaskRunner.
|
||||
// |thread_mode| specifies whether the SingleThreadTaskRunner can share its
|
||||
// thread with other SingleThreadTaskRunners.
|
||||
#define LAZY_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(traits, thread_mode) \
|
||||
base::LazySingleThreadTaskRunner::CreateInternal(traits, thread_mode); \
|
||||
static_assert(traits.use_thread_pool(), ""); \
|
||||
ALLOW_UNUSED_TYPE constexpr base::TaskTraits \
|
||||
LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyTraitsAreConstexpr, \
|
||||
__LINE__) = traits; \
|
||||
ALLOW_UNUSED_TYPE constexpr base::SingleThreadTaskRunnerThreadMode \
|
||||
LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyThreadModeIsConstexpr, \
|
||||
#define LAZY_THREAD_POOL_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(traits, \
|
||||
thread_mode) \
|
||||
base::LazyThreadPoolSingleThreadTaskRunner::CreateInternal(traits, \
|
||||
thread_mode); \
|
||||
/* ThreadPool() as a trait is deprecated and implicit here */ \
|
||||
static_assert(!traits.use_thread_pool(), ""); \
|
||||
ALLOW_UNUSED_TYPE constexpr base::TaskTraits \
|
||||
LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyTraitsAreConstexpr, \
|
||||
__LINE__) = traits; \
|
||||
ALLOW_UNUSED_TYPE constexpr base::SingleThreadTaskRunnerThreadMode \
|
||||
LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyThreadModeIsConstexpr, \
|
||||
__LINE__) = thread_mode
|
||||
|
||||
// |traits| are TaskTraits used when creating the COM STA
|
||||
// SingleThreadTaskRunner. |thread_mode| specifies whether the COM STA
|
||||
// SingleThreadTaskRunner can share its thread with other
|
||||
// SingleThreadTaskRunners.
|
||||
#define LAZY_COM_STA_TASK_RUNNER_INITIALIZER(traits, thread_mode) \
|
||||
base::LazyCOMSTATaskRunner::CreateInternal(traits, thread_mode); \
|
||||
static_assert(traits.use_thread_pool(), ""); \
|
||||
ALLOW_UNUSED_TYPE constexpr base::TaskTraits \
|
||||
LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyTraitsAreConstexpr, \
|
||||
__LINE__) = traits; \
|
||||
ALLOW_UNUSED_TYPE constexpr base::SingleThreadTaskRunnerThreadMode \
|
||||
LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyThreadModeIsConstexpr, \
|
||||
#define LAZY_COM_STA_TASK_RUNNER_INITIALIZER(traits, thread_mode) \
|
||||
base::LazyThreadPoolCOMSTATaskRunner::CreateInternal(traits, thread_mode); \
|
||||
/* ThreadPool() as a trait is deprecated and implicit here */ \
|
||||
static_assert(!traits.use_thread_pool(), ""); \
|
||||
ALLOW_UNUSED_TYPE constexpr base::TaskTraits \
|
||||
LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyTraitsAreConstexpr, \
|
||||
__LINE__) = traits; \
|
||||
ALLOW_UNUSED_TYPE constexpr base::SingleThreadTaskRunnerThreadMode \
|
||||
LAZY_TASK_RUNNER_CONCATENATE_INTERNAL(kVerifyThreadModeIsConstexpr, \
|
||||
__LINE__) = thread_mode
|
||||
|
||||
namespace internal {
|
||||
|
||||
template <typename TaskRunnerType, bool com_sta>
|
||||
class BASE_EXPORT LazyTaskRunner {
|
||||
class BASE_EXPORT LazyThreadPoolTaskRunner {
|
||||
public:
|
||||
// Use the macros above rather than a direct call to this.
|
||||
//
|
||||
// |traits| are TaskTraits to use to create the TaskRunner. If this
|
||||
// LazyTaskRunner is specialized to create a SingleThreadTaskRunner,
|
||||
// LazyThreadPoolTaskRunner is specialized to create a SingleThreadTaskRunner,
|
||||
// |thread_mode| specifies whether the SingleThreadTaskRunner can share its
|
||||
// thread with other SingleThreadTaskRunner. Otherwise, it is unused.
|
||||
static constexpr LazyTaskRunner CreateInternal(
|
||||
static constexpr LazyThreadPoolTaskRunner CreateInternal(
|
||||
const TaskTraits& traits,
|
||||
SingleThreadTaskRunnerThreadMode thread_mode =
|
||||
SingleThreadTaskRunnerThreadMode::SHARED) {
|
||||
return LazyTaskRunner(traits, thread_mode);
|
||||
return LazyThreadPoolTaskRunner(traits, thread_mode);
|
||||
}
|
||||
|
||||
// Returns the TaskRunner held by this instance. Creates it if it didn't
|
||||
@ -156,9 +155,10 @@ class BASE_EXPORT LazyTaskRunner {
|
||||
scoped_refptr<TaskRunnerType> Get();
|
||||
|
||||
private:
|
||||
constexpr LazyTaskRunner(const TaskTraits& traits,
|
||||
SingleThreadTaskRunnerThreadMode thread_mode =
|
||||
SingleThreadTaskRunnerThreadMode::SHARED)
|
||||
constexpr LazyThreadPoolTaskRunner(
|
||||
const TaskTraits& traits,
|
||||
SingleThreadTaskRunnerThreadMode thread_mode =
|
||||
SingleThreadTaskRunnerThreadMode::SHARED)
|
||||
: traits_(traits), thread_mode_(thread_mode) {}
|
||||
|
||||
// Releases the TaskRunner held by this instance.
|
||||
@ -191,22 +191,22 @@ class BASE_EXPORT LazyTaskRunner {
|
||||
// (implementation limitation))'.
|
||||
};
|
||||
|
||||
// When a LazyTaskRunner becomes active (invokes Get()), it adds a callback to
|
||||
// the current ScopedLazyTaskRunnerListForTesting, if any. Callbacks run when
|
||||
// the ScopedLazyTaskRunnerListForTesting is destroyed. In a test process, a
|
||||
// ScopedLazyTaskRunnerListForTesting must be instantiated before any
|
||||
// LazyTaskRunner becomes active.
|
||||
// When a LazyThreadPoolTaskRunner becomes active (invokes Get()), it adds a
|
||||
// callback to the current ScopedLazyTaskRunnerListForTesting, if any.
|
||||
// Callbacks run when the ScopedLazyTaskRunnerListForTesting is
|
||||
// destroyed. In a test process, a ScopedLazyTaskRunnerListForTesting
|
||||
// must be instantiated before any LazyThreadPoolTaskRunner becomes active.
|
||||
class BASE_EXPORT ScopedLazyTaskRunnerListForTesting {
|
||||
public:
|
||||
ScopedLazyTaskRunnerListForTesting();
|
||||
~ScopedLazyTaskRunnerListForTesting();
|
||||
|
||||
private:
|
||||
friend class LazyTaskRunner<SequencedTaskRunner, false>;
|
||||
friend class LazyTaskRunner<SingleThreadTaskRunner, false>;
|
||||
friend class LazyThreadPoolTaskRunner<SequencedTaskRunner, false>;
|
||||
friend class LazyThreadPoolTaskRunner<SingleThreadTaskRunner, false>;
|
||||
|
||||
#if defined(OS_WIN)
|
||||
friend class LazyTaskRunner<SingleThreadTaskRunner, true>;
|
||||
friend class LazyThreadPoolTaskRunner<SingleThreadTaskRunner, true>;
|
||||
#endif
|
||||
|
||||
// Add |callback| to the list of callbacks to run on destruction.
|
||||
@ -223,4 +223,4 @@ class BASE_EXPORT ScopedLazyTaskRunnerListForTesting {
|
||||
} // namespace internal
|
||||
} // namespace base
|
||||
|
||||
#endif // BASE_TASK_LAZY_TASK_RUNNER_H_
|
||||
#endif // BASE_TASK_LAZY_THREAD_POOL_TASK_RUNNER_H_
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
|
||||
#include "base/bind.h"
|
||||
#include "base/bind_helpers.h"
|
||||
@ -21,30 +21,30 @@ namespace base {
|
||||
|
||||
namespace {
|
||||
|
||||
LazySequencedTaskRunner g_sequenced_task_runner_user_visible =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
TaskTraits(ThreadPool(), TaskPriority::USER_VISIBLE));
|
||||
LazySequencedTaskRunner g_sequenced_task_runner_user_blocking =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
TaskTraits(ThreadPool(), TaskPriority::USER_BLOCKING));
|
||||
LazyThreadPoolSequencedTaskRunner g_sequenced_task_runner_user_visible =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
TaskTraits(TaskPriority::USER_VISIBLE));
|
||||
LazyThreadPoolSequencedTaskRunner g_sequenced_task_runner_user_blocking =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
TaskTraits(TaskPriority::USER_BLOCKING));
|
||||
|
||||
LazySingleThreadTaskRunner g_single_thread_task_runner_user_visible =
|
||||
LAZY_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
TaskTraits(ThreadPool(), TaskPriority::USER_VISIBLE),
|
||||
LazyThreadPoolSingleThreadTaskRunner g_single_thread_task_runner_user_visible =
|
||||
LAZY_THREAD_POOL_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
TaskTraits(TaskPriority::USER_VISIBLE),
|
||||
SingleThreadTaskRunnerThreadMode::SHARED);
|
||||
LazySingleThreadTaskRunner g_single_thread_task_runner_user_blocking =
|
||||
LAZY_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
TaskTraits(ThreadPool(), TaskPriority::USER_BLOCKING),
|
||||
LazyThreadPoolSingleThreadTaskRunner g_single_thread_task_runner_user_blocking =
|
||||
LAZY_THREAD_POOL_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
TaskTraits(TaskPriority::USER_BLOCKING),
|
||||
SingleThreadTaskRunnerThreadMode::SHARED);
|
||||
|
||||
#if defined(OS_WIN)
|
||||
LazyCOMSTATaskRunner g_com_sta_task_runner_user_visible =
|
||||
LazyThreadPoolCOMSTATaskRunner g_com_sta_task_runner_user_visible =
|
||||
LAZY_COM_STA_TASK_RUNNER_INITIALIZER(
|
||||
TaskTraits(ThreadPool(), TaskPriority::USER_VISIBLE),
|
||||
TaskTraits(TaskPriority::USER_VISIBLE),
|
||||
SingleThreadTaskRunnerThreadMode::SHARED);
|
||||
LazyCOMSTATaskRunner g_com_sta_task_runner_user_blocking =
|
||||
LazyThreadPoolCOMSTATaskRunner g_com_sta_task_runner_user_blocking =
|
||||
LAZY_COM_STA_TASK_RUNNER_INITIALIZER(
|
||||
TaskTraits(ThreadPool(), TaskPriority::USER_BLOCKING),
|
||||
TaskTraits(TaskPriority::USER_BLOCKING),
|
||||
SingleThreadTaskRunnerThreadMode::SHARED);
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
@ -71,7 +71,7 @@ void ExpectSingleThreadEnvironment(SequenceCheckerImpl* sequence_checker,
|
||||
,
|
||||
bool expect_com_sta = false
|
||||
#endif
|
||||
) {
|
||||
) {
|
||||
EXPECT_TRUE(sequence_checker->CalledOnValidSequence());
|
||||
EXPECT_TRUE(thread_checker->CalledOnValidThread());
|
||||
EXPECT_EQ(expected_priority, internal::GetTaskPriorityForCurrentThread());
|
||||
@ -82,9 +82,9 @@ void ExpectSingleThreadEnvironment(SequenceCheckerImpl* sequence_checker,
|
||||
#endif
|
||||
}
|
||||
|
||||
class LazyTaskRunnerEnvironmentTest : public testing::Test {
|
||||
class LazyThreadPoolTaskRunnerEnvironmentTest : public testing::Test {
|
||||
protected:
|
||||
LazyTaskRunnerEnvironmentTest() = default;
|
||||
LazyThreadPoolTaskRunnerEnvironmentTest() = default;
|
||||
|
||||
void TestTaskRunnerEnvironment(scoped_refptr<SequencedTaskRunner> task_runner,
|
||||
bool expect_single_thread,
|
||||
@ -93,7 +93,7 @@ class LazyTaskRunnerEnvironmentTest : public testing::Test {
|
||||
,
|
||||
bool expect_com_sta = false
|
||||
#endif
|
||||
) {
|
||||
) {
|
||||
SequenceCheckerImpl sequence_checker;
|
||||
ThreadCheckerImpl thread_checker;
|
||||
task_runner->PostTask(FROM_HERE,
|
||||
@ -121,44 +121,50 @@ class LazyTaskRunnerEnvironmentTest : public testing::Test {
|
||||
test::TaskEnvironment task_environment_;
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(LazyTaskRunnerEnvironmentTest);
|
||||
DISALLOW_COPY_AND_ASSIGN(LazyThreadPoolTaskRunnerEnvironmentTest);
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_F(LazyTaskRunnerEnvironmentTest, LazySequencedTaskRunnerUserVisible) {
|
||||
TEST_F(LazyThreadPoolTaskRunnerEnvironmentTest,
|
||||
LazyThreadPoolSequencedTaskRunnerUserVisible) {
|
||||
TestTaskRunnerEnvironment(g_sequenced_task_runner_user_visible.Get(), false,
|
||||
TaskPriority::USER_VISIBLE);
|
||||
}
|
||||
|
||||
TEST_F(LazyTaskRunnerEnvironmentTest, LazySequencedTaskRunnerUserBlocking) {
|
||||
TEST_F(LazyThreadPoolTaskRunnerEnvironmentTest,
|
||||
LazyThreadPoolSequencedTaskRunnerUserBlocking) {
|
||||
TestTaskRunnerEnvironment(g_sequenced_task_runner_user_blocking.Get(), false,
|
||||
TaskPriority::USER_BLOCKING);
|
||||
}
|
||||
|
||||
TEST_F(LazyTaskRunnerEnvironmentTest, LazySingleThreadTaskRunnerUserVisible) {
|
||||
TEST_F(LazyThreadPoolTaskRunnerEnvironmentTest,
|
||||
LazyThreadPoolSingleThreadTaskRunnerUserVisible) {
|
||||
TestTaskRunnerEnvironment(g_single_thread_task_runner_user_visible.Get(),
|
||||
true, TaskPriority::USER_VISIBLE);
|
||||
}
|
||||
|
||||
TEST_F(LazyTaskRunnerEnvironmentTest, LazySingleThreadTaskRunnerUserBlocking) {
|
||||
TEST_F(LazyThreadPoolTaskRunnerEnvironmentTest,
|
||||
LazyThreadPoolSingleThreadTaskRunnerUserBlocking) {
|
||||
TestTaskRunnerEnvironment(g_single_thread_task_runner_user_blocking.Get(),
|
||||
true, TaskPriority::USER_BLOCKING);
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
TEST_F(LazyTaskRunnerEnvironmentTest, LazyCOMSTATaskRunnerUserVisible) {
|
||||
TEST_F(LazyThreadPoolTaskRunnerEnvironmentTest,
|
||||
LazyThreadPoolCOMSTATaskRunnerUserVisible) {
|
||||
TestTaskRunnerEnvironment(g_com_sta_task_runner_user_visible.Get(), true,
|
||||
TaskPriority::USER_VISIBLE, true);
|
||||
}
|
||||
|
||||
TEST_F(LazyTaskRunnerEnvironmentTest, LazyCOMSTATaskRunnerUserBlocking) {
|
||||
TEST_F(LazyThreadPoolTaskRunnerEnvironmentTest,
|
||||
LazyThreadPoolCOMSTATaskRunnerUserBlocking) {
|
||||
TestTaskRunnerEnvironment(g_com_sta_task_runner_user_blocking.Get(), true,
|
||||
TaskPriority::USER_BLOCKING, true);
|
||||
}
|
||||
#endif // defined(OS_WIN)
|
||||
|
||||
TEST(LazyTaskRunnerTest, LazySequencedTaskRunnerReset) {
|
||||
TEST(LazyThreadPoolTaskRunnerTest, LazyThreadPoolSequencedTaskRunnerReset) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
test::TaskEnvironment task_environment;
|
||||
// If the TaskRunner isn't released when the test::TaskEnvironment
|
||||
@ -169,7 +175,7 @@ TEST(LazyTaskRunnerTest, LazySequencedTaskRunnerReset) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(LazyTaskRunnerTest, LazySingleThreadTaskRunnerReset) {
|
||||
TEST(LazyThreadPoolTaskRunnerTest, LazyThreadPoolSingleThreadTaskRunnerReset) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
test::TaskEnvironment task_environment;
|
||||
// If the TaskRunner isn't released when the test::TaskEnvironment
|
||||
@ -181,7 +187,7 @@ TEST(LazyTaskRunnerTest, LazySingleThreadTaskRunnerReset) {
|
||||
}
|
||||
|
||||
#if defined(OS_WIN)
|
||||
TEST(LazyTaskRunnerTest, LazyCOMSTATaskRunnerReset) {
|
||||
TEST(LazyThreadPoolTaskRunnerTest, LazyThreadPoolCOMSTATaskRunnerReset) {
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
test::TaskEnvironment task_environment;
|
||||
// If the TaskRunner isn't released when the test::TaskEnvironment
|
@ -13,7 +13,7 @@
|
||||
#include "base/observer_list.h"
|
||||
#include "base/run_loop.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/sequence_manager/sequence_manager.h"
|
||||
#include "base/threading/thread_checker.h"
|
||||
#include "base/time/time.h"
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/stl_util.h"
|
||||
#include "base/synchronization/atomic_flag.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/task_traits.h"
|
||||
#include "chrome/browser/image_decoder/image_decoder.h"
|
||||
#include "chrome/grit/generated_resources.h"
|
||||
@ -33,16 +33,14 @@ const char* const kWallpaperLayoutArrays[] = {
|
||||
|
||||
const int kWallpaperLayoutCount = base::size(kWallpaperLayoutArrays);
|
||||
|
||||
base::LazySequencedTaskRunner g_blocking_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::LazyThreadPoolSequencedTaskRunner g_blocking_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(),
|
||||
base::TaskPriority::USER_BLOCKING,
|
||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN));
|
||||
base::LazySequencedTaskRunner g_non_blocking_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::LazyThreadPoolSequencedTaskRunner g_non_blocking_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(),
|
||||
base::TaskPriority::USER_VISIBLE,
|
||||
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN));
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "base/process/kill.h"
|
||||
#include "base/process/launch.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "chrome/common/logging_chrome.h"
|
||||
#include "chromeos/dbus/dbus_thread_manager.h"
|
||||
@ -34,10 +34,9 @@ typedef base::OnceCallback<void(bool succeeded)> CommandCompletionCallback;
|
||||
const char kGzipCommand[] = "/bin/gzip";
|
||||
const char kTarCommand[] = "/bin/tar";
|
||||
|
||||
base::LazySequencedTaskRunner g_sequenced_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::LazyThreadPoolSequencedTaskRunner g_sequenced_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(),
|
||||
base::TaskPriority::BEST_EFFORT,
|
||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN));
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
|
||||
@ -43,9 +43,9 @@ using std::set;
|
||||
|
||||
base::SequencedTaskRunner* impl_task_runner() {
|
||||
constexpr base::TaskTraits kBlockingTraits = {
|
||||
base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT};
|
||||
static base::LazySequencedTaskRunner s_sequenced_task_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(kBlockingTraits);
|
||||
base::MayBlock(), base::TaskPriority::BEST_EFFORT};
|
||||
static base::LazyThreadPoolSequencedTaskRunner s_sequenced_task_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(kBlockingTraits);
|
||||
return s_sequenced_task_task_runner.Get().get();
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "base/memory/ref_counted.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/threading/sequenced_task_runner_handle.h"
|
||||
#include "base/trace_event/memory_dump_manager.h"
|
||||
#include "base/trace_event/memory_dump_provider.h"
|
||||
@ -225,9 +225,9 @@ void DevToolsFileWatcher::SharedFileWatcher::DispatchNotifications() {
|
||||
namespace {
|
||||
base::SequencedTaskRunner* impl_task_runner() {
|
||||
constexpr base::TaskTraits kImplTaskTraits = {
|
||||
base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT};
|
||||
static base::LazySequencedTaskRunner s_file_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(kImplTaskTraits);
|
||||
base::MayBlock(), base::TaskPriority::BEST_EFFORT};
|
||||
static base::LazyThreadPoolSequencedTaskRunner s_file_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(kImplTaskTraits);
|
||||
return s_file_task_runner.Get().get();
|
||||
}
|
||||
} // namespace
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "chrome/browser/extensions/activity_log/activity_log_task_runner.h"
|
||||
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/single_thread_task_runner_thread_mode.h"
|
||||
|
||||
namespace extensions {
|
||||
@ -14,11 +14,9 @@ namespace {
|
||||
|
||||
base::SingleThreadTaskRunner* g_task_runner_for_testing = nullptr;
|
||||
|
||||
base::LazySingleThreadTaskRunner g_task_runner =
|
||||
LAZY_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::TaskPriority::BEST_EFFORT),
|
||||
base::LazyThreadPoolSingleThreadTaskRunner g_task_runner =
|
||||
LAZY_THREAD_POOL_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(), base::TaskPriority::BEST_EFFORT),
|
||||
base::SingleThreadTaskRunnerThreadMode::SHARED);
|
||||
|
||||
} // namespace
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "build/build_config.h"
|
||||
#include "chrome/browser/apps/user_type_filter.h"
|
||||
|
@ -10,17 +10,16 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "build/build_config.h"
|
||||
#include "chrome/common/chrome_paths.h"
|
||||
#include "components/crash/content/app/crashpad.h"
|
||||
|
||||
namespace {
|
||||
|
||||
base::LazySequencedTaskRunner g_collect_stats_consent_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::LazyThreadPoolSequencedTaskRunner g_collect_stats_consent_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(),
|
||||
base::TaskPriority::USER_VISIBLE,
|
||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN));
|
||||
|
||||
@ -49,8 +48,8 @@ void SetConsentFilePermissionIfNeeded(const base::FilePath& consent_file) {
|
||||
// static
|
||||
base::SequencedTaskRunner*
|
||||
GoogleUpdateSettings::CollectStatsConsentTaskRunner() {
|
||||
// TODO(fdoray): Use LazySequencedTaskRunner::GetRaw() here instead of
|
||||
// .Get().get() when it's added to the API, http://crbug.com/730170.
|
||||
// TODO(fdoray): Use LazyThreadPoolSequencedTaskRunner::GetRaw() here instead
|
||||
// of .Get().get() when it's added to the API, http://crbug.com/730170.
|
||||
return g_collect_stats_consent_task_runner.Get().get();
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "build/build_config.h"
|
||||
@ -57,10 +57,9 @@ namespace {
|
||||
|
||||
const char kMediaGalleryMountPrefix[] = "media_galleries-";
|
||||
|
||||
base::LazySequencedTaskRunner g_media_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::LazyThreadPoolSequencedTaskRunner g_media_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(),
|
||||
base::TaskPriority::USER_VISIBLE,
|
||||
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN));
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/task/single_thread_task_runner_thread_mode.h"
|
||||
#include "base/task/task_traits.h"
|
||||
@ -53,14 +53,14 @@ const struct AppModeInfo* gAppModeInfo = nullptr;
|
||||
// TODO(crbug.com/773563): Remove |g_sequenced_task_runner| and use an instance
|
||||
// field / singleton instead.
|
||||
#if defined(OS_WIN)
|
||||
base::LazyCOMSTATaskRunner g_sequenced_task_runner =
|
||||
base::LazyThreadPoolCOMSTATaskRunner g_sequenced_task_runner =
|
||||
LAZY_COM_STA_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(), base::MayBlock()),
|
||||
base::TaskTraits(base::MayBlock()),
|
||||
base::SingleThreadTaskRunnerThreadMode::SHARED);
|
||||
#else
|
||||
base::LazySequencedTaskRunner g_sequenced_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(), base::MayBlock()));
|
||||
base::LazyThreadPoolSequencedTaskRunner g_sequenced_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock()));
|
||||
#endif
|
||||
|
||||
} // namespace
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/location.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "chrome/browser/win/conflicts/module_database_observer.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
@ -109,9 +109,9 @@ ModuleDatabase::~ModuleDatabase() {
|
||||
|
||||
// static
|
||||
scoped_refptr<base::SequencedTaskRunner> ModuleDatabase::GetTaskRunner() {
|
||||
static base::LazySequencedTaskRunner g_module_database_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(), base::TaskPriority::BEST_EFFORT,
|
||||
static base::LazyThreadPoolSequencedTaskRunner g_module_database_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::TaskPriority::BEST_EFFORT,
|
||||
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN));
|
||||
return g_module_database_task_runner.Get();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/threading/thread_restrictions.h"
|
||||
#include "base/time/time.h"
|
||||
#include "base/win/registry.h"
|
||||
@ -51,10 +51,9 @@ const GoogleUpdateSettings::UpdatePolicy
|
||||
|
||||
namespace {
|
||||
|
||||
base::LazySequencedTaskRunner g_collect_stats_consent_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::TaskPriority::USER_VISIBLE,
|
||||
base::LazyThreadPoolSequencedTaskRunner g_collect_stats_consent_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::TaskPriority::USER_VISIBLE,
|
||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN));
|
||||
|
||||
// Reads the value |name| from the app's ClientState registry key in |root| into
|
||||
@ -217,8 +216,8 @@ bool GoogleUpdateSettings::IsSystemInstall() {
|
||||
|
||||
base::SequencedTaskRunner*
|
||||
GoogleUpdateSettings::CollectStatsConsentTaskRunner() {
|
||||
// TODO(fdoray): Use LazySequencedTaskRunner::GetRaw() here instead of
|
||||
// .Get().get() when it's added to the API, http://crbug.com/730170.
|
||||
// TODO(fdoray): Use LazyThreadPoolSequencedTaskRunner::GetRaw() here instead
|
||||
// of .Get().get() when it's added to the API, http://crbug.com/730170.
|
||||
return g_collect_stats_consent_task_runner.Get().get();
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "base/command_line.h"
|
||||
#include "base/message_loop/message_pump_type.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
|
||||
namespace chromeos {
|
||||
|
||||
@ -74,10 +74,9 @@ ProcessProxyRegistry* ProcessProxyRegistry::Get() {
|
||||
|
||||
// static
|
||||
scoped_refptr<base::SequencedTaskRunner> ProcessProxyRegistry::GetTaskRunner() {
|
||||
static base::LazySequencedTaskRunner task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(), base::MayBlock(),
|
||||
base::TaskPriority::BEST_EFFORT));
|
||||
static base::LazyThreadPoolSequencedTaskRunner task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(), base::TaskPriority::BEST_EFFORT));
|
||||
return task_runner.Get();
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task_runner_util.h"
|
||||
#include "base/time/default_tick_clock.h"
|
||||
#include "build/build_config.h"
|
||||
@ -56,10 +56,9 @@ namespace {
|
||||
// SequencedTaskRunner to get the network id. A SequencedTaskRunner is used
|
||||
// rather than parallel tasks to avoid having many threads getting the network
|
||||
// id concurrently.
|
||||
base::LazySequencedTaskRunner g_get_network_id_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::LazyThreadPoolSequencedTaskRunner g_get_network_id_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(),
|
||||
base::TaskPriority::BEST_EFFORT,
|
||||
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN));
|
||||
#endif
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#include "components/dbus/thread_linux/dbus_thread_linux.h"
|
||||
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
|
||||
namespace dbus_thread_linux {
|
||||
|
||||
@ -15,11 +15,9 @@ namespace {
|
||||
// on this thread. Use SingleThreadTaskRunnerThreadMode::SHARED, because DBus
|
||||
// does not require an exclusive use of the thread, only the existence of a
|
||||
// single thread for all tasks.
|
||||
base::LazySingleThreadTaskRunner g_dbus_thread_task_runner =
|
||||
LAZY_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::TaskPriority::USER_BLOCKING),
|
||||
base::LazyThreadPoolSingleThreadTaskRunner g_dbus_thread_task_runner =
|
||||
LAZY_THREAD_POOL_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(), base::TaskPriority::USER_BLOCKING),
|
||||
base::SingleThreadTaskRunnerThreadMode::SHARED);
|
||||
|
||||
} // namespace
|
||||
|
@ -20,7 +20,7 @@
|
||||
#include "base/stl_util.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/task_runner_util.h"
|
||||
#include "base/third_party/icu/icu_utf.h"
|
||||
@ -60,9 +60,9 @@ const size_t kZoneIdentifierLength = sizeof(":Zone.Identifier") - 1;
|
||||
// there are no more reservations.
|
||||
ReservationMap* g_reservation_map = NULL;
|
||||
|
||||
base::LazySequencedTaskRunner g_sequenced_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(), base::MayBlock()));
|
||||
base::LazyThreadPoolSequencedTaskRunner g_sequenced_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock()));
|
||||
|
||||
// Observes a DownloadItem for changes to its target path and state. Updates or
|
||||
// revokes associated download path reservations as necessary. Created, invoked
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/synchronization/lock.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "build/build_config.h"
|
||||
|
||||
namespace download {
|
||||
@ -18,18 +18,14 @@ namespace {
|
||||
#if defined(OS_WIN)
|
||||
// On Windows, the download code dips into COM and the shell here and there,
|
||||
// necessitating the use of a COM single-threaded apartment sequence.
|
||||
base::LazyCOMSTATaskRunner g_download_task_runner =
|
||||
base::LazyThreadPoolCOMSTATaskRunner g_download_task_runner =
|
||||
LAZY_COM_STA_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::TaskPriority::USER_VISIBLE),
|
||||
base::TaskTraits(base::MayBlock(), base::TaskPriority::USER_VISIBLE),
|
||||
base::SingleThreadTaskRunnerThreadMode::SHARED);
|
||||
#else
|
||||
base::LazySequencedTaskRunner g_download_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::TaskPriority::USER_VISIBLE));
|
||||
base::LazyThreadPoolSequencedTaskRunner g_download_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(), base::TaskPriority::USER_VISIBLE));
|
||||
#endif
|
||||
|
||||
base::LazyInstance<scoped_refptr<base::SingleThreadTaskRunner>>::
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/location.h"
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/task_runner_util.h"
|
||||
#include "build/build_config.h"
|
||||
@ -26,11 +26,9 @@ namespace {
|
||||
// destination and one of them was cancelled and will delete the file. We use
|
||||
// TaskPriority::USER_VISIBLE, because a busy UI is displayed while the
|
||||
// passwords are being exported.
|
||||
base::LazySingleThreadTaskRunner g_task_runner =
|
||||
LAZY_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::TaskPriority::USER_VISIBLE),
|
||||
base::LazyThreadPoolSingleThreadTaskRunner g_task_runner =
|
||||
LAZY_THREAD_POOL_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(), base::TaskPriority::USER_VISIBLE),
|
||||
base::SingleThreadTaskRunnerThreadMode::SHARED);
|
||||
|
||||
// A wrapper for |write_function|, which can be bound and keep a copy of its
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "base/logging.h"
|
||||
#include "base/macros.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/task/task_traits.h"
|
||||
#include "components/performance_manager/graph/frame_node_impl.h"
|
||||
@ -40,10 +40,9 @@ PerformanceManagerImpl* g_performance_manager_from_pm_sequence = nullptr;
|
||||
PerformanceManagerImpl* g_performance_manager_from_any_sequence = nullptr;
|
||||
|
||||
// The performance manager TaskRunner.
|
||||
base::LazySequencedTaskRunner g_performance_manager_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::TaskPriority::USER_VISIBLE,
|
||||
base::LazyThreadPoolSequencedTaskRunner g_performance_manager_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::TaskPriority::USER_VISIBLE,
|
||||
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
|
||||
base::MayBlock()));
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "base/metrics/histogram_macros.h"
|
||||
#include "base/no_destructor.h"
|
||||
#include "base/single_thread_task_runner.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/task/single_thread_task_runner_thread_mode.h"
|
||||
#include "base/task/task_traits.h"
|
||||
@ -231,10 +231,9 @@ base::SingleThreadTaskRunner* GetProcessLauncherTaskRunner() {
|
||||
#else // defined(OS_ANDROID)
|
||||
// TODO(http://crbug.com/820200): Investigate whether we could use
|
||||
// SequencedTaskRunner on platforms other than Windows.
|
||||
static base::LazySingleThreadTaskRunner launcher_task_runner =
|
||||
LAZY_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(), base::MayBlock(),
|
||||
base::TaskPriority::USER_BLOCKING,
|
||||
static base::LazyThreadPoolSingleThreadTaskRunner launcher_task_runner =
|
||||
LAZY_THREAD_POOL_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(), base::TaskPriority::USER_BLOCKING,
|
||||
base::TaskShutdownBehavior::BLOCK_SHUTDOWN),
|
||||
base::SingleThreadTaskRunnerThreadMode::DEDICATED);
|
||||
return launcher_task_runner.Get().get();
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "base/files/file_util.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/third_party/icu/icu_utf.h"
|
||||
#include "content/public/browser/browser_task_traits.h"
|
||||
@ -20,9 +20,9 @@ namespace content {
|
||||
|
||||
scoped_refptr<base::SequencedTaskRunner> impl_task_runner() {
|
||||
constexpr base::TaskTraits kBlockingTraits = {
|
||||
base::ThreadPool(), base::MayBlock(), base::TaskPriority::BEST_EFFORT};
|
||||
static base::LazySequencedTaskRunner s_sequenced_task_unner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(kBlockingTraits);
|
||||
base::MayBlock(), base::TaskPriority::BEST_EFFORT};
|
||||
static base::LazyThreadPoolSequencedTaskRunner s_sequenced_task_unner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(kBlockingTraits);
|
||||
return s_sequenced_task_unner.Get();
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "base/files/file_path.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "content/browser/child_process_security_policy_impl.h"
|
||||
#include "content/public/browser/browser_context.h"
|
||||
@ -49,10 +49,9 @@ namespace {
|
||||
|
||||
// All FileSystemContexts currently need to share the same sequence per sharing
|
||||
// global objects: https://codereview.chromium.org/2883403002#msg14.
|
||||
base::LazySequencedTaskRunner g_fileapi_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::LazyThreadPoolSequencedTaskRunner g_fileapi_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(),
|
||||
base::TaskPriority::USER_VISIBLE,
|
||||
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN));
|
||||
|
||||
|
@ -4,17 +4,15 @@
|
||||
|
||||
#include "content/common/font_list.h"
|
||||
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
|
||||
namespace content {
|
||||
|
||||
namespace {
|
||||
|
||||
base::LazySequencedTaskRunner g_font_list_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::TaskPriority::USER_VISIBLE));
|
||||
base::LazyThreadPoolSequencedTaskRunner g_font_list_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(), base::TaskPriority::USER_VISIBLE));
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "base/bind.h"
|
||||
#include "base/memory/ptr_util.h"
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/post_task.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "components/onc/onc_constants.h"
|
||||
@ -35,10 +35,10 @@ void ShutdownWifiServiceOnWorkerThread(
|
||||
|
||||
// Ensure that all calls to WiFiService are called from the same task runner
|
||||
// since the implementations do not provide any thread safety gaurantees.
|
||||
base::LazySequencedTaskRunner g_sequenced_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(base::TaskTraits(
|
||||
{base::ThreadPool(), base::MayBlock(), base::TaskPriority::USER_VISIBLE,
|
||||
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}));
|
||||
base::LazyThreadPoolSequencedTaskRunner g_sequenced_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits({base::MayBlock(), base::TaskPriority::USER_VISIBLE,
|
||||
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN}));
|
||||
|
||||
} // namespace
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "extensions/browser/extension_file_task_runner.h"
|
||||
|
||||
#include "base/sequenced_task_runner.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/task/task_traits.h"
|
||||
|
||||
namespace extensions {
|
||||
@ -18,10 +18,9 @@ namespace {
|
||||
// user action), and others are low priority (like garbage collection). Split
|
||||
// the difference and use USER_VISIBLE, which is the default priority and what a
|
||||
// task posted to a named thread (like the FILE thread) would receive.
|
||||
base::LazySequencedTaskRunner g_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::LazyThreadPoolSequencedTaskRunner g_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(),
|
||||
base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
|
||||
base::TaskPriority::USER_VISIBLE));
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_piece.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/task/lazy_task_runner.h"
|
||||
#include "base/task/lazy_thread_pool_task_runner.h"
|
||||
#include "base/threading/thread_task_runner_handle.h"
|
||||
#include "base/time/default_tick_clock.h"
|
||||
#include "base/trace_event/trace_event.h"
|
||||
@ -58,10 +58,9 @@ namespace {
|
||||
// SequencedTaskRunner to get the network id. A SequencedTaskRunner is used
|
||||
// rather than parallel tasks to avoid having many threads getting the network
|
||||
// id concurrently.
|
||||
base::LazySequencedTaskRunner g_get_network_id_task_runner =
|
||||
LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::ThreadPool(),
|
||||
base::MayBlock(),
|
||||
base::LazyThreadPoolSequencedTaskRunner g_get_network_id_task_runner =
|
||||
LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
|
||||
base::TaskTraits(base::MayBlock(),
|
||||
base::TaskPriority::BEST_EFFORT,
|
||||
base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN));
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user