| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 out->instance_id.reset(new std::string(characteristic->GetIdentifier())); | 98 out->instance_id.reset(new std::string(characteristic->GetIdentifier())); |
| 99 | 99 |
| 100 PopulateService(characteristic->GetService(), &out->service); | 100 PopulateService(characteristic->GetService(), &out->service); |
| 101 PopulateCharacteristicProperties(characteristic->GetProperties(), | 101 PopulateCharacteristicProperties(characteristic->GetProperties(), |
| 102 &out->properties); | 102 &out->properties); |
| 103 | 103 |
| 104 const std::vector<uint8>& value = characteristic->GetValue(); | 104 const std::vector<uint8>& value = characteristic->GetValue(); |
| 105 if (value.empty()) | 105 if (value.empty()) |
| 106 return; | 106 return; |
| 107 | 107 |
| 108 out->value.reset(new std::string(value.begin(), value.end())); | 108 out->value.reset(new std::vector<char>(value.begin(), value.end())); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void PopulateDescriptor(const BluetoothGattDescriptor* descriptor, | 111 void PopulateDescriptor(const BluetoothGattDescriptor* descriptor, |
| 112 apibtle::Descriptor* out) { | 112 apibtle::Descriptor* out) { |
| 113 DCHECK(out); | 113 DCHECK(out); |
| 114 | 114 |
| 115 out->uuid = descriptor->GetUUID().canonical_value(); | 115 out->uuid = descriptor->GetUUID().canonical_value(); |
| 116 out->is_local = descriptor->IsLocal(); | 116 out->is_local = descriptor->IsLocal(); |
| 117 out->instance_id.reset(new std::string(descriptor->GetIdentifier())); | 117 out->instance_id.reset(new std::string(descriptor->GetIdentifier())); |
| 118 | 118 |
| 119 PopulateCharacteristic(descriptor->GetCharacteristic(), &out->characteristic); | 119 PopulateCharacteristic(descriptor->GetCharacteristic(), &out->characteristic); |
| 120 | 120 |
| 121 const std::vector<uint8>& value = descriptor->GetValue(); | 121 const std::vector<uint8>& value = descriptor->GetValue(); |
| 122 if (value.empty()) | 122 if (value.empty()) |
| 123 return; | 123 return; |
| 124 | 124 |
| 125 out->value.reset(new std::string(value.begin(), value.end())); | 125 out->value.reset(new std::vector<char>(value.begin(), value.end())); |
| 126 } | 126 } |
| 127 | 127 |
| 128 typedef extensions::ApiResourceManager<extensions::BluetoothLowEnergyConnection> | 128 typedef extensions::ApiResourceManager<extensions::BluetoothLowEnergyConnection> |
| 129 ConnectionResourceManager; | 129 ConnectionResourceManager; |
| 130 ConnectionResourceManager* GetConnectionResourceManager( | 130 ConnectionResourceManager* GetConnectionResourceManager( |
| 131 content::BrowserContext* context) { | 131 content::BrowserContext* context) { |
| 132 ConnectionResourceManager* manager = ConnectionResourceManager::Get(context); | 132 ConnectionResourceManager* manager = ConnectionResourceManager::Get(context); |
| 133 DCHECK(manager) | 133 DCHECK(manager) |
| 134 << "There is no Bluetooth low energy connection manager. " | 134 << "There is no Bluetooth low energy connection manager. " |
| 135 "If this assertion is failing during a test, then it is likely that " | 135 "If this assertion is failing during a test, then it is likely that " |
| (...skipping 1352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1488 continue; | 1488 continue; |
| 1489 | 1489 |
| 1490 manager->Remove(extension_id, *iter); | 1490 manager->Remove(extension_id, *iter); |
| 1491 return true; | 1491 return true; |
| 1492 } | 1492 } |
| 1493 | 1493 |
| 1494 return false; | 1494 return false; |
| 1495 } | 1495 } |
| 1496 | 1496 |
| 1497 } // namespace extensions | 1497 } // namespace extensions |
| OLD | NEW |