| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event
_router.h" | 5 #include "extensions/browser/api/bluetooth_low_energy/bluetooth_low_energy_event
_router.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 using content::BrowserThread; | 22 using content::BrowserThread; |
| 23 | 23 |
| 24 using device::BluetoothAdapter; | 24 using device::BluetoothAdapter; |
| 25 using device::BluetoothAdapterFactory; | 25 using device::BluetoothAdapterFactory; |
| 26 using device::BluetoothDevice; | 26 using device::BluetoothDevice; |
| 27 using device::BluetoothGattCharacteristic; | 27 using device::BluetoothGattCharacteristic; |
| 28 using device::BluetoothGattConnection; | 28 using device::BluetoothGattConnection; |
| 29 using device::BluetoothGattDescriptor; | 29 using device::BluetoothGattDescriptor; |
| 30 using device::BluetoothGattService; | 30 using device::BluetoothGattService; |
| 31 | 31 |
| 32 namespace apibtle = extensions::core_api::bluetooth_low_energy; | 32 namespace apibtle = extensions::api::bluetooth_low_energy; |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 void PopulateService(const BluetoothGattService* service, | 36 void PopulateService(const BluetoothGattService* service, |
| 37 apibtle::Service* out) { | 37 apibtle::Service* out) { |
| 38 DCHECK(out); | 38 DCHECK(out); |
| 39 | 39 |
| 40 out->uuid = service->GetUUID().canonical_value(); | 40 out->uuid = service->GetUUID().canonical_value(); |
| 41 out->is_primary = service->IsPrimary(); | 41 out->is_primary = service->IsPrimary(); |
| 42 out->is_local = service->IsLocal(); | 42 out->is_local = service->IsLocal(); |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 539 out_descriptors->push_back(api_descriptor); | 539 out_descriptors->push_back(api_descriptor); |
| 540 } | 540 } |
| 541 | 541 |
| 542 return kStatusSuccess; | 542 return kStatusSuccess; |
| 543 } | 543 } |
| 544 | 544 |
| 545 BluetoothLowEnergyEventRouter::Status | 545 BluetoothLowEnergyEventRouter::Status |
| 546 BluetoothLowEnergyEventRouter::GetDescriptor( | 546 BluetoothLowEnergyEventRouter::GetDescriptor( |
| 547 const Extension* extension, | 547 const Extension* extension, |
| 548 const std::string& instance_id, | 548 const std::string& instance_id, |
| 549 core_api::bluetooth_low_energy::Descriptor* out_descriptor) const { | 549 api::bluetooth_low_energy::Descriptor* out_descriptor) const { |
| 550 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 550 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 551 DCHECK(extension); | 551 DCHECK(extension); |
| 552 DCHECK(out_descriptor); | 552 DCHECK(out_descriptor); |
| 553 if (!adapter_.get()) { | 553 if (!adapter_.get()) { |
| 554 VLOG(1) << "BluetoothAdapter not ready."; | 554 VLOG(1) << "BluetoothAdapter not ready."; |
| 555 return kStatusErrorFailed; | 555 return kStatusErrorFailed; |
| 556 } | 556 } |
| 557 | 557 |
| 558 BluetoothGattDescriptor* descriptor = FindDescriptorById(instance_id); | 558 BluetoothGattDescriptor* descriptor = FindDescriptorById(instance_id); |
| 559 if (!descriptor) { | 559 if (!descriptor) { |
| (...skipping 931 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1491 continue; | 1491 continue; |
| 1492 | 1492 |
| 1493 manager->Remove(extension_id, *iter); | 1493 manager->Remove(extension_id, *iter); |
| 1494 return true; | 1494 return true; |
| 1495 } | 1495 } |
| 1496 | 1496 |
| 1497 return false; | 1497 return false; |
| 1498 } | 1498 } |
| 1499 | 1499 |
| 1500 } // namespace extensions | 1500 } // namespace extensions |
| OLD | NEW |