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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_UUID_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_UUID_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_UUID_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_UUID_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/pickle.h" | |
11 #include "device/bluetooth/bluetooth_export.h" | 10 #include "device/bluetooth/bluetooth_export.h" |
12 #include "ipc/ipc_param_traits.h" | |
13 | |
14 namespace base { | |
15 class Pickle; | |
16 class PickleIterator; | |
17 } // namespace base | |
18 | 11 |
19 namespace device { | 12 namespace device { |
20 | 13 |
21 // Opaque wrapper around a Bluetooth UUID. Instances of UUID represent the | 14 // Opaque wrapper around a Bluetooth UUID. Instances of UUID represent the |
22 // 128-bit universally unique identifiers (UUIDs) of profiles and attributes | 15 // 128-bit universally unique identifiers (UUIDs) of profiles and attributes |
23 // used in Bluetooth based communication, such as a peripheral's services, | 16 // used in Bluetooth based communication, such as a peripheral's services, |
24 // characteristics, and characteristic descriptors. An instance are | 17 // characteristics, and characteristic descriptors. An instance are |
25 // constructed using a string representing 16, 32, or 128 bit UUID formats. | 18 // constructed using a string representing 16, 32, or 128 bit UUID formats. |
26 class DEVICE_BLUETOOTH_EXPORT BluetoothUUID { | 19 class DEVICE_BLUETOOTH_EXPORT BluetoothUUID { |
27 public: | 20 public: |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 std::string value_; | 88 std::string value_; |
96 | 89 |
97 // The 128-bit string representation of the UUID. | 90 // The 128-bit string representation of the UUID. |
98 std::string canonical_value_; | 91 std::string canonical_value_; |
99 }; | 92 }; |
100 | 93 |
101 // This is required by gtest to print a readable output on test failures. | 94 // This is required by gtest to print a readable output on test failures. |
102 void DEVICE_BLUETOOTH_EXPORT | 95 void DEVICE_BLUETOOTH_EXPORT |
103 PrintTo(const BluetoothUUID& uuid, std::ostream* out); | 96 PrintTo(const BluetoothUUID& uuid, std::ostream* out); |
104 | 97 |
| 98 struct BluetoothUUIDHash { |
| 99 size_t operator()(const device::BluetoothUUID& uuid) const { |
| 100 return std::hash<std::string>()(uuid.canonical_value()); |
| 101 } |
| 102 }; |
| 103 |
105 } // namespace device | 104 } // namespace device |
106 | 105 |
107 namespace IPC { | |
108 | |
109 class Message; | |
110 | |
111 // Tell the IPC system how to serialize and deserialize a BluetoothUUID. | |
112 template <> | |
113 struct DEVICE_BLUETOOTH_EXPORT ParamTraits<device::BluetoothUUID> { | |
114 typedef device::BluetoothUUID param_type; | |
115 static void GetSize(base::PickleSizer* s, const param_type& p); | |
116 static void Write(base::Pickle* m, const param_type& p); | |
117 static bool Read(const base::Pickle* m, | |
118 base::PickleIterator* iter, | |
119 param_type* r); | |
120 static void Log(const param_type& p, std::string* l); | |
121 }; | |
122 | |
123 } // namespace IPC | |
124 | |
125 #endif // DEVICE_BLUETOOTH_BLUETOOTH_UUID_H_ | 106 #endif // DEVICE_BLUETOOTH_BLUETOOTH_UUID_H_ |
OLD | NEW |