diff options
author | yoichio <yoichio@chromium.org> | 2014-10-13 20:38:36 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-10-14 03:38:59 +0000 |
commit | ab9f183ccbec50c1bfa42514019e089fccd9f0f4 (patch) | |
tree | 3eac7d6801e3c5e6015525e1ffdb8ea7f358a8b2 /components/proximity_auth | |
parent | eb552d78ea8a447dcecc5d828bc11eae7a2121d3 (diff) | |
download | chromium_src-ab9f183ccbec50c1bfa42514019e089fccd9f0f4.zip chromium_src-ab9f183ccbec50c1bfa42514019e089fccd9f0f4.tar.gz chromium_src-ab9f183ccbec50c1bfa42514019e089fccd9f0f4.tar.bz2 |
Revert of [Easy Unlock] Port the BluetoothConnectionFinder class to native code. (patchset #4 id:320001 of https://codereview.chromium.org/633253002/)
Reason for revert:
Causes compile failure on mac:
http://build.chromium.org/p/chromium.mac/builders/Mac%20Builder%20%28dbg%29/builds/75518
Original issue's description:
> [Easy Unlock] Port the BluetoothConnectionFinder class to native code.
>
> A couple of pieces are left as TODOs for future CLs:
> * Porting the "seek device by Bluetooth address" feature.
> * Wiring up a screen lock state accessor.
>
> BUG=420946
> TEST=components_unittests
> R=tengs@chromium.org
>
> Committed: https://crrev.com/ac4df1c4df6fdc7c771eb0bdeb15dbd6f2dbb98c
> Cr-Commit-Position: refs/heads/master@{#299415}
TBR=tengs@chromium.org,isherman@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=420946
Review URL: https://codereview.chromium.org/651073002
Cr-Commit-Position: refs/heads/master@{#299420}
Diffstat (limited to 'components/proximity_auth')
-rw-r--r-- | components/proximity_auth/BUILD.gn | 13 | ||||
-rw-r--r-- | components/proximity_auth/bluetooth_connection.cc | 2 | ||||
-rw-r--r-- | components/proximity_auth/bluetooth_connection_finder.cc | 145 | ||||
-rw-r--r-- | components/proximity_auth/bluetooth_connection_finder.h | 108 | ||||
-rw-r--r-- | components/proximity_auth/bluetooth_connection_finder_unittest.cc | 277 | ||||
-rw-r--r-- | components/proximity_auth/connection_finder.h | 37 | ||||
-rw-r--r-- | components/proximity_auth/connection_observer.h | 6 |
7 files changed, 10 insertions, 578 deletions
diff --git a/components/proximity_auth/BUILD.gn b/components/proximity_auth/BUILD.gn index edba900..caf35b4 100644 --- a/components/proximity_auth/BUILD.gn +++ b/components/proximity_auth/BUILD.gn @@ -6,14 +6,11 @@ source_set("proximity_auth") { sources = [ "bluetooth_connection.cc", "bluetooth_connection.h", - "bluetooth_connection_finder.cc", - "bluetooth_connection_finder.h", "bluetooth_util.cc", "bluetooth_util_chromeos.cc", "bluetooth_util.h", "connection.cc", "connection.h", - "connection_finder.h", "connection_observer.h", "proximity_auth_system.cc", "proximity_auth_system.h", @@ -35,7 +32,6 @@ source_set("unit_tests") { testonly = true sources = [ "bluetooth_connection_unittest.cc", - "bluetooth_connection_finder_unittest.cc", "connection_unittest.cc", "proximity_auth_system_unittest.cc", "remote_status_update_unittest.cc", @@ -55,6 +51,11 @@ source_set("unit_tests") { # Note: This is a convenience target for ease of rapid iteration during # development. It is not executed on any try or build bots. test("proximity_auth_unittests") { - sources = [ "run_all_unittests.cc" ] - deps = [ ":unit_tests" ] + sources = [ + "run_all_unittests.cc", + ] + + deps = [ + ":unit_tests", + ] } diff --git a/components/proximity_auth/bluetooth_connection.cc b/components/proximity_auth/bluetooth_connection.cc index d5a2b65..fdc7103 100644 --- a/components/proximity_auth/bluetooth_connection.cc +++ b/components/proximity_auth/bluetooth_connection.cc @@ -120,8 +120,6 @@ void BluetoothConnection::OnAdapterInitialized( if (!bluetooth_device) { VLOG(1) << "[BC] Device with address " << address << " is not known to the system Bluetooth daemon."; - // TOOD(isherman): Optimistically attempt to seek the device and connect - // anyway, as was previously implemented in BluetoothConnectionFinder. Disconnect(); return; } diff --git a/components/proximity_auth/bluetooth_connection_finder.cc b/components/proximity_auth/bluetooth_connection_finder.cc deleted file mode 100644 index 3fe6567..0000000 --- a/components/proximity_auth/bluetooth_connection_finder.cc +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2014 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 "components/proximity_auth/bluetooth_connection_finder.h" - -#include "base/bind.h" -#include "base/location.h" -#include "base/logging.h" -#include "base/message_loop/message_loop_proxy.h" -#include "components/proximity_auth/bluetooth_connection.h" -#include "device/bluetooth/bluetooth_adapter_factory.h" - -using device::BluetoothAdapter; - -namespace proximity_auth { - -BluetoothConnectionFinder::BluetoothConnectionFinder( - const RemoteDevice& remote_device, - const device::BluetoothUUID& uuid, - const base::TimeDelta& polling_interval) - : remote_device_(remote_device), - uuid_(uuid), - polling_interval_(polling_interval), - has_delayed_poll_scheduled_(false), - weak_ptr_factory_(this) { -} - -BluetoothConnectionFinder::~BluetoothConnectionFinder() { - UnregisterAsObserver(); -} - -void BluetoothConnectionFinder::Find( - const ConnectionCallback& connection_callback) { - if (!device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) { - VLOG(1) << "[BCF] Bluetooth is unsupported on this platform. Aborting."; - return; - } - - DCHECK(start_time_.is_null()); - VLOG(1) << "[BCF] Finding Bluetooth connection..."; - - start_time_ = base::TimeTicks::Now(); - connection_callback_ = connection_callback; - - device::BluetoothAdapterFactory::GetAdapter( - base::Bind(&BluetoothConnectionFinder::OnAdapterInitialized, - weak_ptr_factory_.GetWeakPtr())); -} - -scoped_ptr<Connection> BluetoothConnectionFinder::CreateConnection() { - return scoped_ptr<Connection>(new BluetoothConnection(remote_device_, uuid_)); -} - -bool BluetoothConnectionFinder::IsReadyToPoll() { - bool is_adapter_available = - adapter_.get() && adapter_->IsPresent() && adapter_->IsPowered(); - VLOG(1) << "[BCF] Readiness: adapter=" - << (is_adapter_available ? "available" : "unavailable"); - return is_adapter_available; -} - -void BluetoothConnectionFinder::PollIfReady() { - if (!IsReadyToPoll()) - return; - - // If there is a pending task to poll at a later time, the time requisite - // timeout has not yet elapsed since the previous polling attempt. In that - // case, keep waiting until the delayed task comes in. - if (has_delayed_poll_scheduled_) - return; - - // If the |connection_| exists, wait for it to connect or fail prior to - // polling again. - if (connection_) - return; - - VLOG(1) << "[BCF] Polling for connection..."; - connection_ = CreateConnection(); - connection_->AddObserver(this); - connection_->Connect(); -} - -void BluetoothConnectionFinder::DelayedPollIfReady() { - // Note that there is no longer a pending task, and therefore polling is - // permitted. - has_delayed_poll_scheduled_ = false; - PollIfReady(); -} - -void BluetoothConnectionFinder::UnregisterAsObserver() { - if (connection_) { - connection_->RemoveObserver(this); - // The connection is about to be released or destroyed, so no need to clear - // it explicitly here. - } - - if (adapter_.get()) { - adapter_->RemoveObserver(this); - adapter_ = NULL; - } -} - -void BluetoothConnectionFinder::OnAdapterInitialized( - scoped_refptr<BluetoothAdapter> adapter) { - adapter_ = adapter; - adapter_->AddObserver(this); - PollIfReady(); -} - -void BluetoothConnectionFinder::AdapterPresentChanged(BluetoothAdapter* adapter, - bool present) { - PollIfReady(); -} - -void BluetoothConnectionFinder::AdapterPoweredChanged(BluetoothAdapter* adapter, - bool powered) { - PollIfReady(); -} - -void BluetoothConnectionFinder::OnConnectionStatusChanged( - const Connection& connection, - Connection::Status old_status, - Connection::Status new_status) { - DCHECK_EQ(&connection, connection_.get()); - - if (connection_->IsConnected()) { - base::TimeDelta elapsed = base::TimeTicks::Now() - start_time_; - VLOG(1) << "[BCF] Connection found! Elapsed Time: " - << elapsed.InMilliseconds() << "ms."; - UnregisterAsObserver(); - connection_callback_.Run(connection_.Pass()); - } else if (old_status == Connection::IN_PROGRESS) { - VLOG(1) << "[BCF] Connection failed! Scheduling another polling iteration."; - connection_.reset(); - has_delayed_poll_scheduled_ = true; - base::MessageLoopProxy::current()->PostDelayedTask( - FROM_HERE, - base::Bind(&BluetoothConnectionFinder::DelayedPollIfReady, - weak_ptr_factory_.GetWeakPtr()), - polling_interval_); - } -} - -} // namespace proximity_auth diff --git a/components/proximity_auth/bluetooth_connection_finder.h b/components/proximity_auth/bluetooth_connection_finder.h deleted file mode 100644 index 8de83b7..0000000 --- a/components/proximity_auth/bluetooth_connection_finder.h +++ /dev/null @@ -1,108 +0,0 @@ -// Copyright 2014 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 COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_FINDER_H -#define COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_FINDER_H - -#include "base/callback.h" -#include "base/macros.h" -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "base/memory/weak_ptr.h" -#include "base/time/time.h" -#include "components/proximity_auth/connection_finder.h" -#include "components/proximity_auth/connection_observer.h" -#include "components/proximity_auth/remote_device.h" -#include "device/bluetooth/bluetooth_adapter.h" -#include "device/bluetooth/bluetooth_uuid.h" - -namespace proximity_auth { - -class BluetoothConnection; - -// This ConnectionFinder implementation tries to find a Bluetooth connection to -// the remote device by polling at a fixed interval. -class BluetoothConnectionFinder : public ConnectionFinder, - public ConnectionObserver, - public device::BluetoothAdapter::Observer { - public: - BluetoothConnectionFinder(const RemoteDevice& remote_device, - const device::BluetoothUUID& uuid, - const base::TimeDelta& polling_interval); - virtual ~BluetoothConnectionFinder(); - - // ConnectionFinder: - virtual void Find(const ConnectionCallback& connection_callback) override; - - protected: - // Exposed for mocking out the connection in tests. - virtual scoped_ptr<Connection> CreateConnection(); - - // BluetoothAdapter::Observer: - virtual void AdapterPresentChanged(device::BluetoothAdapter* adapter, - bool present) override; - virtual void AdapterPoweredChanged(device::BluetoothAdapter* adapter, - bool powered) override; - - private: - // Returns true iff the Bluetooth adapter is ready to make connections. - bool IsReadyToPoll(); - - // Attempts to connect to the |remote_device_| if the system is ready for - // another iteration of polling. - void PollIfReady(); - - // Wrapper around |PollIfReady()| that can be posted as a delayed task. - void DelayedPollIfReady(); - - // Unregisters |this| instance as an observer from all objects that it might - // have registered with. - void UnregisterAsObserver(); - - // Callback to be called when the Bluetooth adapter is initialized. - void OnAdapterInitialized(scoped_refptr<device::BluetoothAdapter> adapter); - - // ConnectionObserver: - virtual void OnConnectionStatusChanged( - const Connection& connection, - Connection::Status old_status, - Connection::Status new_status) override; - - // The remote device to connect to. - const RemoteDevice remote_device_; - - // The UUID of the service on the remote device. - const device::BluetoothUUID uuid_; - - // The time to wait between polling attempts. - const base::TimeDelta polling_interval_; - - // Records the time at which the finder began searching for connections. - base::TimeTicks start_time_; - - // The callback that should be called upon a successful connection. - ConnectionCallback connection_callback_; - - // The Bluetooth adapter over which the Bluetooth connection will be made. - scoped_refptr<device::BluetoothAdapter> adapter_; - - // The Bluetooth connection that will be opened. - scoped_ptr<Connection> connection_; - - // Whether there is currently a polling task scheduled. - bool has_delayed_poll_scheduled_; - - // Used to schedule everything else. - base::WeakPtrFactory<BluetoothConnectionFinder> weak_ptr_factory_; - - DISALLOW_COPY_AND_ASSIGN(BluetoothConnectionFinder); -}; - -// TODO(isherman): Make sure to wire up the controller to listen for screen lock -// state change events, and create or destroy the connection finder as -// appropriate. - -} // namespace proximity_auth - -#endif // COMPONENTS_PROXIMITY_AUTH_BLUETOOTH_CONNECTION_FINDER_H diff --git a/components/proximity_auth/bluetooth_connection_finder_unittest.cc b/components/proximity_auth/bluetooth_connection_finder_unittest.cc deleted file mode 100644 index fc0804e..0000000 --- a/components/proximity_auth/bluetooth_connection_finder_unittest.cc +++ /dev/null @@ -1,277 +0,0 @@ -// Copyright 2014 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 "components/proximity_auth/bluetooth_connection_finder.h" - -#include "base/bind.h" -#include "base/memory/ref_counted.h" -#include "base/memory/scoped_ptr.h" -#include "base/message_loop/message_loop.h" -#include "base/run_loop.h" -#include "base/time/time.h" -#include "components/proximity_auth/remote_device.h" -#include "components/proximity_auth/wire_message.h" -#include "device/bluetooth/bluetooth_adapter_factory.h" -#include "device/bluetooth/bluetooth_uuid.h" -#include "device/bluetooth/test/mock_bluetooth_adapter.h" -#include "testing/gmock/include/gmock/gmock.h" -#include "testing/gtest/include/gtest/gtest.h" - -using testing::_; -using testing::NiceMock; -using testing::Return; -using testing::StrictMock; - -namespace proximity_auth { -namespace { - -const char kDeviceName[] = "Device name"; -const char kBluetoothAddress[] = "11:22:33:44:55:66"; -const RemoteDevice kRemoteDevice = {kDeviceName, kBluetoothAddress}; - -const char kUuid[] = "DEADBEEF-CAFE-FEED-FOOD-D15EA5EBEEF"; - -class MockConnection : public Connection { - public: - MockConnection() : Connection(kRemoteDevice) {} - virtual ~MockConnection() {} - - MOCK_METHOD0(Connect, void()); - - using Connection::SetStatus; - - private: - void Disconnect() {} - void SendMessageImpl(scoped_ptr<WireMessage> message) {} - - DISALLOW_COPY_AND_ASSIGN(MockConnection); -}; - -class MockBluetoothConnectionFinder : public BluetoothConnectionFinder { - public: - MockBluetoothConnectionFinder() - : BluetoothConnectionFinder(kRemoteDevice, - device::BluetoothUUID(kUuid), - base::TimeDelta()) {} - virtual ~MockBluetoothConnectionFinder() {} - - MOCK_METHOD0(CreateConnectionProxy, Connection*()); - - // Creates a mock connection and sets an expectation that the mock connection - // finder's CreateConnection() method will be called and will return the - // created connection. Returns a reference to the created connection. - // NOTE: The returned connection's lifetime is managed by the connection - // finder. - MockConnection* ExpectCreateConnection() { - scoped_ptr<MockConnection> connection(new NiceMock<MockConnection>()); - MockConnection* connection_alias = connection.get(); - EXPECT_CALL(*this, CreateConnectionProxy()) - .WillOnce(Return(connection.release())); - return connection_alias; - } - - using BluetoothConnectionFinder::AdapterPresentChanged; - using BluetoothConnectionFinder::AdapterPoweredChanged; - - protected: - virtual scoped_ptr<Connection> CreateConnection() override { - return make_scoped_ptr(CreateConnectionProxy()); - } - - private: - DISALLOW_COPY_AND_ASSIGN(MockBluetoothConnectionFinder); -}; - -} // namespace - -class ProximityAuthBluetoothConnectionFinderTest : public testing::Test { - protected: - ProximityAuthBluetoothConnectionFinderTest() - : adapter_(new NiceMock<device::MockBluetoothAdapter>), - connection_callback_(base::Bind( - &ProximityAuthBluetoothConnectionFinderTest::OnConnectionFound, - base::Unretained(this))) { - device::BluetoothAdapterFactory::SetAdapterForTesting(adapter_); - - // By default, configure the environment to allow polling. Individual tests - // can override this as needed. - ON_CALL(*adapter_, IsPresent()).WillByDefault(Return(true)); - ON_CALL(*adapter_, IsPowered()).WillByDefault(Return(true)); - } - - MOCK_METHOD1(OnConnectionFoundProxy, void(Connection* connection)); - void OnConnectionFound(scoped_ptr<Connection> connection) { - OnConnectionFoundProxy(connection.get()); - last_found_connection_ = connection.Pass(); - } - - scoped_refptr<device::MockBluetoothAdapter> adapter_; - ConnectionFinder::ConnectionCallback connection_callback_; - - private: - // Save a pointer to the last found connection, to extend its lifetime. - scoped_ptr<Connection> last_found_connection_; - - base::MessageLoop message_loop_; -}; - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, - ConstructAndDestroyDoesntCrash) { - // Destroying a BluetoothConnectionFinder for which Find() has not been called - // should not crash. - BluetoothConnectionFinder connection_finder( - kRemoteDevice, - device::BluetoothUUID(kUuid), - base::TimeDelta::FromMilliseconds(1)); -} - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, Find_NoBluetoothAdapter) { - // Some platforms do not support Bluetooth. This test is only meaningful on - // those platforms. - adapter_ = NULL; - if (device::BluetoothAdapterFactory::IsBluetoothAdapterAvailable()) - return; - - // The StrictMock will verify that no connection is created. - StrictMock<MockBluetoothConnectionFinder> connection_finder; - connection_finder.Find(connection_callback_); -} - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, - Find_BluetoothAdapterNotPresent) { - // The StrictMock will verify that no connection is created. - StrictMock<MockBluetoothConnectionFinder> connection_finder; - ON_CALL(*adapter_, IsPresent()).WillByDefault(Return(false)); - connection_finder.Find(connection_callback_); -} - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, - Find_BluetoothAdapterNotPowered) { - // The StrictMock will verify that no connection is created. - StrictMock<MockBluetoothConnectionFinder> connection_finder; - ON_CALL(*adapter_, IsPowered()).WillByDefault(Return(false)); - connection_finder.Find(connection_callback_); -} - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, Find_ConnectionSucceeds) { - StrictMock<MockBluetoothConnectionFinder> connection_finder; - - MockConnection* connection = connection_finder.ExpectCreateConnection(); - connection_finder.Find(connection_callback_); - - connection->SetStatus(Connection::IN_PROGRESS); - - EXPECT_CALL(*this, OnConnectionFoundProxy(_)); - connection->SetStatus(Connection::CONNECTED); -} - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, - Find_ConnectionSucceeds_UnregistersAsObserver) { - StrictMock<MockBluetoothConnectionFinder> connection_finder; - - MockConnection* connection = connection_finder.ExpectCreateConnection(); - connection_finder.Find(connection_callback_); - - connection->SetStatus(Connection::IN_PROGRESS); - - EXPECT_CALL(*this, OnConnectionFoundProxy(_)); - EXPECT_CALL(*adapter_, RemoveObserver(&connection_finder)); - connection->SetStatus(Connection::CONNECTED); - - // If for some reason the connection sends more status updates, they should be - // ignored. - EXPECT_CALL(*this, OnConnectionFoundProxy(_)).Times(0); - connection->SetStatus(Connection::IN_PROGRESS); - connection->SetStatus(Connection::CONNECTED); -} - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, - Find_ConnectionFails_PostsTaskToPollAgain) { - StrictMock<MockBluetoothConnectionFinder> connection_finder; - - MockConnection* connection = connection_finder.ExpectCreateConnection(); - connection_finder.Find(connection_callback_); - - // Simulate a connection that fails to connect. - connection->SetStatus(Connection::IN_PROGRESS); - connection->SetStatus(Connection::DISCONNECTED); - - // A task should have been posted to poll again. - base::RunLoop run_loop; - connection_finder.ExpectCreateConnection(); - run_loop.RunUntilIdle(); -} - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, Find_PollsOnAdapterPresent) { - StrictMock<MockBluetoothConnectionFinder> connection_finder; - - ON_CALL(*adapter_, IsPresent()).WillByDefault(Return(false)); - EXPECT_CALL(connection_finder, CreateConnectionProxy()).Times(0); - connection_finder.Find(connection_callback_); - - ON_CALL(*adapter_, IsPresent()).WillByDefault(Return(true)); - connection_finder.ExpectCreateConnection(); - connection_finder.AdapterPresentChanged(adapter_.get(), true); -} - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, Find_PollsOnAdapterPowered) { - StrictMock<MockBluetoothConnectionFinder> connection_finder; - - ON_CALL(*adapter_, IsPowered()).WillByDefault(Return(false)); - EXPECT_CALL(connection_finder, CreateConnectionProxy()).Times(0); - connection_finder.Find(connection_callback_); - - ON_CALL(*adapter_, IsPowered()).WillByDefault(Return(true)); - connection_finder.ExpectCreateConnection(); - connection_finder.AdapterPoweredChanged(adapter_.get(), true); -} - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, - Find_DoesNotPollIfConnectionPending) { - StrictMock<MockBluetoothConnectionFinder> connection_finder; - - MockConnection* connection = connection_finder.ExpectCreateConnection(); - connection_finder.Find(connection_callback_); - - connection->SetStatus(Connection::IN_PROGRESS); - - // At this point, there is a pending connection in progress. Hence, an event - // that would normally trigger a new polling iteration should not do so now, - // because the delay interval between successive polling attempts has not yet - // expired. - EXPECT_CALL(connection_finder, CreateConnectionProxy()).Times(0); - connection_finder.AdapterPresentChanged(adapter_.get(), true); -} - -TEST_F(ProximityAuthBluetoothConnectionFinderTest, - Find_ConnectionFails_PostsTaskToPollAgain_PollWaitsForTask) { - StrictMock<MockBluetoothConnectionFinder> connection_finder; - - MockConnection* connection = connection_finder.ExpectCreateConnection(); - connection_finder.Find(connection_callback_); - - connection->SetStatus(Connection::IN_PROGRESS); - connection->SetStatus(Connection::DISCONNECTED); - - // At this point, there is a pending poll scheduled. Hence, an event that - // would normally trigger a new polling iteration should not do so now, - // because the delay interval between successive polling attempts has not yet - // expired. - EXPECT_CALL(connection_finder, CreateConnectionProxy()).Times(0); - connection_finder.AdapterPresentChanged(adapter_.get(), true); - - // Now, allow the pending task to run, but fail early, so that no new task is - // posted. - ON_CALL(*adapter_, IsPresent()).WillByDefault(Return(false)); - base::RunLoop run_loop; - run_loop.RunUntilIdle(); - ON_CALL(*adapter_, IsPresent()).WillByDefault(Return(true)); - - // Now that there is no pending task, events should once again trigger new - // polling iterations. - connection_finder.ExpectCreateConnection(); - connection_finder.AdapterPresentChanged(adapter_.get(), true); -} - -} // namespace proximity_auth diff --git a/components/proximity_auth/connection_finder.h b/components/proximity_auth/connection_finder.h deleted file mode 100644 index 51292da..0000000 --- a/components/proximity_auth/connection_finder.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright 2014 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 COMPONENTS_PROXIMITY_AUTH_CONNECTION_FINDER_H -#define COMPONENTS_PROXIMITY_AUTH_CONNECTION_FINDER_H - -#include "base/callback_forward.h" -#include "base/macros.h" -#include "base/memory/scoped_ptr.h" - -namespace proximity_auth { - -class Connection; - -// Interface for finding a connection to a remote device. -class ConnectionFinder { - public: - ConnectionFinder() {} - virtual ~ConnectionFinder() {} - - // Attempts to find a connection to a remote device. The finder will try to - // find the connection indefinitely until the finder is destroyed. Calls - // |connection_callback| with the open connection once the remote device is - // connected. - // TODO(isherman): Can this just be done as part of the constructor? - typedef base::Callback<void(scoped_ptr<Connection> connection)> - ConnectionCallback; - virtual void Find(const ConnectionCallback& connection_callback) = 0; - - private: - DISALLOW_COPY_AND_ASSIGN(ConnectionFinder); -}; - -} // namespace proximity_auth - -#endif // COMPONENTS_PROXIMITY_AUTH_CONNECTION_FINDER_H diff --git a/components/proximity_auth/connection_observer.h b/components/proximity_auth/connection_observer.h index 89bf974..5357890 100644 --- a/components/proximity_auth/connection_observer.h +++ b/components/proximity_auth/connection_observer.h @@ -18,18 +18,18 @@ class ConnectionObserver { // |new_status|. virtual void OnConnectionStatusChanged(const Connection& connection, Connection::Status old_status, - Connection::Status new_status) {} + Connection::Status new_status) = 0; // Called when a |message| is received from a remote device over the // |connection|. virtual void OnMessageReceived(const Connection& connection, - const WireMessage& message) {} + const WireMessage& message) = 0; // Called after a |message| is sent to the remote device over the // |connection|. |success| is |true| iff the message is sent successfully. virtual void OnSendCompleted(const Connection& connection, const WireMessage& message, - bool success) {} + bool success) = 0; }; } // namespace proximity_auth |