Chromium Code Reviews| Index: device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.cc |
| diff --git a/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.cc b/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..476f5a57052d7787a64b9d2e2b0308f8e51cb716 |
| --- /dev/null |
| +++ b/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.cc |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/memory/ptr_util.h" |
| + |
| +namespace bluez { |
| + |
| +BluetoothServiceAttributeValueBlueZ::BluetoothServiceAttributeValueBlueZ( |
| + Type type, |
| + size_t size, |
| + std::unique_ptr<base::Value> value) |
| + : 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.
|
| + CHECK_NE(type, SEQUENCE); |
| +} |
| + |
| +BluetoothServiceAttributeValueBlueZ::BluetoothServiceAttributeValueBlueZ( |
| + std::unique_ptr<Sequence> sequence) |
| + : type_(SEQUENCE), |
| + size_(sequence->size()), |
| + value_(nullptr), |
| + sequence_(std::move(sequence)) {} |
| + |
| +BluetoothServiceAttributeValueBlueZ::BluetoothServiceAttributeValueBlueZ( |
| + const BluetoothServiceAttributeValueBlueZ& attribute) { |
| + this->type_ = attribute.type_; |
| + this->size_ = attribute.size_; |
| + |
| + if (attribute.type_ != SEQUENCE) { |
| + this->value_ = base::WrapUnique(attribute.value_->DeepCopy()); |
| + return; |
| + } |
| + |
| + this->sequence_ = |
| + base::WrapUnique(new std::vector<BluetoothServiceAttributeValueBlueZ>( |
| + *attribute.sequence_)); |
| +} |
| + |
| +BluetoothServiceAttributeValueBlueZ::~BluetoothServiceAttributeValueBlueZ() {} |
| + |
| +} // namespace bluez |