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

Side by Side Diff: chromeos/dbus/fake_bluetooth_media_transport_client.h

Issue 939753004: device/bluetooth: Implement Unregister() of BlueotoothAudioSinkChromeOS and disconnection-related c… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
OLDNEW
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/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/observer_list.h" 13 #include "base/observer_list.h"
14 #include "chromeos/chromeos_export.h" 14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/bluetooth_media_transport_client.h" 15 #include "chromeos/dbus/bluetooth_media_transport_client.h"
16 #include "dbus/object_path.h" 16 #include "dbus/object_path.h"
17 17
18 namespace chromeos { 18 namespace chromeos {
19 19
20 class FakeBluetoothMediaEndpointServiceProvider;
21
20 class CHROMEOS_EXPORT FakeBluetoothMediaTransportClient 22 class CHROMEOS_EXPORT FakeBluetoothMediaTransportClient
21 : public BluetoothMediaTransportClient { 23 : public BluetoothMediaTransportClient {
22 public: 24 public:
23 struct Properties : public BluetoothMediaTransportClient::Properties { 25 struct Properties : public BluetoothMediaTransportClient::Properties {
24 explicit Properties(const PropertyChangedCallback& callback); 26 explicit Properties(const PropertyChangedCallback& callback);
25 ~Properties() override; 27 ~Properties() override;
26 28
27 void Get(dbus::PropertyBase* property, 29 void Get(dbus::PropertyBase* property,
28 dbus::PropertySet::GetCallback callback) override; 30 dbus::PropertySet::GetCallback callback) override;
29 void GetAll() override; 31 void GetAll() override;
(...skipping 25 matching lines...) Expand all
55 void Acquire(const dbus::ObjectPath& object_path, 57 void Acquire(const dbus::ObjectPath& object_path,
56 const AcquireCallback& callback, 58 const AcquireCallback& callback,
57 const ErrorCallback& error_callback) override; 59 const ErrorCallback& error_callback) override;
58 void TryAcquire(const dbus::ObjectPath& object_path, 60 void TryAcquire(const dbus::ObjectPath& object_path,
59 const AcquireCallback& callback, 61 const AcquireCallback& callback,
60 const ErrorCallback& error_callback) override; 62 const ErrorCallback& error_callback) override;
61 void Release(const dbus::ObjectPath& object_path, 63 void Release(const dbus::ObjectPath& object_path,
62 const base::Closure& callback, 64 const base::Closure& callback,
63 const ErrorCallback& error_callback) override; 65 const ErrorCallback& error_callback) override;
64 66
65 // Makes the transport valid/invalid for a given media endpoint path. The 67 // Makes the transport valid/invalid for a given media endpoint. The transport
66 // transport object is assigned to the given endpoint if valid is true, false 68 // object is assigned to the given endpoint if valid is true, false
67 // otherwise. 69 // otherwise.
68 void SetValid(const dbus::ObjectPath& endpoint_path, bool valid); 70 void SetValid(FakeBluetoothMediaEndpointServiceProvider* endpoint,
71 bool valid);
72
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);
78
79 // Gets the transport path associated with the given endpoint path.
80 dbus::ObjectPath GetTransportPath(const dbus::ObjectPath& endpoint_path);
81
82 // Gets the endpoint path associated with the given transport_path.
83 dbus::ObjectPath GetEndpointPath(const dbus::ObjectPath& transport_path);
69 84
70 private: 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();
94
95 // An unique transport path.
96 dbus::ObjectPath path;
97
98 // The property set bound with |path|.
99 scoped_ptr<Properties> properties;
100 };
101
71 // Property callback passed while a Properties structure is created. 102 // Property callback passed while a Properties structure is created.
72 void OnPropertyChanged(const std::string& property_name); 103 void OnPropertyChanged(const std::string& property_name);
73 104
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_;
109
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_;
114
74 // The path of the media transport object. 115 // The path of the media transport object.
75 dbus::ObjectPath object_path_; 116 dbus::ObjectPath object_path_;
76 117
77 // Indicates whether endpoints are assigned with the transport object.
78 std::map<dbus::ObjectPath, bool> endpoints_;
79
80 // The fake property set of the media transport object.
81 scoped_ptr<Properties> properties_;
82
83 ObserverList<BluetoothMediaTransportClient::Observer> observers_; 118 ObserverList<BluetoothMediaTransportClient::Observer> observers_;
84 119
85 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient); 120 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient);
86 }; 121 };
87 122
88 } // namespace chromeos 123 } // namespace chromeos
89 124
90 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ 125 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698