blob: 4cdb4590df5d1984270998eee4228c32e4291692 [file] [log] [blame]
Devlin Cronin40b4cbc2017-08-02 01:57:591// 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
5#include "extensions/browser/extension_file_task_runner.h"
6
7#include "base/sequenced_task_runner.h"
Gabriel Charette44db1422018-08-06 11:19:338#include "base/task/lazy_task_runner.h"
9#include "base/task/task_traits.h"
Devlin Cronin40b4cbc2017-08-02 01:57:5910
11namespace extensions {
12
13namespace {
14
15// Note: All tasks posted to a single task runner have the same priority. This
16// is unfortunate, since some file-related tasks are high priority (like serving
17// a file from the extension protocols or loading an extension in response to a
18// user action), and others are low priority (like garbage collection). Split
19// the difference and use USER_VISIBLE, which is the default priority and what a
20// task posted to a named thread (like the FILE thread) would receive.
21base::LazySequencedTaskRunner g_task_runner =
22 LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER(
Sami Kyostilac9580452019-06-17 12:26:2723 base::TaskTraits(base::ThreadPool(),
24 base::MayBlock(),
Devlin Cronin40b4cbc2017-08-02 01:57:5925 base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN,
26 base::TaskPriority::USER_VISIBLE));
27
28} // namespace
29
30scoped_refptr<base::SequencedTaskRunner> GetExtensionFileTaskRunner() {
31 return g_task_runner.Get();
32}
33
34} // namespace extensions