summaryrefslogtreecommitdiff
path: root/chromium/components/arc/usb/usb_host_bridge.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/components/arc/usb/usb_host_bridge.cc')
-rw-r--r--chromium/components/arc/usb/usb_host_bridge.cc36
1 files changed, 16 insertions, 20 deletions
diff --git a/chromium/components/arc/usb/usb_host_bridge.cc b/chromium/components/arc/usb/usb_host_bridge.cc
index b88ab1a9e30..860c29c5b77 100644
--- a/chromium/components/arc/usb/usb_host_bridge.cc
+++ b/chromium/components/arc/usb/usb_host_bridge.cc
@@ -19,8 +19,7 @@
#include "device/usb/mojo/type_converters.h"
#include "device/usb/usb_device_handle.h"
#include "device/usb/usb_device_linux.h"
-#include "mojo/edk/embedder/embedder.h"
-#include "mojo/edk/embedder/scoped_platform_handle.h"
+#include "mojo/public/cpp/system/platform_handle.h"
namespace arc {
namespace {
@@ -51,18 +50,14 @@ void OnDeviceOpened(mojom::UsbHostHost::OpenDeviceCallback callback,
std::move(callback).Run(mojo::ScopedHandle());
return;
}
- mojo::edk::ScopedInternalPlatformHandle platform_handle{
- mojo::edk::InternalPlatformHandle(fd.release())};
- MojoHandle wrapped_handle;
- MojoResult wrap_result = mojo::edk::CreateInternalPlatformHandleWrapper(
- std::move(platform_handle), &wrapped_handle);
- if (wrap_result != MOJO_RESULT_OK) {
- LOG(ERROR) << "Failed to wrap device FD. Closing: " << wrap_result;
+ mojo::ScopedHandle wrapped_handle =
+ mojo::WrapPlatformHandle(mojo::PlatformHandle(std::move(fd)));
+ if (!wrapped_handle.is_valid()) {
+ LOG(ERROR) << "Failed to wrap device FD. Closing.";
std::move(callback).Run(mojo::ScopedHandle());
return;
}
- mojo::ScopedHandle scoped_handle{mojo::Handle(wrapped_handle)};
- std::move(callback).Run(std::move(scoped_handle));
+ std::move(callback).Run(std::move(wrapped_handle));
}
void OnDeviceOpenError(mojom::UsbHostHost::OpenDeviceCallback callback,
@@ -223,8 +218,8 @@ void ArcUsbHostBridge::OnDeviceRemoved(
return;
}
- usb_host_instance->OnDeviceRemoved(
- device.get()->guid(), GetEventReceiverPackages(device.get()->guid()));
+ usb_host_instance->OnDeviceRemoved(device.get()->guid(),
+ GetEventReceiverPackages(device));
if (ui_delegate_)
ui_delegate_->DeviceRemoved(device.get()->guid());
@@ -260,10 +255,9 @@ void ArcUsbHostBridge::SetUiDelegate(ArcUsbHostUiDelegate* ui_delegate) {
}
std::vector<std::string> ArcUsbHostBridge::GetEventReceiverPackages(
- const std::string& guid) {
- scoped_refptr<device::UsbDevice> device = usb_service_->GetDevice(guid);
- if (!device.get()) {
- LOG(WARNING) << "Unknown USB device " << guid;
+ scoped_refptr<device::UsbDevice> device) {
+ if (!device) {
+ LOG(WARNING) << "Unknown USB device.";
return std::vector<std::string>();
}
@@ -271,7 +265,8 @@ std::vector<std::string> ArcUsbHostBridge::GetEventReceiverPackages(
return std::vector<std::string>();
std::unordered_set<std::string> receivers = ui_delegate_->GetEventPackageList(
- guid, device->serial_number(), device->vendor_id(), device->product_id());
+ device->guid(), device->serial_number(), device->vendor_id(),
+ device->product_id());
return std::vector<std::string>(receivers.begin(), receivers.end());
}
@@ -288,10 +283,11 @@ void ArcUsbHostBridge::OnDeviceChecked(const std::string& guid, bool allowed) {
mojom::UsbHostInstance* usb_host_instance = ARC_GET_INSTANCE_FOR_METHOD(
arc_bridge_service_->usb_host(), OnDeviceAdded);
- if (!usb_host_instance)
+ if (!usb_host_instance || !usb_service_)
return;
- usb_host_instance->OnDeviceAdded(guid, GetEventReceiverPackages(guid));
+ usb_host_instance->OnDeviceAdded(
+ guid, GetEventReceiverPackages(usb_service_->GetDevice(guid)));
}
void ArcUsbHostBridge::DoRequestUserAuthorization(