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

Unified Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc

Issue 402303002: bluetoothLowEnergy: Send onServiceAdded after all characteristics are discovered (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
diff --git a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
index b5f5afd47a01d60643794550ffefa50563c1f313..4baeb27adcaf5a3247299ddc4b4b3b8e230a7f70 100644
--- a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
+++ b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc
@@ -855,16 +855,6 @@ void BluetoothLowEnergyEventRouter::GattServiceAdded(
const std::string& service_id = service->GetIdentifier();
observed_gatt_services_.insert(service_id);
service_id_to_device_address_[service_id] = device->GetAddress();
-
- // Signal API event.
- apibtle::Service api_service;
- PopulateService(service, &api_service);
-
- scoped_ptr<base::ListValue> args =
- apibtle::OnServiceAdded::Create(api_service);
- scoped_ptr<Event> event(
- new Event(apibtle::OnServiceAdded::kEventName, args.Pass()));
- EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass());
}
void BluetoothLowEnergyEventRouter::GattServiceRemoved(
@@ -896,6 +886,27 @@ void BluetoothLowEnergyEventRouter::GattServiceRemoved(
EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass());
}
+void BluetoothLowEnergyEventRouter::GattDiscoveryCompleteForService(
+ BluetoothGattService* service) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ VLOG(2) << "GATT service discovery complete: " << service->GetIdentifier();
+
+ DCHECK(observed_gatt_services_.find(service->GetIdentifier()) !=
+ observed_gatt_services_.end());
+ DCHECK(service_id_to_device_address_.find(service->GetIdentifier()) !=
+ service_id_to_device_address_.end());
+
+ // Signal the service added event here.
+ apibtle::Service api_service;
+ PopulateService(service, &api_service);
+
+ scoped_ptr<base::ListValue> args =
+ apibtle::OnServiceAdded::Create(api_service);
+ scoped_ptr<Event> event(
+ new Event(apibtle::OnServiceAdded::kEventName, args.Pass()));
+ EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass());
+}
+
void BluetoothLowEnergyEventRouter::GattServiceChanged(
BluetoothGattService* service) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));

Powered by Google App Engine
This is Rietveld 408576698