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

Unified Diff: components/arc/bluetooth/arc_bluetooth_bridge.cc

Issue 2319953002: arc: bluetooth: Implement socket opening (Closed)
Patch Set: Created 4 years, 3 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 | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | components/arc/common/bluetooth.mojom » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 d61d26f96d5ea195df162f65af9adbdf20ce2d91..4069e877f3696eacb0febaa5093a9e42ef8233cf 100644
--- a/components/arc/bluetooth/arc_bluetooth_bridge.cc
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.cc
@@ -4,8 +4,10 @@
#include "components/arc/bluetooth/arc_bluetooth_bridge.h"
+#include <bluetooth/bluetooth.h>
#include <fcntl.h>
#include <stddef.h>
+#include <sys/socket.h>
#include <iomanip>
#include <string>
@@ -25,6 +27,8 @@
#include "device/bluetooth/bluetooth_gatt_notify_session.h"
#include "device/bluetooth/bluetooth_local_gatt_characteristic.h"
#include "device/bluetooth/bluetooth_local_gatt_descriptor.h"
+#include "mojo/edk/embedder/embedder.h"
+#include "mojo/edk/embedder/scoped_platform_handle.h"
using device::BluetoothAdapter;
using device::BluetoothAdapterFactory;
@@ -1341,6 +1345,29 @@ void ArcBluetoothBridge::SendIndication(
mojo::Array<uint8_t> value,
const SendIndicationCallback& callback) {}
+void ArcBluetoothBridge::OpenBluetoothSocket(
+ const OpenBluetoothSocketCallback& callback) {
+ base::ScopedFD sock(socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM));
+ if (!sock.is_valid()) {
+ LOG(ERROR) << "Failed to open socket.";
+ callback.Run(mojo::ScopedHandle());
+ return;
+ }
+ 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";
}
« no previous file with comments | « components/arc/bluetooth/arc_bluetooth_bridge.h ('k') | components/arc/common/bluetooth.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698