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

Unified Diff: device/bluetooth/bluetooth_gatt_descriptor.cc

Issue 258173003: Remove static initializer in device/bluetooth/bluetooth_gatt_descriptor.cc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update unit tests Created 6 years, 8 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
« no previous file with comments | « device/bluetooth/bluetooth_gatt_descriptor.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
}
« no previous file with comments | « device/bluetooth/bluetooth_gatt_descriptor.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698