OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "base/memory/ptr_util.h" | |
9 | |
10 namespace bluez { | |
11 | |
12 BluetoothServiceAttributeValueBlueZ::BluetoothServiceAttributeValueBlueZ( | |
13 Type type, | |
14 size_t size, | |
15 std::unique_ptr<base::Value> value) | |
16 : type_(type), size_(size), value_(std::move(value)), sequence_(nullptr) { | |
xiyuan
2016/06/22 21:28:44
nit: nullptr for unique_ptr init is not necessary
rkc
2016/06/23 19:55:43
Done.
| |
17 CHECK_NE(type, SEQUENCE); | |
18 } | |
19 | |
20 BluetoothServiceAttributeValueBlueZ::BluetoothServiceAttributeValueBlueZ( | |
21 std::unique_ptr<Sequence> sequence) | |
22 : type_(SEQUENCE), | |
23 size_(sequence->size()), | |
24 value_(nullptr), | |
25 sequence_(std::move(sequence)) {} | |
26 | |
27 BluetoothServiceAttributeValueBlueZ::BluetoothServiceAttributeValueBlueZ( | |
28 const BluetoothServiceAttributeValueBlueZ& attribute) { | |
29 this->type_ = attribute.type_; | |
30 this->size_ = attribute.size_; | |
31 | |
32 if (attribute.type_ != SEQUENCE) { | |
33 this->value_ = base::WrapUnique(attribute.value_->DeepCopy()); | |
34 return; | |
35 } | |
36 | |
37 this->sequence_ = | |
38 base::WrapUnique(new std::vector<BluetoothServiceAttributeValueBlueZ>( | |
39 *attribute.sequence_)); | |
40 } | |
41 | |
42 BluetoothServiceAttributeValueBlueZ::~BluetoothServiceAttributeValueBlueZ() {} | |
43 | |
44 } // namespace bluez | |
OLD | NEW |