ozone: evdev: Sync caps lock LED state to evdev
[chromium-blink-merge.git] / chromeos / dbus / fake_bluetooth_media_transport_client.h
blob319b2ae3c4e0518d527936f0c323e82f87d71856
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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/bluetooth_media_transport_client.h"
16 #include "dbus/object_path.h"
18 namespace chromeos {
20 class FakeBluetoothMediaEndpointServiceProvider;
22 class CHROMEOS_EXPORT FakeBluetoothMediaTransportClient
23 : public BluetoothMediaTransportClient {
24 public:
25 struct Properties : public BluetoothMediaTransportClient::Properties {
26 explicit Properties(const PropertyChangedCallback& callback);
27 ~Properties() override;
29 void Get(dbus::PropertyBase* property,
30 dbus::PropertySet::GetCallback callback) override;
31 void GetAll() override;
32 void Set(dbus::PropertyBase* property,
33 dbus::PropertySet::SetCallback callback) override;
36 // The default path of the transport object.
37 static const char kTransportPath[];
39 // The default properties including device, codec, configuration, state, delay
40 // and volume, owned by a fake media transport object we emulate.
41 static const char kTransportDevicePath[];
42 static const uint8_t kTransportCodec;
43 static const std::vector<uint8_t> kTransportConfiguration;
44 static const uint16_t kTransportDelay;
45 static const uint16_t kTransportVolume;
47 FakeBluetoothMediaTransportClient();
48 ~FakeBluetoothMediaTransportClient() override;
50 // DBusClient override.
51 void Init(dbus::Bus* bus) override;
53 // BluetoothMediaTransportClient override.
54 void AddObserver(Observer* observer) override;
55 void RemoveObserver(Observer* observer) override;
56 Properties* GetProperties(const dbus::ObjectPath& object_path) override;
57 void Acquire(const dbus::ObjectPath& object_path,
58 const AcquireCallback& callback,
59 const ErrorCallback& error_callback) override;
60 void TryAcquire(const dbus::ObjectPath& object_path,
61 const AcquireCallback& callback,
62 const ErrorCallback& error_callback) override;
63 void Release(const dbus::ObjectPath& object_path,
64 const base::Closure& callback,
65 const ErrorCallback& error_callback) override;
67 // Makes the transport valid/invalid for a given media endpoint. The transport
68 // object is assigned to the given endpoint if valid is true, false
69 // otherwise.
70 void SetValid(FakeBluetoothMediaEndpointServiceProvider* endpoint,
71 bool valid);
73 // Set state/volume property to a certain value.
74 void SetState(const dbus::ObjectPath& endpoint_path,
75 const std::string& state);
76 void SetVolume(const dbus::ObjectPath& endpoint_path,
77 const uint16_t& volume);
79 // Gets the transport path associated with the given endpoint path.
80 dbus::ObjectPath GetTransportPath(const dbus::ObjectPath& endpoint_path);
82 // Gets the endpoint path associated with the given transport_path.
83 dbus::ObjectPath GetEndpointPath(const dbus::ObjectPath& transport_path);
85 private:
86 // This class is used for simulating the scenario where each media endpoint
87 // has a corresponding transport path and properties. Once an endpoint is
88 // assigned with a transport path, an object of Transport is created.
89 class Transport {
90 public:
91 Transport(const dbus::ObjectPath& transport_path,
92 Properties* transport_properties);
93 ~Transport();
95 // An unique transport path.
96 dbus::ObjectPath path;
98 // The property set bound with |path|.
99 scoped_ptr<Properties> properties;
102 // Property callback passed while a Properties structure is created.
103 void OnPropertyChanged(const std::string& property_name);
105 // 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
107 // properties.
108 std::map<dbus::ObjectPath, Transport*> endpoint_to_transport_map_;
110 // 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
112 // corresponding endpoint path when GetProperties() is called.
113 std::map<dbus::ObjectPath, dbus::ObjectPath> transport_to_endpoint_map_;
115 // The path of the media transport object.
116 dbus::ObjectPath object_path_;
118 ObserverList<BluetoothMediaTransportClient::Observer> observers_;
120 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient);
123 } // namespace chromeos
125 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_