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

Unified Diff: device/bluetooth/bluetooth_device.cc

Issue 2567903004: Replace ScopedVector/ScopedPtrHashMap with std::vector and std::unordered_map (Closed)
Patch Set: Mac bustage Created 4 years 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/bluetooth_device.cc
diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc
index d4e072bbc4b4b3a404de2931ea3d6bff6b4e2d18..9da1d6565a53033e8cddfcb87e5b207b9b7d5565 100644
--- a/device/bluetooth/bluetooth_device.cc
+++ b/device/bluetooth/bluetooth_device.cc
@@ -69,12 +69,15 @@ void BluetoothDevice::DeviceUUIDs::UpdateDeviceUUIDs() {
BluetoothDevice::BluetoothDevice(BluetoothAdapter* adapter)
: adapter_(adapter),
gatt_services_discovery_complete_(false),
+ gatt_services_shutting_down_(false),
last_update_time_(base::Time()) {}
BluetoothDevice::~BluetoothDevice() {
for (BluetoothGattConnection* connection : gatt_connections_) {
connection->InvalidateConnectionReference();
}
+ gatt_services_shutting_down_ = true;
+ gatt_services_.clear();
}
BluetoothDevice::ConnectionInfo::ConnectionInfo()
@@ -370,14 +373,21 @@ bool BluetoothDevice::IsGattServicesDiscoveryComplete() const {
std::vector<BluetoothRemoteGattService*> BluetoothDevice::GetGattServices()
const {
std::vector<BluetoothRemoteGattService*> services;
+ if (gatt_services_shutting_down_)
+ return services;
for (const auto& iter : gatt_services_)
- services.push_back(iter.second);
+ services.push_back(iter.second.get());
return services;
}
BluetoothRemoteGattService* BluetoothDevice::GetGattService(
const std::string& identifier) const {
- return gatt_services_.get(identifier);
+ if (gatt_services_shutting_down_)
+ return nullptr;
+ auto it = gatt_services_.find(identifier);
+ if (it == gatt_services_.end())
+ return nullptr;
+ return it->second.get();
}
// static

Powered by Google App Engine
This is Rietveld 408576698