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

Unified Diff: device/usb/usb_service_impl.cc

Issue 2857473002: Use the task scheduler in the USB service on macOS and Windows (Closed)
Patch Set: Add AssertIOAllowed 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_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_service_impl.cc
diff --git a/device/usb/usb_service_impl.cc b/device/usb/usb_service_impl.cc
index 2408eb4b32e06af9ff2dc5f4e33116681fce8cbd..dba15d978a1564ddab092ba409003bb6a0e41f04 100644
--- a/device/usb/usb_service_impl.cc
+++ b/device/usb/usb_service_impl.cc
@@ -19,6 +19,7 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "base/task_scheduler/post_task.h"
#include "build/build_config.h"
#include "components/device_event_log/device_event_log.h"
#include "device/usb/usb_device_handle.h"
@@ -216,15 +217,19 @@ void OnDeviceOpenedReadDescriptors(
} // namespace
-UsbServiceImpl::UsbServiceImpl(
- scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_in)
- : UsbService(std::move(blocking_task_runner_in)),
+UsbServiceImpl::UsbServiceImpl()
+ : UsbService(nullptr),
#if defined(OS_WIN)
device_observer_(this),
#endif
weak_factory_(this) {
- blocking_task_runner()->PostTask(
+ base::PostTaskWithTraits(
FROM_HERE,
+ base::TaskTraits()
+ .MayBlock()
+ .WithPriority(base::TaskPriority::USER_VISIBLE)
+ .WithShutdownBehavior(
+ base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
base::Bind(&InitializeUsbContextOnBlockingThread, task_runner(),
base::Bind(&UsbServiceImpl::OnUsbContext,
weak_factory_.GetWeakPtr())));
@@ -324,11 +329,17 @@ void UsbServiceImpl::RefreshDevices() {
pending_path_enumerations_.pop();
}
- blocking_task_runner()->PostTask(
+ base::PostTaskWithTraits(
FROM_HERE,
+ base::TaskTraits()
+ .MayBlock()
+ .WithPriority(base::TaskPriority::USER_VISIBLE)
+ .WithShutdownBehavior(
+ base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN),
base::Bind(&GetDeviceListOnBlockingThread, device_path, context_,
- task_runner(), base::Bind(&UsbServiceImpl::OnDeviceList,
- weak_factory_.GetWeakPtr())));
+ task_runner(),
+ base::Bind(&UsbServiceImpl::OnDeviceList,
+ weak_factory_.GetWeakPtr())));
}
void UsbServiceImpl::OnDeviceList(libusb_device** platform_devices,
@@ -437,8 +448,8 @@ void UsbServiceImpl::EnumerateDevice(PlatformUsbDevice platform_device,
return;
}
- scoped_refptr<UsbDeviceImpl> device(new UsbDeviceImpl(
- context_, platform_device, descriptor, blocking_task_runner()));
+ scoped_refptr<UsbDeviceImpl> device(
+ new UsbDeviceImpl(context_, platform_device, descriptor));
base::Closure add_device =
base::Bind(&UsbServiceImpl::AddDevice, weak_factory_.GetWeakPtr(),
refresh_complete, device);
« no previous file with comments | « device/usb/usb_service_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698