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/proximity_auth/ble/bluetooth_low_energy_weave_packet_receiv
er.h" | 5 #include "components/proximity_auth/ble/bluetooth_low_energy_weave_packet_receiv
er.h" |
6 | 6 |
7 #ifdef OS_WIN | 7 #ifdef OS_WIN |
8 #include <winsock2.h> | 8 #include <winsock2.h> |
9 #else | 9 #else |
10 #include <netinet/in.h> | 10 #include <netinet/in.h> |
11 #endif | 11 #endif |
12 | 12 |
13 #include "components/proximity_auth/logging/logging.h" | 13 #include "components/proximity_auth/logging/logging.h" |
14 | 14 |
15 namespace proximity_auth { | 15 namespace proximity_auth { |
16 namespace weave { | 16 namespace weave { |
17 namespace { | 17 namespace { |
18 | 18 |
19 const uint16_t kMaxInitControlPacketSize = 20; | 19 const uint16_t kMaxInitControlPacketSize = 20; |
20 const uint16_t kMaxPacketSizeLowerBound = 20; | 20 const uint16_t kMaxPacketSizeLowerBound = 20; |
21 | 21 |
22 } // namespace | 22 } // namespace |
23 | 23 |
24 BluetoothLowEnergyWeavePacketReceiver::Factory* | 24 std::shared_ptr<BluetoothLowEnergyWeavePacketReceiver::Factory> |
25 BluetoothLowEnergyWeavePacketReceiver::Factory::factory_instance_ = nullptr; | 25 BluetoothLowEnergyWeavePacketReceiver::Factory::factory_instance_ = nullptr; |
26 | 26 |
27 // static | 27 // static |
28 std::unique_ptr<BluetoothLowEnergyWeavePacketReceiver> | 28 std::unique_ptr<BluetoothLowEnergyWeavePacketReceiver> |
29 BluetoothLowEnergyWeavePacketReceiver::Factory::NewInstance( | 29 BluetoothLowEnergyWeavePacketReceiver::Factory::NewInstance( |
30 ReceiverType receiver_type) { | 30 ReceiverType receiver_type) { |
31 if (factory_instance_ == nullptr) { | 31 if (!factory_instance_) { |
32 factory_instance_ = new Factory(); | 32 factory_instance_.reset(new Factory()); |
33 } | 33 } |
34 return factory_instance_->BuildInstance(receiver_type); | 34 return factory_instance_->BuildInstance(receiver_type); |
35 } | 35 } |
36 | 36 |
37 // static | 37 // static |
38 void BluetoothLowEnergyWeavePacketReceiver::Factory::SetInstanceForTesting( | 38 void BluetoothLowEnergyWeavePacketReceiver::Factory::SetInstanceForTesting( |
39 Factory* factory) { | 39 std::shared_ptr<Factory> factory) { |
40 factory_instance_ = factory; | 40 factory_instance_ = factory; |
41 } | 41 } |
42 | 42 |
43 std::unique_ptr<BluetoothLowEnergyWeavePacketReceiver> | 43 std::unique_ptr<BluetoothLowEnergyWeavePacketReceiver> |
44 BluetoothLowEnergyWeavePacketReceiver::Factory::BuildInstance( | 44 BluetoothLowEnergyWeavePacketReceiver::Factory::BuildInstance( |
45 ReceiverType receiver_type) { | 45 ReceiverType receiver_type) { |
46 return std::unique_ptr<BluetoothLowEnergyWeavePacketReceiver>( | 46 return std::unique_ptr<BluetoothLowEnergyWeavePacketReceiver>( |
47 new BluetoothLowEnergyWeavePacketReceiver(receiver_type)); | 47 new BluetoothLowEnergyWeavePacketReceiver(receiver_type)); |
48 } | 48 } |
49 | 49 |
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 442 |
443 uint16_t BluetoothLowEnergyWeavePacketReceiver::GetConceptualMaxPacketSize() { | 443 uint16_t BluetoothLowEnergyWeavePacketReceiver::GetConceptualMaxPacketSize() { |
444 if (!max_packet_size_) | 444 if (!max_packet_size_) |
445 return kMaxPacketSizeLowerBound; | 445 return kMaxPacketSizeLowerBound; |
446 return max_packet_size_; | 446 return max_packet_size_; |
447 } | 447 } |
448 | 448 |
449 } // namespace weave | 449 } // namespace weave |
450 | 450 |
451 } // namespace proximity_auth | 451 } // namespace proximity_auth |
OLD | NEW |