Devlin Cronin | 40b4cbc | 2017-08-02 01:57:59 | [diff] [blame] | 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 | |
| 5 | #include "extensions/browser/extension_file_task_runner.h" |
| 6 | |
| 7 | #include "base/sequenced_task_runner.h" |
Gabriel Charette | 44db142 | 2018-08-06 11:19:33 | [diff] [blame] | 8 | #include "base/task/lazy_task_runner.h" |
| 9 | #include "base/task/task_traits.h" |
Devlin Cronin | 40b4cbc | 2017-08-02 01:57:59 | [diff] [blame] | 10 | |
| 11 | namespace extensions { |
| 12 | |
| 13 | namespace { |
| 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. |
| 21 | base::LazySequencedTaskRunner g_task_runner = |
| 22 | LAZY_SEQUENCED_TASK_RUNNER_INITIALIZER( |
Sami Kyostila | c958045 | 2019-06-17 12:26:27 | [diff] [blame] | 23 | base::TaskTraits(base::ThreadPool(), |
| 24 | base::MayBlock(), |
Devlin Cronin | 40b4cbc | 2017-08-02 01:57:59 | [diff] [blame] | 25 | base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN, |
| 26 | base::TaskPriority::USER_VISIBLE)); |
| 27 | |
| 28 | } // namespace |
| 29 | |
| 30 | scoped_refptr<base::SequencedTaskRunner> GetExtensionFileTaskRunner() { |
| 31 | return g_task_runner.Get(); |
| 32 | } |
| 33 | |
| 34 | } // namespace extensions |