OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "device/bluetooth/bluetooth_device_win.h" | 5 #include "device/bluetooth/bluetooth_device_win.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/containers/scoped_ptr_hash_map.h" | 9 #include "base/containers/scoped_ptr_hash_map.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 service_state) { | 343 service_state) { |
344 // First, remove no longer exist GATT service. | 344 // First, remove no longer exist GATT service. |
345 { | 345 { |
346 std::vector<std::string> to_be_removed_services; | 346 std::vector<std::string> to_be_removed_services; |
347 for (const auto& gatt_service : gatt_services_) { | 347 for (const auto& gatt_service : gatt_services_) { |
348 if (!DoesGattServiceExist(service_state, gatt_service.second)) { | 348 if (!DoesGattServiceExist(service_state, gatt_service.second)) { |
349 to_be_removed_services.push_back(gatt_service.first); | 349 to_be_removed_services.push_back(gatt_service.first); |
350 } | 350 } |
351 } | 351 } |
352 for (const auto& service : to_be_removed_services) { | 352 for (const auto& service : to_be_removed_services) { |
353 gatt_services_.erase(service); | 353 gatt_services_.take_and_erase(service); |
354 } | 354 } |
355 // Update previously discovered services. | 355 // Update previously discovered services. |
356 for (auto gatt_service : gatt_services_) { | 356 for (auto gatt_service : gatt_services_) { |
357 static_cast<BluetoothRemoteGattServiceWin*>(gatt_service.second) | 357 static_cast<BluetoothRemoteGattServiceWin*>(gatt_service.second) |
358 ->Update(); | 358 ->Update(); |
359 } | 359 } |
360 } | 360 } |
361 | 361 |
362 // Return if no new services have been added. | 362 // Return if no new services have been added. |
363 if (gatt_services_.size() == service_state.size()) | 363 if (gatt_services_.size() == service_state.size()) |
(...skipping 11 matching lines...) Expand all Loading... |
375 gatt_services_.add(primary_service->GetIdentifier(), | 375 gatt_services_.add(primary_service->GetIdentifier(), |
376 scoped_ptr<BluetoothGattService>(primary_service)); | 376 scoped_ptr<BluetoothGattService>(primary_service)); |
377 adapter_->NotifyGattServiceAdded(primary_service); | 377 adapter_->NotifyGattServiceAdded(primary_service); |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
381 adapter_->NotifyGattServicesDiscovered(this); | 381 adapter_->NotifyGattServicesDiscovered(this); |
382 } | 382 } |
383 | 383 |
384 } // namespace device | 384 } // namespace device |
OLD | NEW |