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

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: 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..7cb778eb17c80e6ba81928a008dbca966377b6b8 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,25 @@ class ArcBluetoothBridge
mojo::Array<uint8_t> value,
const SendIndicationCallback& callback) override;
+ // Set up or disable multiple advertising.
+ void EnableAdvertising(
rkc 2016/08/18 00:06:09 These functions are very, vague. Can we add commen
+ int32_t min_interval,
+ int32_t max_interval,
+ device::BluetoothAdvertisement::AdvertisementType adv_type,
+ int32_t channel_map,
+ int32_t tx_power,
+ int32_t timeout_s,
+ const EnableAdvertisingCallback& callback) override;
+ void SetAdvertisingData(
+ int32_t adv_handle,
+ bool include_name,
+ bool include_tx_power,
+ int32_t appearance,
rkc 2016/08/18 00:06:10 Document what |appearance| means.
+ mojo::Array<mojom::BluetoothAdvertisingDataPtr> adv_data,
+ const SetAdvertisingDataCallback& callback) override;
+ void DisableAdvertising(int32_t adv_handle,
rkc 2016/08/18 00:06:10 Document what this really does. Does it forget all
+ const DisableAdvertisingCallback& callback) override;
+
// Chrome observer callbacks
void OnPoweredOn(
const base::Callback<void(mojom::BluetoothAdapterState)>& callback) const;
@@ -312,6 +332,19 @@ class ArcBluetoothBridge
std::unique_ptr<device::BluetoothGattNotifySession> notify_session);
private:
+ // Structure to do bookkeeping for advertisements registered via
+ // multi advertisement across API calls.
+ struct InstanceAdvertisement {
rkc 2016/08/18 00:06:10 s/InstanceAdvertisement/AdvertisementInstance
+ bool in_use;
Luis Héctor Chávez 2016/08/18 04:29:13 data members should go at the end: https://engdoc.
+ device::BluetoothAdvertisement::AdvertisementType adv_type;
+ scoped_refptr<device::BluetoothAdvertisement> advertisement;
+
+ void Clear() {
+ advertisement = nullptr;
+ in_use = false;
+ }
+ };
+
mojo::Array<mojom::BluetoothPropertyPtr> GetDeviceProperties(
mojom::BluetoothPropertyType type,
device::BluetoothDevice* device) const;
@@ -360,6 +393,22 @@ class ArcBluetoothBridge
const base::Closure& success_callback,
const ErrorCallback& error_callback);
+ // Callbacks for managing multiple advertisements
+ void OnRegisterAdvertisementDone(
+ const SetAdvertisingDataCallback& callback,
+ int32_t adv_handle,
+ scoped_refptr<device::BluetoothAdvertisement> advertisement);
+ void OnRegisterAdvertisementError(
+ const SetAdvertisingDataCallback& callback,
+ int32_t adv_handle,
+ device::BluetoothAdvertisement::ErrorCode error_code);
+ void OnUnregisterAdvertisementDone(const DisableAdvertisingCallback& callback,
+ int32_t adv_handle);
+ void OnUnregisterAdvertisementError(
+ const DisableAdvertisingCallback& callback,
+ int32_t adv_handle,
+ device::BluetoothAdvertisement::ErrorCode error_code);
+
bool CalledOnValidThread();
mojo::Binding<mojom::BluetoothHost> binding_;
@@ -381,6 +430,12 @@ class ArcBluetoothBridge
// Keeps track of all devices which initiated a GATT connection to us.
std::unordered_set<std::string> gatt_connection_cache_;
+ // Copied from Android at system/bt/stack/btm/btm_ble_int.h
+ // https://goo.gl/k7PM6u
puthik_chromium 2016/08/17 23:22:04 This is wrong comment
+ static constexpr uint16_t kMaxAdvertisement = 5;
rkc 2016/08/18 00:06:10 s/kMaxAdvertisement/kMaxAdvertisements
+ // Holds advertising data registered by the instance.
+ InstanceAdvertisement advertisements_[kMaxAdvertisement];
rkc 2016/08/18 00:06:09 Instead of having this as a static array and needi
+
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