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

Unified Diff: device/bluetooth/dbus/fake_bluetooth_adapter_client.cc

Issue 2084463002: BlueZ + DBus implementations of create/remove service record functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_adapter_client.h ('k') | device/device_tests.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « device/bluetooth/dbus/fake_bluetooth_adapter_client.h ('k') | device/device_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698