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

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

Issue 910023002: device/bluetooth:Implement BluetoothMediaEndpointServiceProvider delegate and media-related overrid… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved the addition/removal of all types of observer to constructor/destructor. 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 #include "chromeos/dbus/fake_bluetooth_media_transport_client.h" 5 #include "chromeos/dbus/fake_bluetooth_media_transport_client.h"
6 6
7 #include "base/bind.h"
8 #include "chromeos/dbus/bluetooth_media_client.h"
9 #include "chromeos/dbus/dbus_thread_manager.h"
10 #include "chromeos/dbus/fake_bluetooth_media_client.h"
11
12 using dbus::ObjectPath;
13
7 namespace { 14 namespace {
8 15
9 // TODO(mcchou): Remove this constants once it is in cros_system_api. 16 // TODO(mcchou): Remove this constants once it is in cros_system_api.
10 const char kBluetoothMediaTransportInterface[] = "org.bluez.MediaTransport1"; 17 const char kBluetoothMediaTransportInterface[] = "org.bluez.MediaTransport1";
11 const char kNotImplemented[] = "org.bluez.NotImplemented"; 18 const char kNotImplemented[] = "org.bluez.NotImplemented";
12 19
13 } // namespace 20 } // namespace
14 21
15 namespace chromeos { 22 namespace chromeos {
16 23
24 // static
25 const char FakeBluetoothMediaTransportClient::kTransportPath[] =
26 "/fake/hci0/dev_00_00_00_00_00_00/fd0";
27 const char FakeBluetoothMediaTransportClient::kTransportDevicePath[] =
28 "/fake/hci0/dev_00_00_00_00_00_00";
29 const uint8_t FakeBluetoothMediaTransportClient::kTransportCodec = 0x00;
30 const std::vector<uint8_t>
31 FakeBluetoothMediaTransportClient::kTransportConfiguration = {
32 0x21, 0x15, 0x33, 0x2C};
33 const uint16_t FakeBluetoothMediaTransportClient::kTransportDelay = 5;
34 const uint16_t FakeBluetoothMediaTransportClient::kTransportVolume = 10;
35
17 FakeBluetoothMediaTransportClient::Properties::Properties( 36 FakeBluetoothMediaTransportClient::Properties::Properties(
18 const PropertyChangedCallback& callback) 37 const PropertyChangedCallback& callback)
19 : BluetoothMediaTransportClient::Properties( 38 : BluetoothMediaTransportClient::Properties(
20 nullptr, 39 nullptr,
21 kBluetoothMediaTransportInterface, 40 kBluetoothMediaTransportInterface,
22 callback) { 41 callback) {
23 } 42 }
24 43
25 FakeBluetoothMediaTransportClient::Properties::~Properties() { 44 FakeBluetoothMediaTransportClient::Properties::~Properties() {
26 } 45 }
(...skipping 11 matching lines...) Expand all
38 VLOG(1) << "GetAll called."; 57 VLOG(1) << "GetAll called.";
39 } 58 }
40 59
41 void FakeBluetoothMediaTransportClient::Properties::Set( 60 void FakeBluetoothMediaTransportClient::Properties::Set(
42 dbus::PropertyBase* property, 61 dbus::PropertyBase* property,
43 dbus::PropertySet::SetCallback callback) { 62 dbus::PropertySet::SetCallback callback) {
44 VLOG(1) << "Set " << property->name(); 63 VLOG(1) << "Set " << property->name();
45 callback.Run(false); 64 callback.Run(false);
46 } 65 }
47 66
48 FakeBluetoothMediaTransportClient::FakeBluetoothMediaTransportClient() { 67 FakeBluetoothMediaTransportClient::FakeBluetoothMediaTransportClient()
68 : object_path_(ObjectPath(kTransportPath)) {
69 // TODO(mcchou): Multiple endpoints are sharing one property set for now.
70 // Add property sets accordingly to separate the
71 // MediaTransportPropertiesChanged events for different endpoints.
72
73 // Sets fake property set with default values.
74 properties_.reset(new Properties(
75 base::Bind(&FakeBluetoothMediaTransportClient::OnPropertyChanged,
76 base::Unretained(this))));
77 properties_->device.ReplaceValue(ObjectPath(kTransportDevicePath));
78 properties_->uuid.ReplaceValue(BluetoothMediaClient::kBluetoothAudioSinkUUID);
79 properties_->codec.ReplaceValue(kTransportCodec);
80 properties_->configuration.ReplaceValue(kTransportConfiguration);
81 properties_->state.ReplaceValue(BluetoothMediaTransportClient::kStateIdle);
82 properties_->delay.ReplaceValue(kTransportDelay);
83 properties_->volume.ReplaceValue(kTransportVolume);
49 } 84 }
50 85
51 FakeBluetoothMediaTransportClient::~FakeBluetoothMediaTransportClient() { 86 FakeBluetoothMediaTransportClient::~FakeBluetoothMediaTransportClient() {
52 } 87 }
53 88
54 // DBusClient override. 89 // DBusClient override.
55 void FakeBluetoothMediaTransportClient::Init(dbus::Bus* bus) { 90 void FakeBluetoothMediaTransportClient::Init(dbus::Bus* bus) {
56 } 91 }
57 92
58 // BluetoothMediaTransportClient overrides. 93 // BluetoothMediaTransportClient overrides.
59 94
60 void FakeBluetoothMediaTransportClient::AddObserver( 95 void FakeBluetoothMediaTransportClient::AddObserver(
61 BluetoothMediaTransportClient::Observer* observer) { 96 BluetoothMediaTransportClient::Observer* observer) {
62 observers_.AddObserver(observer); 97 observers_.AddObserver(observer);
63 } 98 }
64 99
65 void FakeBluetoothMediaTransportClient::RemoveObserver( 100 void FakeBluetoothMediaTransportClient::RemoveObserver(
66 BluetoothMediaTransportClient::Observer* observer) { 101 BluetoothMediaTransportClient::Observer* observer) {
67 observers_.RemoveObserver(observer); 102 observers_.RemoveObserver(observer);
68 } 103 }
69 104
70 FakeBluetoothMediaTransportClient::Properties* 105 FakeBluetoothMediaTransportClient::Properties*
71 FakeBluetoothMediaTransportClient::GetProperties( 106 FakeBluetoothMediaTransportClient::GetProperties(
72 const dbus::ObjectPath& object_path) { 107 const ObjectPath& object_path) {
73 return nullptr; 108 return nullptr;
74 } 109 }
75 110
76 void FakeBluetoothMediaTransportClient::Acquire( 111 void FakeBluetoothMediaTransportClient::Acquire(
77 const dbus::ObjectPath& object_path, 112 const ObjectPath& object_path,
78 const AcquireCallback& callback, 113 const AcquireCallback& callback,
79 const ErrorCallback& error_callback) { 114 const ErrorCallback& error_callback) {
80 error_callback.Run(kNotImplemented, ""); 115 error_callback.Run(kNotImplemented, "");
81 } 116 }
82 117
83 void FakeBluetoothMediaTransportClient::TryAcquire( 118 void FakeBluetoothMediaTransportClient::TryAcquire(
84 const dbus::ObjectPath& object_path, 119 const ObjectPath& object_path,
85 const AcquireCallback& callback, 120 const AcquireCallback& callback,
86 const ErrorCallback& error_callback) { 121 const ErrorCallback& error_callback) {
87 error_callback.Run(kNotImplemented, ""); 122 error_callback.Run(kNotImplemented, "");
88 } 123 }
89 124
90 void FakeBluetoothMediaTransportClient::Release( 125 void FakeBluetoothMediaTransportClient::Release(
91 const dbus::ObjectPath& object_path, 126 const ObjectPath& object_path,
92 const base::Closure& callback, 127 const base::Closure& callback,
93 const ErrorCallback& error_callback) { 128 const ErrorCallback& error_callback) {
94 error_callback.Run(kNotImplemented, ""); 129 error_callback.Run(kNotImplemented, "");
95 } 130 }
96 131
132 void FakeBluetoothMediaTransportClient::SetValid(
133 const ObjectPath& endpoint_path,
134 bool valid) {
135 if (valid) {
136 endpoints_[endpoint_path] = valid;
137 return;
138 }
139 endpoints_.erase(endpoint_path);
140
141 // TODO(mcchou): Since there is only one transport path, all observers will
142 // be notified. Shades irrelevant observers.
143
144 // Notifies observers about the state change of the transport.
145 FOR_EACH_OBSERVER(BluetoothMediaTransportClient::Observer, observers_,
146 MediaTransportRemoved(object_path_));
147 }
148
149 void FakeBluetoothMediaTransportClient::OnPropertyChanged(
150 const std::string& property_name) {
151 VLOG(1) << "Property " << property_name << " changed";
152 }
153
97 } // namespace chromeos 154 } // namespace chromeos
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_bluetooth_media_transport_client.h ('k') | device/bluetooth/bluetooth_audio_sink_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698