Chromium Code Reviews| 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 #include "chromeos/dbus/fake_bluetooth_media_client.h" | 5 #include "chromeos/dbus/fake_bluetooth_media_client.h" |
| 6 | 6 |
| 7 #include <string> | |
| 8 | |
| 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 // The UUID for Bluetooth audio sink service. | |
| 14 const char kBluetoothAudioSinkUUID[] = "0000110b-0000-1000-8000-00805f9b34fb"; | |
|
Ben Chan
2015/01/28 15:54:27
do you expect to have a TODO to move these constan
Miao
2015/01/28 22:34:20
kBluetoothAudioSinkUUID will be placed in Bluetoot
| |
| 15 | |
| 16 const char kAdapterNotFoundError[] = "org.chromium.Error.AdapterNotFound"; | |
| 17 const char kNotImplementedError[] = "org.chromium.Error.NotImplemented"; | |
| 18 const char kInvalidArgumentError[] = "org.chromium.Error.InvalidArgument"; | |
| 19 | |
| 20 } // namespace | |
| 21 | |
| 7 namespace chromeos { | 22 namespace chromeos { |
| 8 | 23 |
| 9 FakeBluetoothMediaClient::FakeBluetoothMediaClient() { | 24 FakeBluetoothMediaClient::FakeBluetoothMediaClient() { |
| 10 } | 25 } |
| 11 | 26 |
| 12 FakeBluetoothMediaClient::~FakeBluetoothMediaClient() { | 27 FakeBluetoothMediaClient::~FakeBluetoothMediaClient() { |
| 13 } | 28 } |
| 14 | 29 |
| 15 void FakeBluetoothMediaClient::Init(dbus::Bus* bus) { | 30 void FakeBluetoothMediaClient::Init(dbus::Bus* bus) { |
| 16 } | 31 } |
| 17 | 32 |
| 18 void FakeBluetoothMediaClient::AddObserver( | 33 void FakeBluetoothMediaClient::AddObserver( |
| 19 BluetoothMediaClient::Observer* observer) { | 34 BluetoothMediaClient::Observer* observer) { |
| 20 DCHECK(observer); | 35 DCHECK(observer); |
| 21 observers_.AddObserver(observer); | 36 observers_.AddObserver(observer); |
| 22 } | 37 } |
| 23 | 38 |
| 24 void FakeBluetoothMediaClient::RemoveObserver( | 39 void FakeBluetoothMediaClient::RemoveObserver( |
| 25 BluetoothMediaClient::Observer* observer) { | 40 BluetoothMediaClient::Observer* observer) { |
| 26 DCHECK(observer); | 41 DCHECK(observer); |
| 27 observers_.RemoveObserver(observer); | 42 observers_.RemoveObserver(observer); |
| 28 } | 43 } |
| 29 | 44 |
| 30 // TODO(mcchou): Add method definition for |RegisterEndpoint|, | |
| 31 // |UnregisterEndpoint|, |RegisterPlayer| and |UnregisterPlayer|. | |
| 32 void FakeBluetoothMediaClient::RegisterEndpoint( | 45 void FakeBluetoothMediaClient::RegisterEndpoint( |
| 33 const dbus::ObjectPath& object_path, | 46 const ObjectPath& object_path, |
| 34 const dbus::ObjectPath& endpoint_path, | 47 const ObjectPath& endpoint_path, |
| 35 const EndpointProperties& properties, | 48 const EndpointProperties& properties, |
| 36 const base::Closure& callback, | 49 const base::Closure& callback, |
| 37 const ErrorCallback& error_callback) { | 50 const ErrorCallback& error_callback) { |
| 38 error_callback.Run("org.bluez.NotImplemented", ""); | 51 VLOG(1) << "RegisterEndpoint: " << endpoint_path.value(); |
| 52 | |
| 53 // The object paths of the media client and adapter client should be the same. | |
| 54 if (object_path != ObjectPath(FakeBluetoothAdapterClient::kAdapterPath)) { | |
| 55 error_callback.Run(kAdapterNotFoundError, ""); | |
| 56 return; | |
| 57 } | |
| 58 | |
| 59 if (properties.uuid != std::string(kBluetoothAudioSinkUUID) || | |
|
Ben Chan
2015/01/28 15:54:27
EndpointProperties.uuid is a std::string, so std::
Miao
2015/01/28 22:34:20
Done.
| |
| 60 properties.codec != 0x00 || | |
|
Ben Chan
2015/01/28 15:54:27
perhaps define 0x00 as something like kDefaultCode
Miao
2015/01/28 22:34:20
kDefaultCodec added.
| |
| 61 properties.capabilities.empty()) { | |
| 62 error_callback.Run(kInvalidArgumentError, ""); | |
| 63 return; | |
| 64 } | |
| 65 callback.Run(); | |
| 39 } | 66 } |
| 40 | 67 |
| 41 void FakeBluetoothMediaClient::UnregisterEndpoint( | 68 void FakeBluetoothMediaClient::UnregisterEndpoint( |
| 42 const dbus::ObjectPath& object_path, | 69 const ObjectPath& object_path, |
| 43 const dbus::ObjectPath& endpoint_path, | 70 const ObjectPath& endpoint_path, |
| 44 const base::Closure& callback, | 71 const base::Closure& callback, |
| 45 const ErrorCallback& error_callback) { | 72 const ErrorCallback& error_callback) { |
| 46 error_callback.Run("org.bluez.NotImplemented", ""); | 73 error_callback.Run(kNotImplementedError, ""); |
| 47 } | 74 } |
| 48 | 75 |
| 49 } // namespace chromeos | 76 } // namespace chromeos |
| OLD | NEW |