Index: device/bluetooth/bluetooth_gatt_descriptor.cc |
diff --git a/device/bluetooth/bluetooth_gatt_descriptor.cc b/device/bluetooth/bluetooth_gatt_descriptor.cc |
index 3af5a9f541a045e00ea98c4c470020e36d167acd..5d3673b5ea36e9a886741270e530b4162ecc3b09 100644 |
--- a/device/bluetooth/bluetooth_gatt_descriptor.cc |
+++ b/device/bluetooth/bluetooth_gatt_descriptor.cc |
@@ -4,22 +4,73 @@ |
#include "device/bluetooth/bluetooth_gatt_descriptor.h" |
+#include <vector> |
+ |
+#include "base/lazy_instance.h" |
#include "base/logging.h" |
+#include "base/macros.h" |
namespace device { |
+namespace { |
+ |
+struct UUIDs { |
+ UUIDs() : uuids_(MakeUUIDVector()) {} |
+ |
+ const std::vector<BluetoothUUID> uuids_; |
+ |
+ private: |
+ static std::vector<BluetoothUUID> MakeUUIDVector() { |
+ std::vector<BluetoothUUID> uuids; |
+ static const char* const strings[] = { |
+ "0x2900", "0x2901", "0x2902", "0x2903", "0x2904", "0x2905" |
+ }; |
+ |
+ for (size_t i = 0; i < arraysize(strings); ++i) |
+ uuids.push_back(BluetoothUUID(strings[i])); |
+ |
+ return uuids; |
+ } |
+}; |
+ |
+base::LazyInstance<const UUIDs>::Leaky g_uuids = LAZY_INSTANCE_INITIALIZER; |
-const BluetoothUUID BluetoothGattDescriptor:: |
- kCharacteristicExtendedPropertiesUuid("2900"); |
-const BluetoothUUID BluetoothGattDescriptor:: |
- kCharacteristicUserDescriptionUuid("2901"); |
-const BluetoothUUID BluetoothGattDescriptor:: |
- kClientCharacteristicConfigurationUuid("2902"); |
-const BluetoothUUID BluetoothGattDescriptor:: |
- kServerCharacteristicConfigurationUuid("2903"); |
-const BluetoothUUID BluetoothGattDescriptor:: |
- kCharacteristicPresentationFormatUuid("2904"); |
-const BluetoothUUID BluetoothGattDescriptor:: |
- kCharacteristicAggregateFormatUuid("2905"); |
+} // namespace |
+ |
+// static |
+const BluetoothUUID& |
+BluetoothGattDescriptor::CharacteristicExtendedPropertiesUuid() { |
+ return g_uuids.Get().uuids_[0]; |
+} |
+ |
+// static |
+const BluetoothUUID& |
+BluetoothGattDescriptor::CharacteristicUserDescriptionUuid() { |
+ return g_uuids.Get().uuids_[1]; |
+} |
+ |
+// static |
+const BluetoothUUID& |
+BluetoothGattDescriptor::ClientCharacteristicConfigurationUuid() { |
+ return g_uuids.Get().uuids_[2]; |
+} |
+ |
+// static |
+const BluetoothUUID& |
+BluetoothGattDescriptor::ServerCharacteristicConfigurationUuid() { |
+ return g_uuids.Get().uuids_[3]; |
+} |
+ |
+// static |
+const BluetoothUUID& |
+BluetoothGattDescriptor::CharacteristicPresentationFormatUuid() { |
+ return g_uuids.Get().uuids_[4]; |
+} |
+ |
+// static |
+const BluetoothUUID& |
+BluetoothGattDescriptor::CharacteristicAggregateFormatUuid() { |
+ return g_uuids.Get().uuids_[5]; |
+} |
BluetoothGattDescriptor::BluetoothGattDescriptor() { |
} |