Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: components/cryptauth/ble/bluetooth_low_energy_weave_packet_generator.cc

Issue 2844773002: [ProximityAuth] Remote static initializers from uWeave classes. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_packet_generator.h " 5 #include "components/cryptauth/ble/bluetooth_low_energy_weave_packet_generator.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 <string.h> 13 #include <string.h>
14 14
15 #include <algorithm> 15 #include <algorithm>
16 16
17 #include "base/logging.h" 17 #include "base/logging.h"
18 18
19 namespace cryptauth { 19 namespace cryptauth {
20 namespace weave { 20 namespace weave {
21 21
22 // static. 22 // static.
23 std::shared_ptr<BluetoothLowEnergyWeavePacketGenerator::Factory> 23 BluetoothLowEnergyWeavePacketGenerator::Factory*
24 BluetoothLowEnergyWeavePacketGenerator::Factory::factory_instance_ = 24 BluetoothLowEnergyWeavePacketGenerator::Factory::factory_instance_ =
25 nullptr; 25 nullptr;
26 26
27 // static. 27 // static.
28 std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator> 28 std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator>
29 BluetoothLowEnergyWeavePacketGenerator::Factory::NewInstance() { 29 BluetoothLowEnergyWeavePacketGenerator::Factory::NewInstance() {
30 if (!factory_instance_) { 30 if (!factory_instance_) {
31 factory_instance_.reset(new Factory()); 31 factory_instance_ = new Factory();
32 } 32 }
33 return factory_instance_->BuildInstance(); 33 return factory_instance_->BuildInstance();
34 } 34 }
35 35
36 // static. 36 // static.
37 void BluetoothLowEnergyWeavePacketGenerator::Factory::SetInstanceForTesting( 37 void BluetoothLowEnergyWeavePacketGenerator::Factory::SetInstanceForTesting(
38 std::shared_ptr<Factory> factory) { 38 Factory* factory) {
39 factory_instance_ = factory; 39 factory_instance_ = factory;
40 } 40 }
41 41
42 std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator> 42 std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator>
43 BluetoothLowEnergyWeavePacketGenerator::Factory::BuildInstance() { 43 BluetoothLowEnergyWeavePacketGenerator::Factory::BuildInstance() {
44 return std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator>( 44 return std::unique_ptr<BluetoothLowEnergyWeavePacketGenerator>(
45 new BluetoothLowEnergyWeavePacketGenerator()); 45 new BluetoothLowEnergyWeavePacketGenerator());
46 } 46 }
47 47
48 BluetoothLowEnergyWeavePacketGenerator::BluetoothLowEnergyWeavePacketGenerator() 48 BluetoothLowEnergyWeavePacketGenerator::BluetoothLowEnergyWeavePacketGenerator()
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 DCHECK(packet); 192 DCHECK(packet);
193 DCHECK(!packet->empty()); 193 DCHECK(!packet->empty());
194 194
195 // Last bit is the bit 2 of the packet's first byte and set it to 1. 195 // Last bit is the bit 2 of the packet's first byte and set it to 1.
196 packet->at(0) = packet->at(0) | (1 << 2); 196 packet->at(0) = packet->at(0) | (1 << 2);
197 } 197 }
198 198
199 } // namespace weave 199 } // namespace weave
200 200
201 } // namespace cryptauth 201 } // namespace cryptauth
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698