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

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: Fixed nits. 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;
30 void Set(dbus::PropertyBase* property, 32 void Set(dbus::PropertyBase* property,
31 dbus::PropertySet::SetCallback callback) override; 33 dbus::PropertySet::SetCallback callback) override;
32 }; 34 };
33 35
36 class Transport {
armansito 2015/02/26 04:23:08 Make this class private. As in, move it below the
Miao 2015/02/26 04:41:50 Done.
37 public:
38 Transport(const dbus::ObjectPath& transport_path,
39 Properties* transport_properties);
40 ~Transport();
41
42 dbus::ObjectPath path;
43 scoped_ptr<Properties> properties;
44 };
45
34 // The default path of the transport object. 46 // The default path of the transport object.
35 static const char kTransportPath[]; 47 static const char kTransportPath[];
36 48
37 // The default properties including device, codec, configuration, state, delay 49 // The default properties including device, codec, configuration, state, delay
38 // and volume, owned by a fake media transport object we emulate. 50 // and volume, owned by a fake media transport object we emulate.
39 static const char kTransportDevicePath[]; 51 static const char kTransportDevicePath[];
40 static const uint8_t kTransportCodec; 52 static const uint8_t kTransportCodec;
41 static const std::vector<uint8_t> kTransportConfiguration; 53 static const std::vector<uint8_t> kTransportConfiguration;
42 static const uint16_t kTransportDelay; 54 static const uint16_t kTransportDelay;
43 static const uint16_t kTransportVolume; 55 static const uint16_t kTransportVolume;
(...skipping 11 matching lines...) Expand all
55 void Acquire(const dbus::ObjectPath& object_path, 67 void Acquire(const dbus::ObjectPath& object_path,
56 const AcquireCallback& callback, 68 const AcquireCallback& callback,
57 const ErrorCallback& error_callback) override; 69 const ErrorCallback& error_callback) override;
58 void TryAcquire(const dbus::ObjectPath& object_path, 70 void TryAcquire(const dbus::ObjectPath& object_path,
59 const AcquireCallback& callback, 71 const AcquireCallback& callback,
60 const ErrorCallback& error_callback) override; 72 const ErrorCallback& error_callback) override;
61 void Release(const dbus::ObjectPath& object_path, 73 void Release(const dbus::ObjectPath& object_path,
62 const base::Closure& callback, 74 const base::Closure& callback,
63 const ErrorCallback& error_callback) override; 75 const ErrorCallback& error_callback) override;
64 76
65 // Makes the transport valid/invalid for a given media endpoint path. The 77 // 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 78 // object is assigned to the given endpoint if valid is true, false
67 // otherwise. 79 // otherwise.
68 void SetValid(const dbus::ObjectPath& endpoint_path, bool valid); 80 void SetValid(FakeBluetoothMediaEndpointServiceProvider* endpoint,
81 bool valid);
82
83 // Set state/volume property to a certain value.
84 void SetState(const dbus::ObjectPath& endpoint_path,
85 const std::string& state);
86 void SetVolume(const dbus::ObjectPath& endpoint_path,
87 const uint16_t& volume);
88
89 // Gets the transport path associated with the given endpoint path.
90 dbus::ObjectPath GetTransportPath(const dbus::ObjectPath& endpoint_path);
91
92 // Gets the endpoint path associated with the given transport_path.
93 dbus::ObjectPath GetEndpointPath(const dbus::ObjectPath& transport_path);
69 94
70 private: 95 private:
71 // Property callback passed while a Properties structure is created. 96 // Property callback passed while a Properties structure is created.
72 void OnPropertyChanged(const std::string& property_name); 97 void OnPropertyChanged(const std::string& property_name);
73 98
99 // Map of endpoints with valid transport. Each pair is composed of an endpoint
100 // path and a Transport structure containing a transport path and its
101 // properties.
102 std::map<dbus::ObjectPath, Transport*> endpoint_to_transport_map_;
103
104 // Map of valid transports. Each pair is composed of a transport path as the
105 // key and an endpoint path as the value. This map is used to get the
106 // corresponding endpoint path when GetProperties() is called.
107 std::map<dbus::ObjectPath, dbus::ObjectPath> transport_to_endpoint_map_;
108
74 // The path of the media transport object. 109 // The path of the media transport object.
75 dbus::ObjectPath object_path_; 110 dbus::ObjectPath object_path_;
76 111
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_; 112 ObserverList<BluetoothMediaTransportClient::Observer> observers_;
84 113
85 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient); 114 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient);
86 }; 115 };
87 116
88 } // namespace chromeos 117 } // namespace chromeos
89 118
90 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ 119 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698