Chromium Code Reviews| Index: components/arc/bluetooth/arc_bluetooth_bridge.cc |
| diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.cc b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| index 5042636b7465a062c41a05f768b4253c6e6f05a4..8a4017e29ee0085e311079818a6cec2847f4f7d7 100644 |
| --- a/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| +++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc |
| @@ -3,6 +3,8 @@ |
| // found in the LICENSE file. |
| #include "components/arc/bluetooth/arc_bluetooth_bridge.h" |
| +#include <bluetooth/bluetooth.h> |
| +#include <sys/socket.h> |
|
Luis Héctor Chávez
2016/07/20 23:16:38
nit: these need to be together with the rest of th
|
| #include <fcntl.h> |
| #include <stddef.h> |
| @@ -10,6 +12,8 @@ |
| #include <iomanip> |
| #include <string> |
| #include <utility> |
| +#include "mojo/edk/embedder/embedder.h" |
| +#include "mojo/edk/embedder/scoped_platform_handle.h" |
|
Luis Héctor Chávez
2016/07/20 23:16:38
nit: these need to be together with the rest of th
|
| #include "base/bind.h" |
| #include "base/logging.h" |
| @@ -1023,6 +1027,24 @@ void ArcBluetoothBridge::ReadRemoteRssi( |
| callback.Run(rssi); |
| } |
| +void ArcBluetoothBridge::OpenBluetoothSocket( |
| + const OpenBluetoothSocketCallback& callback) { |
| + base::ScopedFD sock(socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM)); |
|
Luis Héctor Chávez
2016/07/20 23:16:38
nit: can you do
if (!sock.is_valid()) {
LOG(...
|
| + mojo::edk::ScopedPlatformHandle platform_handle{ |
| + mojo::edk::PlatformHandle(sock.release())}; |
| + MojoHandle wrapped_handle; |
| + MojoResult wrap_result = mojo::edk::CreatePlatformHandleWrapper( |
| + std::move(platform_handle), &wrapped_handle); |
| + if (wrap_result != MOJO_RESULT_OK) { |
| + LOG(ERROR) << "Failed to wrap handles. Closing: " << wrap_result; |
| + callback.Run(mojo::ScopedHandle()); |
| + return; |
| + } |
| + mojo::ScopedHandle scoped_handle{mojo::Handle(wrapped_handle)}; |
| + |
| + callback.Run(std::move(scoped_handle)); |
| +} |
| + |
| void ArcBluetoothBridge::OnDiscoveryError() { |
| LOG(WARNING) << "failed to change discovery state"; |
| } |