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

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

Issue 2256003002: components/arc: implement multi advertising (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@plumb-incoming-connections
Patch Set: swap CHECK_EQ for EXPECT_EQ Created 4 years, 4 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
Index: components/arc/bluetooth/arc_bluetooth_bridge.h
diff --git a/components/arc/bluetooth/arc_bluetooth_bridge.h b/components/arc/bluetooth/arc_bluetooth_bridge.h
index c1a6ade02b395302cca0302fb0cefdd8e0974edb..3dc6c5aa0ed8929047c2c692313ff89b05156c0c 100644
--- a/components/arc/bluetooth/arc_bluetooth_bridge.h
+++ b/components/arc/bluetooth/arc_bluetooth_bridge.h
@@ -19,6 +19,7 @@
#include "components/arc/instance_holder.h"
#include "device/bluetooth/bluetooth_adapter.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
+#include "device/bluetooth/bluetooth_advertisement.h"
#include "device/bluetooth/bluetooth_device.h"
#include "device/bluetooth/bluetooth_discovery_session.h"
#include "device/bluetooth/bluetooth_local_gatt_service.h"
@@ -266,6 +267,17 @@ class ArcBluetoothBridge
mojo::Array<uint8_t> value,
const SendIndicationCallback& callback) override;
+ // Set up or disable multiple advertising.
+ void ReserveAdvertisementHandle(
+ const ReserveAdvertisementHandleCallback& callback) override;
+ void BroadcastAdvertisement(
+ int32_t adv_handle,
+ mojom::BluetoothAdvertisementPtr advertisement,
+ const BroadcastAdvertisementCallback& callback) override;
+ void ReleaseAdvertisementHandle(
+ int32_t adv_handle,
+ const ReleaseAdvertisementHandleCallback& callback) override;
+
// Chrome observer callbacks
void OnPoweredOn(
const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
@@ -360,6 +372,42 @@ class ArcBluetoothBridge
const base::Closure& success_callback,
const ErrorCallback& error_callback);
+ // Callbacks for managing advertisements registered from the instance.
+
+ // Called when we have an open slot in the advertisement map and want to
+ // register the advertisement given by |data| for handle |adv_handle|.
+ void OnReadyToRegisterAdvertisement(
+ const BroadcastAdvertisementCallback& callback,
+ int32_t adv_handle,
+ std::unique_ptr<device::BluetoothAdvertisement::Data> data);
+ // Called when we've successfully registered a new advertisement for
+ // handle |adv_handle|.
+ void OnRegisterAdvertisementDone(
+ const BroadcastAdvertisementCallback& callback,
+ int32_t adv_handle,
+ scoped_refptr<device::BluetoothAdvertisement> advertisement);
+ // Called when the attempt to register an advertisement for handle
+ // |adv_handle| has failed. |adv_handle| remains reserved, but no
+ // advertisement is associated with it.
+ void OnRegisterAdvertisementError(
+ const BroadcastAdvertisementCallback& callback,
+ int32_t adv_handle,
+ device::BluetoothAdvertisement::ErrorCode error_code);
+ // Both of the following are called after we've tried to unregister
+ // the advertisement for |adv_handle|. Either way, we will no
+ // longer be broadcasting this advertisement, so in either case, the
+ // handle can be released.
+ void OnUnregisterAdvertisementDone(
+ const ReleaseAdvertisementHandleCallback& callback,
+ int32_t adv_handle);
+ void OnUnregisterAdvertisementError(
+ const ReleaseAdvertisementHandleCallback& callback,
+ int32_t adv_handle,
+ device::BluetoothAdvertisement::ErrorCode error_code);
+ // Find the next free advertisement handle and put it in *adv_handle,
+ // or return false if the advertisement map is full.
+ bool GetAdvertisementHandle(int32_t* adv_handle);
+
bool CalledOnValidThread();
mojo::Binding<mojom::BluetoothHost> binding_;
@@ -381,6 +429,11 @@ class ArcBluetoothBridge
// Keeps track of all devices which initiated a GATT connection to us.
std::unordered_set<std::string> gatt_connection_cache_;
+ // Holds advertising data registered by the instance.
+ static constexpr uint16_t kMaxAdvertisements = 5;
+ std::map<int32_t, scoped_refptr<device::BluetoothAdvertisement>>
rickyz (no longer on Chrome) 2016/08/24 21:47:30 Did you see rkc's comment on using std::array for
Eric Caruso 2016/08/24 22:24:42 The design changed, and I got rid of Advertisement
+ advertisements_;
+
base::ThreadChecker thread_checker_;
// WeakPtrFactory to use for callbacks.
« no previous file with comments | « no previous file | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('j') | components/arc/bluetooth/arc_bluetooth_bridge.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698