dbus_thread_linux.cc 1.1 KB

1234567891011121314151617181920212223242526272829
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/dbus/thread_linux/dbus_thread_linux.h"
  5. #include "base/task/lazy_thread_pool_task_runner.h"
  6. namespace dbus_thread_linux {
  7. namespace {
  8. // Use TaskPriority::USER_BLOCKING, because there is a client
  9. // (NotificationPlatformBridgeLinuxImpl) which needs to run user-blocking tasks
  10. // on this thread. Use SingleThreadTaskRunnerThreadMode::SHARED, because DBus
  11. // does not require an exclusive use of the thread, only the existence of a
  12. // single thread for all tasks.
  13. base::LazyThreadPoolSingleThreadTaskRunner g_dbus_thread_task_runner =
  14. LAZY_THREAD_POOL_SINGLE_THREAD_TASK_RUNNER_INITIALIZER(
  15. base::TaskTraits(base::MayBlock(), base::TaskPriority::USER_BLOCKING),
  16. base::SingleThreadTaskRunnerThreadMode::SHARED);
  17. } // namespace
  18. scoped_refptr<base::SingleThreadTaskRunner> GetTaskRunner() {
  19. return g_dbus_thread_task_runner.Get();
  20. }
  21. } // namespace dbus_thread_linux