value_store_task_runner.cc 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2021 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/value_store/value_store_task_runner.h"
  5. #include "base/task/lazy_thread_pool_task_runner.h"
  6. #include "base/task/sequenced_task_runner.h"
  7. #include "base/task/task_traits.h"
  8. namespace value_store {
  9. namespace {
  10. // Note: All tasks posted to a single task runner have the same priority. This
  11. // is unfortunate, since some file-related tasks are high priority, and others
  12. // are low priority (like garbage collection). Split the difference and use
  13. // USER_VISIBLE, which is the default priority and what a task posted to a
  14. // named thread (like the FILE thread) would receive.
  15. base::LazyThreadPoolSequencedTaskRunner g_task_runner =
  16. LAZY_THREAD_POOL_SEQUENCED_TASK_RUNNER_INITIALIZER(
  17. base::TaskTraits(base::MayBlock(),
  18. base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
  19. base::TaskPriority::USER_VISIBLE));
  20. } // namespace
  21. scoped_refptr<base::SequencedTaskRunner> GetValueStoreTaskRunner() {
  22. return g_task_runner.Get();
  23. }
  24. } // namespace value_store