| 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..15d00555ac94b8ed3448491e7df694fd5a40cbfc 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,32 @@ 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_;
|
| + records_.insert(
|
| + std::pair<uint32_t, BluetoothServiceRecordBlueZ>(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;
|
| }
|
|
|