| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.
h" | 5 #include "components/cryptauth/ble/bluetooth_low_energy_weave_client_connection.
h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 // The UUID of the RX characteristic used to receive data from the server. | 31 // The UUID of the RX characteristic used to receive data from the server. |
| 32 const char kRXCharacteristicUUID[] = "00000100-0004-1000-8000-001A11000102"; | 32 const char kRXCharacteristicUUID[] = "00000100-0004-1000-8000-001A11000102"; |
| 33 | 33 |
| 34 // If sending a message fails, retry up to 2 additional times. This means that | 34 // If sending a message fails, retry up to 2 additional times. This means that |
| 35 // each message gets 3 attempts: the first one, and 2 retries. | 35 // each message gets 3 attempts: the first one, and 2 retries. |
| 36 const int kMaxNumberOfRetryAttempts = 2; | 36 const int kMaxNumberOfRetryAttempts = 2; |
| 37 | 37 |
| 38 } // namespace | 38 } // namespace |
| 39 | 39 |
| 40 // static | 40 // static |
| 41 std::shared_ptr<BluetoothLowEnergyWeaveClientConnection::Factory> | 41 BluetoothLowEnergyWeaveClientConnection::Factory* |
| 42 BluetoothLowEnergyWeaveClientConnection::Factory::factory_instance_ = | 42 BluetoothLowEnergyWeaveClientConnection::Factory::factory_instance_ = |
| 43 nullptr; | 43 nullptr; |
| 44 | 44 |
| 45 // static | 45 // static |
| 46 std::unique_ptr<Connection> | 46 std::unique_ptr<Connection> |
| 47 BluetoothLowEnergyWeaveClientConnection::Factory::NewInstance( | 47 BluetoothLowEnergyWeaveClientConnection::Factory::NewInstance( |
| 48 const RemoteDevice& remote_device, | 48 const RemoteDevice& remote_device, |
| 49 const std::string& device_address, | 49 const std::string& device_address, |
| 50 scoped_refptr<device::BluetoothAdapter> adapter, | 50 scoped_refptr<device::BluetoothAdapter> adapter, |
| 51 const device::BluetoothUUID remote_service_uuid, | 51 const device::BluetoothUUID remote_service_uuid, |
| 52 BluetoothThrottler* bluetooth_throttler) { | 52 BluetoothThrottler* bluetooth_throttler) { |
| 53 if (!factory_instance_) { | 53 if (!factory_instance_) { |
| 54 factory_instance_.reset(new Factory()); | 54 factory_instance_ = new Factory(); |
| 55 } | 55 } |
| 56 return factory_instance_->BuildInstance( | 56 return factory_instance_->BuildInstance( |
| 57 remote_device, | 57 remote_device, |
| 58 device_address, | 58 device_address, |
| 59 adapter, | 59 adapter, |
| 60 remote_service_uuid, | 60 remote_service_uuid, |
| 61 bluetooth_throttler); | 61 bluetooth_throttler); |
| 62 } | 62 } |
| 63 | 63 |
| 64 // static | 64 // static |
| 65 void BluetoothLowEnergyWeaveClientConnection::Factory::SetInstanceForTesting( | 65 void BluetoothLowEnergyWeaveClientConnection::Factory::SetInstanceForTesting( |
| 66 std::shared_ptr<Factory> factory) { | 66 Factory* factory) { |
| 67 factory_instance_ = factory; | 67 factory_instance_ = factory; |
| 68 } | 68 } |
| 69 | 69 |
| 70 std::unique_ptr<Connection> | 70 std::unique_ptr<Connection> |
| 71 BluetoothLowEnergyWeaveClientConnection::Factory::BuildInstance( | 71 BluetoothLowEnergyWeaveClientConnection::Factory::BuildInstance( |
| 72 const RemoteDevice& remote_device, | 72 const RemoteDevice& remote_device, |
| 73 const std::string& device_address, | 73 const std::string& device_address, |
| 74 scoped_refptr<device::BluetoothAdapter> adapter, | 74 scoped_refptr<device::BluetoothAdapter> adapter, |
| 75 const device::BluetoothUUID remote_service_uuid, | 75 const device::BluetoothUUID remote_service_uuid, |
| 76 BluetoothThrottler* bluetooth_throttler) { | 76 BluetoothThrottler* bluetooth_throttler) { |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 number_of_failed_attempts(0) {} | 666 number_of_failed_attempts(0) {} |
| 667 | 667 |
| 668 BluetoothLowEnergyWeaveClientConnection::WriteRequest::WriteRequest( | 668 BluetoothLowEnergyWeaveClientConnection::WriteRequest::WriteRequest( |
| 669 const WriteRequest& other) = default; | 669 const WriteRequest& other) = default; |
| 670 | 670 |
| 671 BluetoothLowEnergyWeaveClientConnection::WriteRequest::~WriteRequest() {} | 671 BluetoothLowEnergyWeaveClientConnection::WriteRequest::~WriteRequest() {} |
| 672 | 672 |
| 673 } // namespace weave | 673 } // namespace weave |
| 674 | 674 |
| 675 } // namespace cryptauth | 675 } // namespace cryptauth |
| OLD | NEW |