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

Unified Diff: extensions/browser/api/hid/hid_api.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 | « extensions/browser/api/hid/hid_api.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/hid/hid_api.cc
diff --git a/extensions/browser/api/hid/hid_api.cc b/extensions/browser/api/hid/hid_api.cc
index bbea4277ca37bd08db1a5ef325940633ce4603da..fcb8abf55951b422d4c913c158ec37cca5210fdf 100644
--- a/extensions/browser/api/hid/hid_api.cc
+++ b/extensions/browser/api/hid/hid_api.cc
@@ -141,38 +141,28 @@ bool HidConnectFunction::Prepare() {
}
void HidConnectFunction::AsyncWorkStart() {
- if (!device_manager_->GetDeviceInfo(parameters_->device_id, &device_info_)) {
+ HidDeviceInfo device_info;
+ if (!device_manager_->GetDeviceInfo(parameters_->device_id, &device_info)) {
CompleteWithError(kErrorInvalidDeviceId);
return;
}
- if (!device_manager_->HasPermission(extension(), device_info_)) {
+ if (!device_manager_->HasPermission(extension(), device_info)) {
LOG(WARNING) << "Insufficient permissions to access device.";
CompleteWithError(kErrorPermissionDenied);
return;
}
-#if defined(OS_CHROMEOS)
HidService* hid_service = device::DeviceClient::Get()->GetHidService();
DCHECK(hid_service);
- hid_service->RequestAccess(
- device_info_.device_id,
- base::Bind(&HidConnectFunction::OnRequestAccessComplete, this));
-#else
- OnRequestAccessComplete(true);
-#endif
-}
-void HidConnectFunction::OnRequestAccessComplete(bool success) {
- if (!success) {
- CompleteWithError(kErrorPermissionDenied);
- return;
- }
+ hid_service->Connect(
+ device_info.device_id,
+ base::Bind(&HidConnectFunction::OnConnectComplete, this));
+}
- HidService* hid_service = device::DeviceClient::Get()->GetHidService();
- DCHECK(hid_service);
- scoped_refptr<HidConnection> connection =
- hid_service->Connect(device_info_.device_id);
+void HidConnectFunction::OnConnectComplete(
+ scoped_refptr<HidConnection> connection) {
if (!connection.get()) {
CompleteWithError(kErrorFailedToOpenDevice);
return;
« no previous file with comments | « extensions/browser/api/hid/hid_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698