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 |
index e9d61a825018e8574970a589efaeb2b9759f2549..ee6cbf611248c0dea5bb3a1306c14bdc4b70f1c2 100644 |
--- a/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.cc |
+++ b/device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.cc |
@@ -12,7 +12,7 @@ |
namespace bluez { |
BluetoothServiceAttributeValueBlueZ::BluetoothServiceAttributeValueBlueZ() |
- : type_(NULLTYPE), size_(0) {} |
+ : type_(NULLTYPE), size_(0), value_(base::Value::CreateNullValue()) {} |
BluetoothServiceAttributeValueBlueZ::BluetoothServiceAttributeValueBlueZ( |
Type type, |
@@ -30,25 +30,23 @@ BluetoothServiceAttributeValueBlueZ::BluetoothServiceAttributeValueBlueZ( |
BluetoothServiceAttributeValueBlueZ::BluetoothServiceAttributeValueBlueZ( |
const BluetoothServiceAttributeValueBlueZ& attribute) { |
- this->type_ = attribute.type_; |
- this->size_ = attribute.size_; |
- |
- if (attribute.type_ == NULLTYPE) { |
- this->value_ = base::Value::CreateNullValue(); |
- return; |
- } |
- |
- if (attribute.type_ != SEQUENCE) { |
- this->value_ = base::WrapUnique(attribute.value_->DeepCopy()); |
- return; |
- } |
- |
- this->sequence_ = base::MakeUnique<Sequence>(*attribute.sequence_); |
+ *this = attribute; |
} |
-BluetoothServiceAttributeValueBlueZ BluetoothServiceAttributeValueBlueZ:: |
+BluetoothServiceAttributeValueBlueZ& BluetoothServiceAttributeValueBlueZ:: |
operator=(const BluetoothServiceAttributeValueBlueZ& attribute) { |
- return BluetoothServiceAttributeValueBlueZ(attribute); |
+ if (this != &attribute) { |
+ type_ = attribute.type_; |
+ size_ = attribute.size_; |
+ if (attribute.type_ == SEQUENCE) { |
+ value_ = nullptr; |
+ sequence_ = base::MakeUnique<Sequence>(*attribute.sequence_); |
+ } else { |
+ value_ = attribute.value_->CreateDeepCopy(); |
+ sequence_ = nullptr; |
+ } |
+ } |
+ return *this; |
} |
BluetoothServiceAttributeValueBlueZ::~BluetoothServiceAttributeValueBlueZ() {} |