summaryrefslogtreecommitdiffstats
path: root/device
diff options
context:
space:
mode:
authoryoungki@chromium.org <youngki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 03:15:23 +0000
committeryoungki@chromium.org <youngki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-01 03:15:23 +0000
commitb24df959055631ff52b47097053948f597eb0a0c (patch)
tree3cbd381f4d4c7678513d700e5cab11f12e807504 /device
parent2044f3e8a4c99951ad45f63c6e4814da6c20cb00 (diff)
downloadchromium_src-b24df959055631ff52b47097053948f597eb0a0c.zip
chromium_src-b24df959055631ff52b47097053948f597eb0a0c.tar.gz
chromium_src-b24df959055631ff52b47097053948f597eb0a0c.tar.bz2
Implemented chrome.bluetooth.addProfile and chrome.bluetooth.removeProfile.
We will reject the registration of the profiles that have already been registered. When there is an incoming connection, we will route that connection to the extension that registered the profile. BUG=229636 Review URL: https://chromiumcodereview.appspot.com/14311007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197554 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device')
-rw-r--r--device/bluetooth/bluetooth_profile.h9
-rw-r--r--device/bluetooth/bluetooth_profile_mac.h5
-rw-r--r--device/bluetooth/bluetooth_profile_mac.mm7
-rw-r--r--device/bluetooth/test/mock_bluetooth_profile.cc15
-rw-r--r--device/bluetooth/test/mock_bluetooth_profile.h25
-rw-r--r--device/device.gyp2
6 files changed, 56 insertions, 7 deletions
diff --git a/device/bluetooth/bluetooth_profile.h b/device/bluetooth/bluetooth_profile.h
index 466bdf2..46200b3 100644
--- a/device/bluetooth/bluetooth_profile.h
+++ b/device/bluetooth/bluetooth_profile.h
@@ -12,8 +12,10 @@
namespace device {
+class BluetoothDevice;
class BluetoothProfileMac;
class BluetoothSocket;
+class MockBluetoothProfile;
// BluetoothProfile represents an implementation of either a client or server
// of a particular specified profile (aka service or protocol in other
@@ -92,11 +94,14 @@ class BluetoothProfile {
// The socket will be closed when all references are released; none of the
// BluetoothProfile, or BluetoothAdapter or BluetoothDevice objects are
// guaranteed to hold a reference so this may outlive all of them.
- typedef base::Callback<void(scoped_refptr<BluetoothSocket>)> SocketCallback;
- virtual void SetConnectionCallback(const SocketCallback& callback) = 0;
+ typedef base::Callback<void(
+ const BluetoothDevice*,
+ scoped_refptr<BluetoothSocket>)> ConnectionCallback;
+ virtual void SetConnectionCallback(const ConnectionCallback& callback) = 0;
private:
friend class BluetoothProfileMac;
+ friend class MockBluetoothProfile;
BluetoothProfile();
virtual ~BluetoothProfile();
diff --git a/device/bluetooth/bluetooth_profile_mac.h b/device/bluetooth/bluetooth_profile_mac.h
index 34b6b34..0085efd 100644
--- a/device/bluetooth/bluetooth_profile_mac.h
+++ b/device/bluetooth/bluetooth_profile_mac.h
@@ -23,7 +23,8 @@ class BluetoothProfileMac : public BluetoothProfile {
public:
// BluetoothProfile override.
virtual void Unregister() OVERRIDE;
- virtual void SetConnectionCallback(const SocketCallback& callback) OVERRIDE;
+ virtual void SetConnectionCallback(
+ const ConnectionCallback& callback) OVERRIDE;
// Makes an outgoing connection to |device|.
// This method runs |socket_callback_| with the socket and returns true if the
@@ -38,7 +39,7 @@ class BluetoothProfileMac : public BluetoothProfile {
const std::string uuid_;
const std::string name_;
- SocketCallback socket_callback_;
+ ConnectionCallback connection_callback_;
};
} // namespace device
diff --git a/device/bluetooth/bluetooth_profile_mac.mm b/device/bluetooth/bluetooth_profile_mac.mm
index ca50f06..c0658a9 100644
--- a/device/bluetooth/bluetooth_profile_mac.mm
+++ b/device/bluetooth/bluetooth_profile_mac.mm
@@ -59,8 +59,8 @@ void BluetoothProfileMac::Unregister() {
}
void BluetoothProfileMac::SetConnectionCallback(
- const SocketCallback& callback) {
- socket_callback_ = callback;
+ const ConnectionCallback& callback) {
+ connection_callback_ = callback;
}
bool BluetoothProfileMac::Connect(IOBluetoothDevice* device) {
@@ -70,7 +70,8 @@ bool BluetoothProfileMac::Connect(IOBluetoothDevice* device) {
scoped_refptr<BluetoothSocket> socket(
BluetoothSocketMac::CreateBluetoothSocket(record));
if (socket.get() != NULL) {
- socket_callback_.Run(socket);
+ BluetoothDeviceMac device_mac(device);
+ connection_callback_.Run(&device_mac, socket);
return true;
}
}
diff --git a/device/bluetooth/test/mock_bluetooth_profile.cc b/device/bluetooth/test/mock_bluetooth_profile.cc
new file mode 100644
index 0000000..bf2af21
--- /dev/null
+++ b/device/bluetooth/test/mock_bluetooth_profile.cc
@@ -0,0 +1,15 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "device/bluetooth/test/mock_bluetooth_profile.h"
+
+namespace device {
+
+MockBluetoothProfile::MockBluetoothProfile() {
+}
+
+MockBluetoothProfile::~MockBluetoothProfile() {
+}
+
+} // namespace device
diff --git a/device/bluetooth/test/mock_bluetooth_profile.h b/device/bluetooth/test/mock_bluetooth_profile.h
new file mode 100644
index 0000000..92b7505
--- /dev/null
+++ b/device/bluetooth/test/mock_bluetooth_profile.h
@@ -0,0 +1,25 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_PROFILE_H_
+#define DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_PROFILE_H_
+
+#include "device/bluetooth/bluetooth_profile.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace device {
+
+class MockBluetoothProfile : public BluetoothProfile {
+ public:
+ MockBluetoothProfile();
+ virtual ~MockBluetoothProfile();
+
+ MOCK_METHOD0(Unregister, void());
+ MOCK_METHOD1(SetConnectionCallback,
+ void(const BluetoothProfile::ConnectionCallback&));
+};
+
+} // namespace device
+
+#endif // DEVICE_BLUETOOTH_TEST_MOCK_BLUETOOTH_PROFILE_H_
diff --git a/device/device.gyp b/device/device.gyp
index 3f3d010..6afb8a0 100644
--- a/device/device.gyp
+++ b/device/device.gyp
@@ -110,6 +110,8 @@
'bluetooth/test/mock_bluetooth_adapter.h',
'bluetooth/test/mock_bluetooth_device.cc',
'bluetooth/test/mock_bluetooth_device.h',
+ 'bluetooth/test/mock_bluetooth_profile.cc',
+ 'bluetooth/test/mock_bluetooth_profile.h',
'bluetooth/test/mock_bluetooth_socket.cc',
'bluetooth/test/mock_bluetooth_socket.h',
],