Chromium Code Reviews| Index: device/bluetooth/dbus/fake_bluetooth_adapter_client.cc |
| diff --git a/device/bluetooth/dbus/fake_bluetooth_adapter_client.cc b/device/bluetooth/dbus/fake_bluetooth_adapter_client.cc |
| index eb78a49bf679d8e56e3eb68ec00b643b89458c21..ca4bb3d4e13ce34c4ceafadddde63a0baca23272 100644 |
| --- a/device/bluetooth/dbus/fake_bluetooth_adapter_client.cc |
| +++ b/device/bluetooth/dbus/fake_bluetooth_adapter_client.cc |
| @@ -4,11 +4,18 @@ |
| #include "device/bluetooth/dbus/fake_bluetooth_adapter_client.h" |
| +#include <map> |
| +#include <utility> |
| + |
| +#include "base/bind_helpers.h" |
| +#include "base/callback_forward.h" |
| #include "base/location.h" |
| #include "base/logging.h" |
| #include "base/single_thread_task_runner.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| #include "base/time/time.h" |
| +#include "dbus/bus.h" |
| +#include "device/bluetooth/bluez/bluetooth_service_record_bluez.h" |
| #include "device/bluetooth/dbus/bluez_dbus_manager.h" |
| #include "device/bluetooth/dbus/fake_bluetooth_device_client.h" |
| #include "third_party/cros_system_api/dbus/service_constants.h" |
| @@ -71,7 +78,8 @@ FakeBluetoothAdapterClient::FakeBluetoothAdapterClient() |
| second_visible_(false), |
| discovering_count_(0), |
| set_discovery_filter_should_fail_(false), |
| - simulation_interval_ms_(kSimulationIntervalMs) { |
| + simulation_interval_ms_(kSimulationIntervalMs), |
| + last_handle_(0) { |
| properties_.reset(new Properties(base::Bind( |
| &FakeBluetoothAdapterClient::OnPropertyChanged, base::Unretained(this)))); |
| @@ -226,6 +234,31 @@ void FakeBluetoothAdapterClient::SetDiscoveryFilter( |
| PostDelayedTask(callback); |
| } |
| +void FakeBluetoothAdapterClient::CreateServiceRecord( |
| + const dbus::ObjectPath& object_path, |
| + const bluez::BluetoothServiceRecordBlueZ& record, |
| + const ServiceRecordCallback& callback, |
| + const ErrorCallback& error_callback) { |
| + last_handle_++; |
|
xiyuan
2016/06/22 15:53:06
nit: ++last_handle_
rkc
2016/06/22 21:06:38
Done.
|
| + records_.emplace(last_handle_, record); |
| + callback.Run(last_handle_); |
| +} |
| + |
| +void FakeBluetoothAdapterClient::RemoveServiceRecord( |
| + const dbus::ObjectPath& object_path, |
| + uint32_t handle, |
| + const base::Closure& callback, |
| + const ErrorCallback& error_callback) { |
| + auto it = records_.find(handle); |
| + if (it == records_.end()) { |
| + error_callback.Run(bluetooth_adapter::kErrorDoesNotExist, |
| + "Service record does not exist."); |
| + return; |
| + } |
| + records_.erase(it); |
| + callback.Run(); |
| +} |
| + |
| void FakeBluetoothAdapterClient::SetSimulationIntervalMs(int interval_ms) { |
| simulation_interval_ms_ = interval_ms; |
| } |