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

Side by Side Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_event_router.cc

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_event_router.h" 5 #include "chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energ y_event_router.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1057 chrc_id_to_service_id_.end()); 1057 chrc_id_to_service_id_.end());
1058 DCHECK(chrc_id_to_service_id_[characteristic->GetIdentifier()] == 1058 DCHECK(chrc_id_to_service_id_[characteristic->GetIdentifier()] ==
1059 service->GetIdentifier()); 1059 service->GetIdentifier());
1060 1060
1061 // Send the event; manually construct the arguments, instead of using 1061 // Send the event; manually construct the arguments, instead of using
1062 // apibtle::OnCharacteristicValueChanged::Create, as it doesn't convert 1062 // apibtle::OnCharacteristicValueChanged::Create, as it doesn't convert
1063 // lists of enums correctly. 1063 // lists of enums correctly.
1064 apibtle::Characteristic api_characteristic; 1064 apibtle::Characteristic api_characteristic;
1065 PopulateCharacteristic(characteristic, &api_characteristic); 1065 PopulateCharacteristic(characteristic, &api_characteristic);
1066 std::unique_ptr<base::ListValue> args(new base::ListValue()); 1066 std::unique_ptr<base::ListValue> args(new base::ListValue());
1067 args->Append(apibtle::CharacteristicToValue(&api_characteristic).release()); 1067 args->Append(apibtle::CharacteristicToValue(&api_characteristic));
1068 1068
1069 DispatchEventToExtensionsWithPermission( 1069 DispatchEventToExtensionsWithPermission(
1070 events::BLUETOOTH_LOW_ENERGY_ON_CHARACTERISTIC_VALUE_CHANGED, 1070 events::BLUETOOTH_LOW_ENERGY_ON_CHARACTERISTIC_VALUE_CHANGED,
1071 apibtle::OnCharacteristicValueChanged::kEventName, service->GetUUID(), 1071 apibtle::OnCharacteristicValueChanged::kEventName, service->GetUUID(),
1072 characteristic->GetIdentifier(), std::move(args)); 1072 characteristic->GetIdentifier(), std::move(args));
1073 } 1073 }
1074 1074
1075 void BluetoothLowEnergyEventRouter::GattDescriptorValueChanged( 1075 void BluetoothLowEnergyEventRouter::GattDescriptorValueChanged(
1076 BluetoothAdapter* adapter, 1076 BluetoothAdapter* adapter,
1077 BluetoothRemoteGattDescriptor* descriptor, 1077 BluetoothRemoteGattDescriptor* descriptor,
(...skipping 10 matching lines...) Expand all
1088 desc_id_to_chrc_id_.end()); 1088 desc_id_to_chrc_id_.end());
1089 DCHECK(characteristic->GetIdentifier() == 1089 DCHECK(characteristic->GetIdentifier() ==
1090 desc_id_to_chrc_id_[descriptor->GetIdentifier()]); 1090 desc_id_to_chrc_id_[descriptor->GetIdentifier()]);
1091 1091
1092 // Send the event; manually construct the arguments, instead of using 1092 // Send the event; manually construct the arguments, instead of using
1093 // apibtle::OnDescriptorValueChanged::Create, as it doesn't convert 1093 // apibtle::OnDescriptorValueChanged::Create, as it doesn't convert
1094 // lists of enums correctly. 1094 // lists of enums correctly.
1095 apibtle::Descriptor api_descriptor; 1095 apibtle::Descriptor api_descriptor;
1096 PopulateDescriptor(descriptor, &api_descriptor); 1096 PopulateDescriptor(descriptor, &api_descriptor);
1097 std::unique_ptr<base::ListValue> args(new base::ListValue()); 1097 std::unique_ptr<base::ListValue> args(new base::ListValue());
1098 args->Append(apibtle::DescriptorToValue(&api_descriptor).release()); 1098 args->Append(apibtle::DescriptorToValue(&api_descriptor));
1099 1099
1100 DispatchEventToExtensionsWithPermission( 1100 DispatchEventToExtensionsWithPermission(
1101 events::BLUETOOTH_LOW_ENERGY_ON_DESCRIPTOR_VALUE_CHANGED, 1101 events::BLUETOOTH_LOW_ENERGY_ON_DESCRIPTOR_VALUE_CHANGED,
1102 apibtle::OnDescriptorValueChanged::kEventName, 1102 apibtle::OnDescriptorValueChanged::kEventName,
1103 characteristic->GetService()->GetUUID(), "" /* characteristic_id */, 1103 characteristic->GetService()->GetUUID(), "" /* characteristic_id */,
1104 std::move(args)); 1104 std::move(args));
1105 } 1105 }
1106 1106
1107 void BluetoothLowEnergyEventRouter::OnCharacteristicReadRequest( 1107 void BluetoothLowEnergyEventRouter::OnCharacteristicReadRequest(
1108 const device::BluetoothDevice* device, 1108 const device::BluetoothDevice* device,
(...skipping 811 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 requests_[extension_id] = std::move(new_request_id_map); 1920 requests_[extension_id] = std::move(new_request_id_map);
1921 } else { 1921 } else {
1922 request_id_map = iter->second.get(); 1922 request_id_map = iter->second.get();
1923 } 1923 }
1924 1924
1925 (*request_id_map)[++last_callback_request_id_] = std::move(request); 1925 (*request_id_map)[++last_callback_request_id_] = std::move(request);
1926 return last_callback_request_id_; 1926 return last_callback_request_id_;
1927 } 1927 }
1928 1928
1929 } // namespace extensions 1929 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698