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 CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/files/file.h" | |
12 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
13 #include "base/observer_list.h" | 14 #include "base/observer_list.h" |
14 #include "chromeos/chromeos_export.h" | 15 #include "chromeos/chromeos_export.h" |
15 #include "chromeos/dbus/bluetooth_media_transport_client.h" | 16 #include "chromeos/dbus/bluetooth_media_transport_client.h" |
16 #include "dbus/object_path.h" | 17 #include "dbus/object_path.h" |
17 | 18 |
18 namespace chromeos { | 19 namespace chromeos { |
19 | 20 |
20 class FakeBluetoothMediaEndpointServiceProvider; | 21 class FakeBluetoothMediaEndpointServiceProvider; |
21 | 22 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
69 // otherwise. | 70 // otherwise. |
70 void SetValid(FakeBluetoothMediaEndpointServiceProvider* endpoint, | 71 void SetValid(FakeBluetoothMediaEndpointServiceProvider* endpoint, |
71 bool valid); | 72 bool valid); |
72 | 73 |
73 // Set state/volume property to a certain value. | 74 // Set state/volume property to a certain value. |
74 void SetState(const dbus::ObjectPath& endpoint_path, | 75 void SetState(const dbus::ObjectPath& endpoint_path, |
75 const std::string& state); | 76 const std::string& state); |
76 void SetVolume(const dbus::ObjectPath& endpoint_path, | 77 void SetVolume(const dbus::ObjectPath& endpoint_path, |
77 const uint16_t& volume); | 78 const uint16_t& volume); |
78 | 79 |
79 // Gets the transport path associated with the given endpoint path. | 80 // Writes bytes to the input file descriptor, |input_fd|, accosiated with a |
armansito
2015/03/12 03:42:54
nit: s/accosiated/associated. Try pronouncing your
Miao
2015/03/12 22:33:31
:P
| |
81 // Transport object which is bound to |endpoint_path|. | |
armansito
2015/03/12 03:42:54
nit: s/Transport/transport/. Lowercase, because yo
Miao
2015/03/12 22:33:31
Done.
| |
82 void WriteData(const dbus::ObjectPath& endpoint_path, | |
83 const std::vector<char>& bytes); | |
84 | |
85 // Retrieves the transport object path bound to |endpoint_path|. | |
80 dbus::ObjectPath GetTransportPath(const dbus::ObjectPath& endpoint_path); | 86 dbus::ObjectPath GetTransportPath(const dbus::ObjectPath& endpoint_path); |
81 | 87 |
82 // Gets the endpoint path associated with the given transport_path. | 88 // Gets the endpoint path associated with the given transport_path. |
83 dbus::ObjectPath GetEndpointPath(const dbus::ObjectPath& transport_path); | 89 dbus::ObjectPath GetEndpointPath(const dbus::ObjectPath& transport_path); |
84 | 90 |
85 private: | 91 private: |
86 // This class is used for simulating the scenario where each media endpoint | 92 // This class is used for simulating the scenario where each media endpoint |
87 // has a corresponding transport path and properties. Once an endpoint is | 93 // has a corresponding transport path and properties. Once an endpoint is |
88 // assigned with a transport path, an object of Transport is created. | 94 // assigned with a transport path, an object of Transport is created. |
89 class Transport { | 95 struct Transport { |
90 public: | |
91 Transport(const dbus::ObjectPath& transport_path, | 96 Transport(const dbus::ObjectPath& transport_path, |
92 Properties* transport_properties); | 97 Properties* transport_properties); |
93 ~Transport(); | 98 ~Transport(); |
94 | 99 |
95 // An unique transport path. | 100 // An unique transport path. |
96 dbus::ObjectPath path; | 101 dbus::ObjectPath path; |
97 | 102 |
98 // The property set bound with |path|. | 103 // The property set bound with |path|. |
99 scoped_ptr<Properties> properties; | 104 scoped_ptr<Properties> properties; |
105 | |
106 // File descriptor for simulating data available event. |input_fd| | |
107 // will be initialized when Acquire/TryAcquire is called. | |
armansito
2015/03/12 03:42:54
I would also say here that this is the internal en
Miao
2015/03/12 22:33:31
Done.
| |
108 scoped_ptr<base::File> input_fd; | |
100 }; | 109 }; |
101 | 110 |
102 // Property callback passed while a Properties structure is created. | 111 // Property callback passed while a Properties structure is created. |
103 void OnPropertyChanged(const std::string& property_name); | 112 void OnPropertyChanged(const std::string& property_name); |
104 | 113 |
114 // Retrieves the transport structure bound to |endpoint_path| | |
115 Transport* GetTransport(const dbus::ObjectPath& endpoint_path); | |
116 | |
105 // Map of endpoints with valid transport. Each pair is composed of an endpoint | 117 // Map of endpoints with valid transport. Each pair is composed of an endpoint |
106 // path and a Transport structure containing a transport path and its | 118 // path and a Transport structure containing a transport path and its |
107 // properties. | 119 // properties. |
108 std::map<dbus::ObjectPath, Transport*> endpoint_to_transport_map_; | 120 std::map<dbus::ObjectPath, Transport*> endpoint_to_transport_map_; |
109 | 121 |
110 // Map of valid transports. Each pair is composed of a transport path as the | 122 // Map of valid transports. Each pair is composed of a transport path as the |
111 // key and an endpoint path as the value. This map is used to get the | 123 // key and an endpoint path as the value. This map is used to get the |
112 // corresponding endpoint path when GetProperties() is called. | 124 // corresponding endpoint path when GetProperties() is called. |
113 std::map<dbus::ObjectPath, dbus::ObjectPath> transport_to_endpoint_map_; | 125 std::map<dbus::ObjectPath, dbus::ObjectPath> transport_to_endpoint_map_; |
114 | 126 |
115 // The path of the media transport object. | |
116 dbus::ObjectPath object_path_; | |
117 | |
118 ObserverList<BluetoothMediaTransportClient::Observer> observers_; | 127 ObserverList<BluetoothMediaTransportClient::Observer> observers_; |
119 | 128 |
120 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient); | 129 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient); |
121 }; | 130 }; |
122 | 131 |
123 } // namespace chromeos | 132 } // namespace chromeos |
124 | 133 |
125 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ | 134 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ |
OLD | NEW |