summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorrkc <rkc@chromium.org>2015-04-27 14:29:01 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-27 21:29:51 +0000
commitc96da18077ef4b5ab28cb8b2684cd84386075e5a (patch)
treecd6d51d9f8272552581eecc9aaa7a5387ade7edc /chromeos
parent685b5b6b32a9c4dbb09224541574d8a02859d572 (diff)
downloadchromium_src-c96da18077ef4b5ab28cb8b2684cd84386075e5a.zip
chromium_src-c96da18077ef4b5ab28cb8b2684cd84386075e5a.tar.gz
chromium_src-c96da18077ef4b5ab28cb8b2684cd84386075e5a.tar.bz2
Add CPP API for BLE advertisments.
This CL adds the new classes, changes to existing classes and tests for adding the CPP API for LE advertisements. The design for this is available at http://go/chrome-ble-advertising. R=armansito@chromium.org, jamuraa@chromium.org BUG=466375 Review URL: https://codereview.chromium.org/1054743003 Cr-Commit-Position: refs/heads/master@{#327128}
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/dbus/bluetooth_le_advertisement_service_provider.cc16
-rw-r--r--chromeos/dbus/bluetooth_le_advertisement_service_provider.h8
-rw-r--r--chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.cc7
-rw-r--r--chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h3
-rw-r--r--chromeos/dbus/fake_bluetooth_le_advertising_manager_client.cc3
-rw-r--r--chromeos/dbus/fake_bluetooth_le_advertising_manager_client.h2
6 files changed, 18 insertions, 21 deletions
diff --git a/chromeos/dbus/bluetooth_le_advertisement_service_provider.cc b/chromeos/dbus/bluetooth_le_advertisement_service_provider.cc
index aa3f234..f6a4c44 100644
--- a/chromeos/dbus/bluetooth_le_advertisement_service_provider.cc
+++ b/chromeos/dbus/bluetooth_le_advertisement_service_provider.cc
@@ -37,7 +37,6 @@ class BluetoothAdvertisementServiceProviderImpl
: origin_thread_id_(base::PlatformThread::CurrentId()),
bus_(bus),
delegate_(delegate),
- object_path_(object_path),
type_(type),
service_uuids_(service_uuids.Pass()),
manufacturer_data_(manufacturer_data.Pass()),
@@ -49,6 +48,7 @@ class BluetoothAdvertisementServiceProviderImpl
VLOG(1) << "Creating Bluetooth Advertisement: " << object_path_.value();
+ object_path_ = object_path;
exported_object_ = bus_->GetExportedObject(object_path_);
// Export Bluetooth Advertisement interface methods.
@@ -358,10 +358,6 @@ class BluetoothAdvertisementServiceProviderImpl
// owns this one, and must outlive it.
Delegate* delegate_;
- // D-Bus object path of object we are exporting, kept so we can unregister
- // again in our destructor.
- dbus::ObjectPath object_path_;
-
// Advertisement data that needs to be provided to BlueZ when requested.
AdvertisementType type_;
scoped_ptr<UUIDList> service_uuids_;
@@ -391,7 +387,7 @@ BluetoothLEAdvertisementServiceProvider::
}
// static
-BluetoothLEAdvertisementServiceProvider*
+scoped_ptr<BluetoothLEAdvertisementServiceProvider>
BluetoothLEAdvertisementServiceProvider::Create(
dbus::Bus* bus,
const dbus::ObjectPath& object_path,
@@ -402,12 +398,12 @@ BluetoothLEAdvertisementServiceProvider::Create(
scoped_ptr<UUIDList> solicit_uuids,
scoped_ptr<ServiceData> service_data) {
if (!DBusThreadManager::Get()->IsUsingStub(DBusClientBundle::BLUETOOTH)) {
- return new BluetoothAdvertisementServiceProviderImpl(
+ return make_scoped_ptr(new BluetoothAdvertisementServiceProviderImpl(
bus, object_path, delegate, type, service_uuids.Pass(),
- manufacturer_data.Pass(), solicit_uuids.Pass(), service_data.Pass());
+ manufacturer_data.Pass(), solicit_uuids.Pass(), service_data.Pass()));
} else {
- return new FakeBluetoothLEAdvertisementServiceProvider(object_path,
- delegate);
+ return make_scoped_ptr(
+ new FakeBluetoothLEAdvertisementServiceProvider(object_path, delegate));
}
}
diff --git a/chromeos/dbus/bluetooth_le_advertisement_service_provider.h b/chromeos/dbus/bluetooth_le_advertisement_service_provider.h
index 4cea5d8..98622a2 100644
--- a/chromeos/dbus/bluetooth_le_advertisement_service_provider.h
+++ b/chromeos/dbus/bluetooth_le_advertisement_service_provider.h
@@ -50,11 +50,13 @@ class CHROMEOS_EXPORT BluetoothLEAdvertisementServiceProvider {
virtual ~BluetoothLEAdvertisementServiceProvider();
+ const dbus::ObjectPath& object_path() { return object_path_; }
+
// Creates the instance where |bus| is the D-Bus bus connection to export
// the object onto, |object_path| is the object path that it should have
// and |delegate| is the object to which all method calls will be passed
// and responses generated from.
- static BluetoothLEAdvertisementServiceProvider* Create(
+ static scoped_ptr<BluetoothLEAdvertisementServiceProvider> Create(
dbus::Bus* bus,
const dbus::ObjectPath& object_path,
Delegate* delegate,
@@ -67,6 +69,10 @@ class CHROMEOS_EXPORT BluetoothLEAdvertisementServiceProvider {
protected:
BluetoothLEAdvertisementServiceProvider();
+ // D-Bus object path of object we are exporting, kept so we can unregister
+ // again in our destructor.
+ dbus::ObjectPath object_path_;
+
private:
DISALLOW_COPY_AND_ASSIGN(BluetoothLEAdvertisementServiceProvider);
};
diff --git a/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.cc b/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.cc
index 24bfb4f..ce46e3d 100644
--- a/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.cc
+++ b/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.cc
@@ -3,8 +3,8 @@
// found in the LICENSE file.
#include "chromeos/dbus/dbus_thread_manager.h"
-#include "fake_bluetooth_le_advertisement_service_provider.h"
-#include "fake_bluetooth_le_advertising_manager_client.h"
+#include "chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h"
+#include "chromeos/dbus/fake_bluetooth_le_advertising_manager_client.h"
namespace chromeos {
@@ -12,7 +12,8 @@ FakeBluetoothLEAdvertisementServiceProvider::
FakeBluetoothLEAdvertisementServiceProvider(
const dbus::ObjectPath& object_path,
Delegate* delegate)
- : object_path_(object_path), delegate_(delegate) {
+ : delegate_(delegate) {
+ object_path_ = object_path;
VLOG(1) << "Creating Bluetooth Advertisement: " << object_path_.value();
FakeBluetoothLEAdvertisingManagerClient*
diff --git a/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h b/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h
index c56abb4..5a19aee 100644
--- a/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h
+++ b/chromeos/dbus/fake_bluetooth_le_advertisement_service_provider.h
@@ -36,9 +36,6 @@ class CHROMEOS_EXPORT FakeBluetoothLEAdvertisementServiceProvider
private:
friend class FakeBluetoothLEAdvertisingManagerClient;
- // D-Bus object path we are faking.
- dbus::ObjectPath object_path_;
-
// All incoming method calls are passed on to the Delegate and a callback
// passed to generate the reply. |delegate_| is generally the object that
// owns this one, and must outlive it.
diff --git a/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.cc b/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.cc
index 8145d1c..5702832 100644
--- a/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.cc
+++ b/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.cc
@@ -54,9 +54,6 @@ void FakeBluetoothLEAdvertisingManagerClient::RegisterAdvertisement(
} else if (!currently_registered_.value().empty()) {
error_callback.Run(bluetooth_advertising_manager::kErrorFailed,
"Maximum advertisements reached");
- } else if (advertisement_object_path != currently_registered_) {
- error_callback.Run(bluetooth_advertising_manager::kErrorAlreadyExists,
- "Already advertising.");
} else {
currently_registered_ = advertisement_object_path;
base::MessageLoop::current()->PostTask(FROM_HERE, callback);
diff --git a/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.h b/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.h
index ff340e8..5df129c 100644
--- a/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.h
+++ b/chromeos/dbus/fake_bluetooth_le_advertising_manager_client.h
@@ -11,8 +11,8 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/observer_list.h"
-#include "bluetooth_le_advertising_manager_client.h"
#include "chromeos/chromeos_export.h"
+#include "chromeos/dbus/bluetooth_le_advertising_manager_client.h"
#include "dbus/object_path.h"
#include "dbus/property.h"