summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorisherman <isherman@chromium.org>2014-10-15 21:45:33 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-16 04:45:50 +0000
commit764baa24e4eb6a215551831b9d4d30316c724323 (patch)
tree5fbcfe6c2babc99c1ca8663a65dcfe8475e3893b /components
parentca595a12817b4855b2eb58a038b771d0bc76f664 (diff)
downloadchromium_src-764baa24e4eb6a215551831b9d4d30316c724323.zip
chromium_src-764baa24e4eb6a215551831b9d4d30316c724323.tar.gz
chromium_src-764baa24e4eb6a215551831b9d4d30316c724323.tar.bz2
[Clean up] Expose ConnectToServiceInsecurely as a BluetoothDevice API on all platforms.
As a result, stop using the private class BluetoothDeviceChromeOS from outside of the //device/bluetooth component. BUG=423114 TEST=compiles R=armansito@chromium.org Review URL: https://codereview.chromium.org/652403002 Cr-Commit-Position: refs/heads/master@{#299841}
Diffstat (limited to 'components')
-rw-r--r--components/proximity_auth/bluetooth_connection.cc14
-rw-r--r--components/proximity_auth/bluetooth_connection.h8
-rw-r--r--components/proximity_auth/bluetooth_connection_unittest.cc25
-rw-r--r--components/proximity_auth/bluetooth_util.cc10
-rw-r--r--components/proximity_auth/bluetooth_util.h12
-rw-r--r--components/proximity_auth/bluetooth_util_chromeos.cc10
6 files changed, 10 insertions, 69 deletions
diff --git a/components/proximity_auth/bluetooth_connection.cc b/components/proximity_auth/bluetooth_connection.cc
index d5a2b65..435793e 100644
--- a/components/proximity_auth/bluetooth_connection.cc
+++ b/components/proximity_auth/bluetooth_connection.cc
@@ -7,7 +7,6 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
#include "base/numerics/safe_conversions.h"
-#include "components/proximity_auth/bluetooth_util.h"
#include "components/proximity_auth/remote_device.h"
#include "components/proximity_auth/wire_message.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
@@ -96,16 +95,6 @@ void BluetoothConnection::DeviceRemoved(device::BluetoothAdapter* adapter,
Disconnect();
}
-void BluetoothConnection::ConnectToService(
- device::BluetoothDevice* device,
- const device::BluetoothUUID& uuid,
- const device::BluetoothDevice::ConnectToServiceCallback& callback,
- const device::BluetoothDevice::ConnectToServiceErrorCallback&
- error_callback) {
- bluetooth_util::ConnectToServiceInsecurely(
- device, uuid, callback, error_callback);
-}
-
void BluetoothConnection::StartReceive() {
base::WeakPtr<BluetoothConnection> weak_this = weak_ptr_factory_.GetWeakPtr();
socket_->Receive(kReceiveBufferSizeBytes,
@@ -130,8 +119,7 @@ void BluetoothConnection::OnAdapterInitialized(
adapter_->AddObserver(this);
base::WeakPtr<BluetoothConnection> weak_this = weak_ptr_factory_.GetWeakPtr();
- ConnectToService(
- bluetooth_device,
+ bluetooth_device->ConnectToServiceInsecurely(
uuid_,
base::Bind(&BluetoothConnection::OnConnected, weak_this),
base::Bind(&BluetoothConnection::OnConnectionError, weak_this));
diff --git a/components/proximity_auth/bluetooth_connection.h b/components/proximity_auth/bluetooth_connection.h
index 8b09a6f..ebe4f8d 100644
--- a/components/proximity_auth/bluetooth_connection.h
+++ b/components/proximity_auth/bluetooth_connection.h
@@ -45,14 +45,6 @@ class BluetoothConnection : public Connection,
virtual void DeviceRemoved(device::BluetoothAdapter* adapter,
device::BluetoothDevice* device) override;
- // Exposed for testing.
- virtual void ConnectToService(
- device::BluetoothDevice* device,
- const device::BluetoothUUID& uuid,
- const device::BluetoothDevice::ConnectToServiceCallback& callback,
- const device::BluetoothDevice::ConnectToServiceErrorCallback&
- error_callback);
-
private:
// Registers receive callbacks with the backing |socket_|.
void StartReceive();
diff --git a/components/proximity_auth/bluetooth_connection_unittest.cc b/components/proximity_auth/bluetooth_connection_unittest.cc
index 80c04e9..1476533 100644
--- a/components/proximity_auth/bluetooth_connection_unittest.cc
+++ b/components/proximity_auth/bluetooth_connection_unittest.cc
@@ -57,17 +57,6 @@ class MockBluetoothConnection : public BluetoothConnection {
MockBluetoothConnection()
: BluetoothConnection(kRemoteDevice, device::BluetoothUUID(kUuid)) {}
- // Bluetooth dependencies.
- typedef device::BluetoothDevice::ConnectToServiceCallback
- ConnectToServiceCallback;
- typedef device::BluetoothDevice::ConnectToServiceErrorCallback
- ConnectToServiceErrorCallback;
- MOCK_METHOD4(ConnectToService,
- void(device::BluetoothDevice* device,
- const device::BluetoothUUID& uuid,
- const ConnectToServiceCallback& callback,
- const ConnectToServiceErrorCallback& error_callback));
-
// Calls back into the parent Connection class.
MOCK_METHOD1(SetStatusProxy, void(Status status));
MOCK_METHOD1(OnBytesReceived, void(const std::string& bytes));
@@ -121,7 +110,7 @@ class ProximityAuthBluetoothConnectionTest : public testing::Test {
ON_CALL(*adapter_, GetDevice(_)).WillByDefault(Return(&device_));
EXPECT_CALL(*connection, SetStatusProxy(Connection::IN_PROGRESS));
EXPECT_CALL(*adapter_, AddObserver(connection));
- EXPECT_CALL(*connection, ConnectToService(&device_, uuid_, _, _));
+ EXPECT_CALL(device_, ConnectToServiceInsecurely(uuid_, _, _));
connection->Connect();
EXPECT_EQ(Connection::IN_PROGRESS, connection->status());
@@ -137,8 +126,8 @@ class ProximityAuthBluetoothConnectionTest : public testing::Test {
ON_CALL(*adapter_, GetDevice(_)).WillByDefault(Return(&device_));
EXPECT_CALL(*connection, SetStatusProxy(Connection::IN_PROGRESS));
EXPECT_CALL(*adapter_, AddObserver(connection));
- EXPECT_CALL(*connection, ConnectToService(_, _, _, _))
- .WillOnce(SaveArg<2>(&callback));
+ EXPECT_CALL(device_, ConnectToServiceInsecurely(_, _, _))
+ .WillOnce(SaveArg<1>(&callback));
connection->Connect();
ASSERT_FALSE(callback.is_null());
@@ -261,8 +250,8 @@ TEST_F(ProximityAuthBluetoothConnectionTest, Connect_ConnectionFails) {
ON_CALL(*adapter_, GetDevice(_)).WillByDefault(Return(&device_));
EXPECT_CALL(connection, SetStatusProxy(Connection::IN_PROGRESS));
EXPECT_CALL(*adapter_, AddObserver(&connection));
- EXPECT_CALL(connection, ConnectToService(&device_, uuid_, _, _))
- .WillOnce(SaveArg<3>(&error_callback));
+ EXPECT_CALL(device_, ConnectToServiceInsecurely(uuid_, _, _))
+ .WillOnce(SaveArg<2>(&error_callback));
connection.Connect();
ASSERT_FALSE(error_callback.is_null());
@@ -382,8 +371,8 @@ TEST_F(ProximityAuthBluetoothConnectionTest,
ON_CALL(*adapter_, GetDevice(_)).WillByDefault(Return(&device_));
EXPECT_CALL(connection, SetStatusProxy(Connection::IN_PROGRESS));
EXPECT_CALL(*adapter_, AddObserver(&connection));
- EXPECT_CALL(connection, ConnectToService(&device_, uuid_, _, _))
- .WillOnce(SaveArg<2>(&callback));
+ EXPECT_CALL(device_, ConnectToServiceInsecurely(uuid_, _, _))
+ .WillOnce(SaveArg<1>(&callback));
connection.Connect();
ASSERT_FALSE(callback.is_null());
diff --git a/components/proximity_auth/bluetooth_util.cc b/components/proximity_auth/bluetooth_util.cc
index 405dd23..27b377c 100644
--- a/components/proximity_auth/bluetooth_util.cc
+++ b/components/proximity_auth/bluetooth_util.cc
@@ -8,8 +8,6 @@
#include "base/callback.h"
-using device::BluetoothDevice;
-
namespace proximity_auth {
namespace bluetooth_util {
namespace {
@@ -23,14 +21,6 @@ void SeekDeviceByAddress(const std::string& device_address,
error_callback.Run(kApiUnavailable);
}
-void ConnectToServiceInsecurely(
- BluetoothDevice* device,
- const device::BluetoothUUID& uuid,
- const BluetoothDevice::ConnectToServiceCallback& callback,
- const BluetoothDevice::ConnectToServiceErrorCallback& error_callback) {
- error_callback.Run(kApiUnavailable);
-}
-
} // namespace bluetooth_util
} // namespace proximity_auth
diff --git a/components/proximity_auth/bluetooth_util.h b/components/proximity_auth/bluetooth_util.h
index 7bd94fc..ec1c2cc 100644
--- a/components/proximity_auth/bluetooth_util.h
+++ b/components/proximity_auth/bluetooth_util.h
@@ -8,10 +8,9 @@
#include <string>
#include "base/callback_forward.h"
-#include "device/bluetooth/bluetooth_device.h"
-namespace device {
-class BluetoothUUID;
+namespace base {
+class TaskRunner;
}
namespace proximity_auth {
@@ -29,13 +28,6 @@ void SeekDeviceByAddress(const std::string& device_address,
const ErrorCallback& error_callback,
base::TaskRunner* task_runner);
-void ConnectToServiceInsecurely(
- device::BluetoothDevice* device,
- const device::BluetoothUUID& uuid,
- const device::BluetoothDevice::ConnectToServiceCallback& callback,
- const device::BluetoothDevice::ConnectToServiceErrorCallback&
- error_callback);
-
} // namespace bluetooth_util
} // namespace proximity_auth
diff --git a/components/proximity_auth/bluetooth_util_chromeos.cc b/components/proximity_auth/bluetooth_util_chromeos.cc
index 162ea63..86a0758f 100644
--- a/components/proximity_auth/bluetooth_util_chromeos.cc
+++ b/components/proximity_auth/bluetooth_util_chromeos.cc
@@ -21,7 +21,6 @@
#include "base/threading/sequenced_worker_pool.h"
#include "base/time/time.h"
#include "device/bluetooth/bluetooth_device.h"
-#include "device/bluetooth/bluetooth_device_chromeos.h"
#include "net/socket/socket_descriptor.h"
// The bluez headers are (intentionally) not available within the Chromium
@@ -156,14 +155,5 @@ void SeekDeviceByAddress(const std::string& device_address,
base::Bind(&OnSeekDeviceResult, callback, error_callback));
}
-void ConnectToServiceInsecurely(
- device::BluetoothDevice* device,
- const device::BluetoothUUID& uuid,
- const BluetoothDevice::ConnectToServiceCallback& callback,
- const BluetoothDevice::ConnectToServiceErrorCallback& error_callback) {
- static_cast<chromeos::BluetoothDeviceChromeOS*>(device)
- ->ConnectToServiceInsecurely(uuid, callback, error_callback);
-}
-
} // namespace bluetooth_util
} // namespace proximity_auth