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_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ |
6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 // Retrieves the transport object path bound to |endpoint_path|. | 92 // Retrieves the transport object path bound to |endpoint_path|. |
93 dbus::ObjectPath GetTransportPath(const dbus::ObjectPath& endpoint_path); | 93 dbus::ObjectPath GetTransportPath(const dbus::ObjectPath& endpoint_path); |
94 | 94 |
95 private: | 95 private: |
96 // This class is used for simulating the scenario where each media endpoint | 96 // This class is used for simulating the scenario where each media endpoint |
97 // has a corresponding transport path and properties. Once an endpoint is | 97 // has a corresponding transport path and properties. Once an endpoint is |
98 // assigned with a transport path, an object of Transport is created. | 98 // assigned with a transport path, an object of Transport is created. |
99 struct Transport { | 99 struct Transport { |
100 Transport(const dbus::ObjectPath& transport_path, | 100 Transport(const dbus::ObjectPath& transport_path, |
101 Properties* transport_properties); | 101 std::unique_ptr<Properties> transport_properties); |
102 ~Transport(); | 102 ~Transport(); |
103 | 103 |
104 // An unique transport path. | 104 // An unique transport path. |
105 dbus::ObjectPath path; | 105 dbus::ObjectPath path; |
106 | 106 |
107 // The property set bound with |path|. | 107 // The property set bound with |path|. |
108 std::unique_ptr<Properties> properties; | 108 std::unique_ptr<Properties> properties; |
109 | 109 |
110 // This is the internal end of socketpair created for simulation purposes. | 110 // This is the internal end of socketpair created for simulation purposes. |
111 // |input_fd| will be initialized when Acquire/TryAcquire is called. | 111 // |input_fd| will be initialized when Acquire/TryAcquire is called. |
(...skipping 15 matching lines...) Expand all Loading... |
127 // Helper function used by Acquire and TryAcquire to set up the sockpair and | 127 // Helper function used by Acquire and TryAcquire to set up the sockpair and |
128 // invoke callback/error_callback. | 128 // invoke callback/error_callback. |
129 void AcquireInternal(bool try_flag, | 129 void AcquireInternal(bool try_flag, |
130 const dbus::ObjectPath& object_path, | 130 const dbus::ObjectPath& object_path, |
131 const AcquireCallback& callback, | 131 const AcquireCallback& callback, |
132 const ErrorCallback& error_callback); | 132 const ErrorCallback& error_callback); |
133 | 133 |
134 // Map of endpoints with valid transport. Each pair is composed of an endpoint | 134 // Map of endpoints with valid transport. Each pair is composed of an endpoint |
135 // path and a Transport structure containing a transport path and its | 135 // path and a Transport structure containing a transport path and its |
136 // properties. | 136 // properties. |
137 std::map<dbus::ObjectPath, Transport*> endpoint_to_transport_map_; | 137 std::map<dbus::ObjectPath, std::unique_ptr<Transport>> |
| 138 endpoint_to_transport_map_; |
138 | 139 |
139 // Map of valid transports. Each pair is composed of a transport path as the | 140 // Map of valid transports. Each pair is composed of a transport path as the |
140 // key and an endpoint path as the value. This map is used to get the | 141 // key and an endpoint path as the value. This map is used to get the |
141 // corresponding endpoint path when GetProperties() is called. | 142 // corresponding endpoint path when GetProperties() is called. |
142 std::map<dbus::ObjectPath, dbus::ObjectPath> transport_to_endpoint_map_; | 143 std::map<dbus::ObjectPath, dbus::ObjectPath> transport_to_endpoint_map_; |
143 | 144 |
144 base::ObserverList<BluetoothMediaTransportClient::Observer> observers_; | 145 base::ObserverList<BluetoothMediaTransportClient::Observer> observers_; |
145 | 146 |
146 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient); | 147 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient); |
147 }; | 148 }; |
148 | 149 |
149 } // namespace bluez | 150 } // namespace bluez |
150 | 151 |
151 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ | 152 #endif // DEVICE_BLUETOOTH_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ |
OLD | NEW |