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

Unified Diff: device/bluetooth/bluez/bluetooth_service_attribute_value_bluez.cc

Issue 2287023002: device/bluetooth: Fix = operator and copy constructor of BluetoothServiceAttributeValueBlueZ (Closed)
Patch Set: change bug number Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
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() {}

Powered by Google App Engine
This is Rietveld 408576698