Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Unified Diff: device/usb/usb_service.cc

Issue 2849953003: Use the task scheduler for blocking tasks in the USB service on Linux (Closed)
Patch Set: Remove more passing of the SequencedTaskRunner Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/usb/usb_service.h ('k') | device/usb/usb_service_android.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_service.cc
diff --git a/device/usb/usb_service.cc b/device/usb/usb_service.cc
index b560cd0c36441dae85e6dd3bfd4cc814037009fa..1349b73c82b86209539d4463cee3db7cae915a5a 100644
--- a/device/usb/usb_service.cc
+++ b/device/usb/usb_service.cc
@@ -8,6 +8,7 @@
#include "base/feature_list.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
+#include "base/task_scheduler/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
#include "components/device_event_log/device_event_log.h"
@@ -46,9 +47,9 @@ void UsbService::Observer::WillDestroyUsbService() {}
std::unique_ptr<UsbService> UsbService::Create(
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner) {
#if defined(OS_ANDROID)
- return base::WrapUnique(new UsbServiceAndroid(blocking_task_runner));
+ return base::WrapUnique(new UsbServiceAndroid());
#elif defined(USE_UDEV)
- return base::WrapUnique(new UsbServiceLinux(blocking_task_runner));
+ return base::WrapUnique(new UsbServiceLinux());
#elif defined(OS_WIN)
if (base::FeatureList::IsEnabled(kNewUsbBackend))
return base::WrapUnique(new UsbServiceWin(blocking_task_runner));
@@ -61,6 +62,17 @@ std::unique_ptr<UsbService> UsbService::Create(
#endif
}
+// static
+scoped_refptr<base::SequencedTaskRunner>
+UsbService::CreateBlockingTaskRunner() {
+ return base::CreateSequencedTaskRunnerWithTraits(
+ base::TaskTraits()
+ .MayBlock()
+ .WithPriority(base::TaskPriority::USER_VISIBLE)
+ .WithShutdownBehavior(
+ base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN));
+}
+
UsbService::~UsbService() {
#if DCHECK_IS_ON()
DCHECK(did_shutdown_);
« no previous file with comments | « device/usb/usb_service.h ('k') | device/usb/usb_service_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698