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

Unified Diff: device/hid/hid_service_mac.cc

Issue 660573007: Open HID connections asynchronously. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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/hid/hid_service_mac.h ('k') | device/hid/hid_service_win.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_service_mac.cc
diff --git a/device/hid/hid_service_mac.cc b/device/hid/hid_service_mac.cc
index c32ebb47f934ee1b3b1152d4171b991dbfbcd8ec..4723668f4a8f59f88d00d717c0f9fd6a4caaaa7b 100644
--- a/device/hid/hid_service_mac.cc
+++ b/device/hid/hid_service_mac.cc
@@ -259,13 +259,14 @@ void HidServiceMac::RemoveDevices() {
}
}
-scoped_refptr<HidConnection> HidServiceMac::Connect(
- const HidDeviceId& device_id) {
+void HidServiceMac::Connect(const HidDeviceId& device_id,
+ const ConnectCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
const auto& map_entry = devices().find(device_id);
if (map_entry == devices().end()) {
- return NULL;
+ task_runner_->PostTask(FROM_HERE, base::Bind(callback, nullptr));
+ return;
}
const HidDeviceInfo& device_info = map_entry->second;
@@ -275,7 +276,8 @@ scoped_refptr<HidConnection> HidServiceMac::Connect(
IORegistryEntryFromPath(kIOMasterPortDefault, service_path));
if (!service.get()) {
VLOG(1) << "IOService not found for path: " << device_id;
- return NULL;
+ task_runner_->PostTask(FROM_HERE, base::Bind(callback, nullptr));
+ return;
}
base::ScopedCFTypeRef<IOHIDDeviceRef> hid_device(
@@ -284,11 +286,15 @@ scoped_refptr<HidConnection> HidServiceMac::Connect(
if (result != kIOReturnSuccess) {
VLOG(1) << "Failed to open device: "
<< base::StringPrintf("0x%04x", result);
- return NULL;
+ task_runner_->PostTask(FROM_HERE, base::Bind(callback, nullptr));
+ return;
}
- return make_scoped_refptr(new HidConnectionMac(
- hid_device.release(), device_info, file_task_runner_));
+ task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(callback,
+ make_scoped_refptr(new HidConnectionMac(
+ hid_device.release(), device_info, file_task_runner_))));
}
} // namespace device
« no previous file with comments | « device/hid/hid_service_mac.h ('k') | device/hid/hid_service_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698