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

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

Issue 287673002: chrome.bluetoothLowEnergy: Implement the onDescriptorValueChanged event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 7 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 d5320d7260a8caf18ae053e8de740f4764473e4e..83d8a63fde33f7f821cdbbaa51b08c423c9fbece 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
@@ -638,6 +638,24 @@ void BluetoothLowEnergyEventRouter::GattDescriptorValueChanged(
const std::vector<uint8>& value) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
VLOG(2) << "GATT descriptor value changed: " << descriptor->GetIdentifier();
+
+ DCHECK(desc_id_to_chrc_id_.find(descriptor->GetIdentifier()) !=
+ desc_id_to_chrc_id_.end());
+ DCHECK(characteristic->GetIdentifier() ==
+ desc_id_to_chrc_id_[descriptor->GetIdentifier()]);
+
+ // Signal API event.
+ apibtle::Descriptor api_descriptor;
+ PopulateDescriptor(descriptor, &api_descriptor);
+
+ // Manually construct the arguments, instead of using
+ // apibtle::OnDescriptorValueChanged::Create, as it doesn't convert lists of
+ // enums correctly.
+ scoped_ptr<base::ListValue> args(new base::ListValue());
+ args->Append(apibtle::DescriptorToValue(&api_descriptor).release());
+ scoped_ptr<Event> event(
+ new Event(apibtle::OnDescriptorValueChanged::kEventName, args.Pass()));
+ EventRouter::Get(browser_context_)->BroadcastEvent(event.Pass());
}
void BluetoothLowEnergyEventRouter::OnGetAdapter(

Powered by Google App Engine
This is Rietveld 408576698