| 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 #ifndef COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_WEAVE_PACKET_GENERATO
R_H_ | 5 #ifndef COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_WEAVE_PACKET_GENERATO
R_H_ |
| 6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_WEAVE_PACKET_GENERATO
R_H_ | 6 #define COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_WEAVE_PACKET_GENERATO
R_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "components/proximity_auth/ble/bluetooth_low_energy_weave_defines.h" | 15 #include "components/proximity_auth/ble/bluetooth_low_energy_weave_defines.h" |
| 16 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 17 | 17 |
| 18 namespace proximity_auth { | 18 namespace proximity_auth { |
| 19 namespace weave { | 19 namespace weave { |
| 20 | 20 |
| 21 // Generates the messages sent using the uWeave protocol. | 21 // Generates the messages sent using the uWeave protocol. |
| 22 class BluetoothLowEnergyWeavePacketGenerator { | 22 class BluetoothLowEnergyWeavePacketGenerator { |
| 23 public: | 23 public: |
| 24 class Factory { | 24 class Factory { |
| 25 public: | 25 public: |
| 26 static std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator> | 26 static std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator> |
| 27 NewInstance(); | 27 NewInstance(); |
| 28 | 28 |
| 29 // Exposed for testing. | 29 // Exposed for testing. |
| 30 static void SetInstanceForTesting(Factory* factory); | 30 static void SetInstanceForTesting(std::shared_ptr<Factory> factory); |
| 31 | 31 |
| 32 protected: | 32 protected: |
| 33 // Exposed for testing. | 33 // Exposed for testing. |
| 34 virtual std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator> | 34 virtual std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator> |
| 35 BuildInstance(); | 35 BuildInstance(); |
| 36 | 36 |
| 37 private: | 37 private: |
| 38 static Factory* factory_instance_; | 38 static std::shared_ptr<Factory> factory_instance_; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 virtual Packet CreateConnectionRequest(); | 41 virtual Packet CreateConnectionRequest(); |
| 42 virtual Packet CreateConnectionResponse(); | 42 virtual Packet CreateConnectionResponse(); |
| 43 virtual Packet CreateConnectionClose(ReasonForClose reason_for_close); | 43 virtual Packet CreateConnectionClose(ReasonForClose reason_for_close); |
| 44 | 44 |
| 45 // Packet size must be greater than or equal to 20. | 45 // Packet size must be greater than or equal to 20. |
| 46 virtual void SetMaxPacketSize(uint16_t size); | 46 virtual void SetMaxPacketSize(uint16_t size); |
| 47 | 47 |
| 48 // Will crash if message is empty. | 48 // Will crash if message is empty. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 65 | 65 |
| 66 // Counter for the number of packets sent, starting at 0. | 66 // Counter for the number of packets sent, starting at 0. |
| 67 uint8_t next_packet_counter_; | 67 uint8_t next_packet_counter_; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 } // namespace weave | 70 } // namespace weave |
| 71 | 71 |
| 72 } // namespace proximity_auth | 72 } // namespace proximity_auth |
| 73 | 73 |
| 74 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_WEAVE_PACKET_GENER
ATOR_H_ | 74 #endif // COMPONENTS_PROXIMITY_AUTH_BLE_BLUETOOTH_LOW_ENERGY_WEAVE_PACKET_GENER
ATOR_H_ |
| OLD | NEW |