diff options
author | sacomoto <sacomoto@chromium.org> | 2015-08-05 02:05:13 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-08-05 09:06:50 +0000 |
commit | 7ae8d9c314c283e9d2d8b72e106d6625a009e7bc (patch) | |
tree | 4d64c28468bbd243364a8bb8e41dbd09f55d9935 /components/proximity_auth | |
parent | e889e14bcc4652d48ad01c43a14af857304f697f (diff) | |
download | chromium_src-7ae8d9c314c283e9d2d8b72e106d6625a009e7bc.zip chromium_src-7ae8d9c314c283e9d2d8b72e106d6625a009e7bc.tar.gz chromium_src-7ae8d9c314c283e9d2d8b72e106d6625a009e7bc.tar.bz2 |
Using WireMessage instead of FakeWireMessage.
This CL breaks the compatibility with BLE devices expecting FakeWireMessages.
This CL also fixes a bug when reconnecting to a given device. It no
longer removes the |adapter_| after the right device is found.
BUG=513675
Review URL: https://codereview.chromium.org/1251843002
Cr-Commit-Position: refs/heads/master@{#341872}
Diffstat (limited to 'components/proximity_auth')
5 files changed, 6 insertions, 19 deletions
diff --git a/components/proximity_auth/ble/bluetooth_low_energy_connection.cc b/components/proximity_auth/ble/bluetooth_low_energy_connection.cc index 3d7586e..e2c1153 100644 --- a/components/proximity_auth/ble/bluetooth_low_energy_connection.cc +++ b/components/proximity_auth/ble/bluetooth_low_energy_connection.cc @@ -299,11 +299,6 @@ BluetoothLowEnergyConnection::WriteRequest::WriteRequest( BluetoothLowEnergyConnection::WriteRequest::~WriteRequest() { } -scoped_ptr<WireMessage> BluetoothLowEnergyConnection::DeserializeWireMessage( - bool* is_incomplete_message) { - return FakeWireMessage::Deserialize(received_bytes(), is_incomplete_message); -} - void BluetoothLowEnergyConnection::CompleteConnection() { PA_LOG(INFO) << "Connection completed. Time elapsed: " << base::TimeTicks::Now() - start_time_; @@ -480,7 +475,7 @@ void BluetoothLowEnergyConnection::OnRemoteCharacteristicWritten( write_remote_characteristic_pending_ = false; // TODO(sacomoto): Actually pass the current message to the observer. if (run_did_send_message_callback) - OnDidSendMessage(FakeWireMessage(""), true); + OnDidSendMessage(WireMessage(std::string(), std::string()), true); // Removes the top of queue (already processed) and process the next request. DCHECK(!write_requests_queue_.empty()); @@ -496,7 +491,7 @@ void BluetoothLowEnergyConnection::OnWriteRemoteCharacteristicError( write_remote_characteristic_pending_ = false; // TODO(sacomoto): Actually pass the current message to the observer. if (run_did_send_message_callback) - OnDidSendMessage(FakeWireMessage(""), false); + OnDidSendMessage(WireMessage(std::string(), std::string()), false); // Increases the number of failed attempts and retry. DCHECK(!write_requests_queue_.empty()); diff --git a/components/proximity_auth/ble/bluetooth_low_energy_connection.h b/components/proximity_auth/ble/bluetooth_low_energy_connection.h index b2019b7..0efec2a 100644 --- a/components/proximity_auth/ble/bluetooth_low_energy_connection.h +++ b/components/proximity_auth/ble/bluetooth_low_energy_connection.h @@ -116,8 +116,6 @@ class BluetoothLowEnergyConnection : public Connection, // proximity_auth::Connection: void SendMessageImpl(scoped_ptr<WireMessage> message) override; - scoped_ptr<WireMessage> DeserializeWireMessage( - bool* is_incomplete_message) override; // device::BluetoothAdapter::Observer: void DeviceChanged(device::BluetoothAdapter* adapter, diff --git a/components/proximity_auth/ble/bluetooth_low_energy_connection_finder.cc b/components/proximity_auth/ble/bluetooth_low_energy_connection_finder.cc index 8b020a9..420500f 100644 --- a/components/proximity_auth/ble/bluetooth_low_energy_connection_finder.cc +++ b/components/proximity_auth/ble/bluetooth_low_energy_connection_finder.cc @@ -145,7 +145,6 @@ void BluetoothLowEnergyConnectionFinder::HandleDeviceUpdated( connection_->AddObserver(this); connection_->Connect(); - adapter_->RemoveObserver(this); StopDiscoverySession(); } } diff --git a/components/proximity_auth/ble/proximity_auth_ble_system.cc b/components/proximity_auth/ble/proximity_auth_ble_system.cc index 7d12468..9b55912 100644 --- a/components/proximity_auth/ble/proximity_auth_ble_system.cc +++ b/components/proximity_auth/ble/proximity_auth_ble_system.cc @@ -24,6 +24,7 @@ #include "components/proximity_auth/logging/logging.h" #include "components/proximity_auth/proximity_auth_client.h" #include "components/proximity_auth/remote_device.h" +#include "components/proximity_auth/wire_message.h" #include "device/bluetooth/bluetooth_device.h" #include "device/bluetooth/bluetooth_gatt_connection.h" @@ -242,8 +243,8 @@ void ProximityAuthBleSystem::OnFocusedUserChanged(const std::string& user_id) { void ProximityAuthBleSystem::OnMessageReceived(const Connection& connection, const WireMessage& message) { - // TODO(sacomoto): change this when WireMessage is fully implemented. - PA_LOG(INFO) << "Message received: " << message.payload(); + PA_LOG(INFO) << "Message with " << message.payload().size() + << " bytes received."; // The first message should contain a public key registered in |unlock_keys_| // to authenticate the device. @@ -343,7 +344,7 @@ void ProximityAuthBleSystem::StartPollingScreenState() { } // Sends message requesting screen state. connection_->SendMessage( - make_scoped_ptr(new FakeWireMessage(kPollScreenState))); + make_scoped_ptr(new WireMessage(kPollScreenState))); // Schedules the next message in |kPollingIntervalSeconds| s. base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( diff --git a/components/proximity_auth/connection.h b/components/proximity_auth/connection.h index cbaf3a5..a79ce188 100644 --- a/components/proximity_auth/connection.h +++ b/components/proximity_auth/connection.h @@ -86,12 +86,6 @@ class Connection { virtual scoped_ptr<WireMessage> DeserializeWireMessage( bool* is_incomplete_message); - // Exposed so it is possible to override DeserializeWireMessage in - // BluetoothLowEnergyConnection class, while mantaining the same - // functionality. - // TODO(sacomoto): remove this when FakeWireMessage is not needed anymore. - const std::string& received_bytes() { return received_bytes_; } - private: // The remote device corresponding to this connection. const RemoteDevice remote_device_; |