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

Side by Side Diff: device/bluetooth/bluetooth_device.cc

Issue 2606823002: Remove base::ScopedPtrHashMap from device/. (Closed)
Patch Set: one last fix Created 3 years, 11 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 (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.h" 5 #include "device/bluetooth/bluetooth_device.h"
6 6
7 #include <iterator> 7 #include <iterator>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/stl_util.h"
13 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
14 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
15 #include "base/time/time.h" 14 #include "base/time/time.h"
16 #include "base/values.h" 15 #include "base/values.h"
17 #include "device/bluetooth/bluetooth_adapter.h" 16 #include "device/bluetooth/bluetooth_adapter.h"
18 #include "device/bluetooth/bluetooth_gatt_connection.h" 17 #include "device/bluetooth/bluetooth_gatt_connection.h"
19 #include "device/bluetooth/bluetooth_remote_gatt_service.h" 18 #include "device/bluetooth/bluetooth_remote_gatt_service.h"
20 #include "device/bluetooth/string_util_icu.h" 19 #include "device/bluetooth/string_util_icu.h"
21 #include "grit/bluetooth_strings.h" 20 #include "grit/bluetooth_strings.h"
22 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
23 22
24 namespace device { 23 namespace device {
25 24
26 BluetoothDevice::DeviceUUIDs::DeviceUUIDs() {} 25 BluetoothDevice::DeviceUUIDs::DeviceUUIDs() = default;
27 26
28 BluetoothDevice::DeviceUUIDs::~DeviceUUIDs() {} 27 BluetoothDevice::DeviceUUIDs::~DeviceUUIDs() = default;
28
29 BluetoothDevice::DeviceUUIDs::DeviceUUIDs(const DeviceUUIDs& other) = default;
30
31 BluetoothDevice::DeviceUUIDs& BluetoothDevice::DeviceUUIDs::operator=(
32 const DeviceUUIDs& other) = default;
29 33
30 void BluetoothDevice::DeviceUUIDs::ReplaceAdvertisedUUIDs( 34 void BluetoothDevice::DeviceUUIDs::ReplaceAdvertisedUUIDs(
31 UUIDList new_advertised_uuids) { 35 UUIDList new_advertised_uuids) {
32 advertised_uuids_.clear(); 36 advertised_uuids_.clear();
33 for (auto& it : new_advertised_uuids) { 37 for (auto& it : new_advertised_uuids) {
34 advertised_uuids_.insert(std::move(it)); 38 advertised_uuids_.insert(std::move(it));
35 } 39 }
36 UpdateDeviceUUIDs(); 40 UpdateDeviceUUIDs();
37 } 41 }
38 42
39 void BluetoothDevice::DeviceUUIDs::ClearAdvertisedUUIDs() { 43 void BluetoothDevice::DeviceUUIDs::ClearAdvertisedUUIDs() {
40 advertised_uuids_.clear(); 44 advertised_uuids_.clear();
41 UpdateDeviceUUIDs(); 45 UpdateDeviceUUIDs();
42 } 46 }
43 47
44 void BluetoothDevice::DeviceUUIDs::ReplaceServiceUUIDs( 48 void BluetoothDevice::DeviceUUIDs::ReplaceServiceUUIDs(
45 const GattServiceMap& gatt_services) { 49 const GattServiceMap& gatt_services) {
46 service_uuids_.clear(); 50 service_uuids_.clear();
47 for (const auto& gatt_service_pair : gatt_services) { 51 for (const auto& gatt_service_pair : gatt_services)
48 service_uuids_.insert(gatt_service_pair.second->GetUUID()); 52 service_uuids_.insert(gatt_service_pair.second->GetUUID());
49 }
50 UpdateDeviceUUIDs(); 53 UpdateDeviceUUIDs();
51 } 54 }
52 55
53 void BluetoothDevice::DeviceUUIDs::ClearServiceUUIDs() { 56 void BluetoothDevice::DeviceUUIDs::ClearServiceUUIDs() {
54 service_uuids_.clear(); 57 service_uuids_.clear();
55 UpdateDeviceUUIDs(); 58 UpdateDeviceUUIDs();
56 } 59 }
57 60
58 const BluetoothDevice::UUIDSet& BluetoothDevice::DeviceUUIDs::GetUUIDs() const { 61 const BluetoothDevice::UUIDSet& BluetoothDevice::DeviceUUIDs::GetUUIDs() const {
59 return device_uuids_; 62 return device_uuids_;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 } 367 }
365 368
366 bool BluetoothDevice::IsGattServicesDiscoveryComplete() const { 369 bool BluetoothDevice::IsGattServicesDiscoveryComplete() const {
367 return gatt_services_discovery_complete_; 370 return gatt_services_discovery_complete_;
368 } 371 }
369 372
370 std::vector<BluetoothRemoteGattService*> BluetoothDevice::GetGattServices() 373 std::vector<BluetoothRemoteGattService*> BluetoothDevice::GetGattServices()
371 const { 374 const {
372 std::vector<BluetoothRemoteGattService*> services; 375 std::vector<BluetoothRemoteGattService*> services;
373 for (const auto& iter : gatt_services_) 376 for (const auto& iter : gatt_services_)
374 services.push_back(iter.second); 377 services.push_back(iter.second.get());
375 return services; 378 return services;
376 } 379 }
377 380
378 BluetoothRemoteGattService* BluetoothDevice::GetGattService( 381 BluetoothRemoteGattService* BluetoothDevice::GetGattService(
379 const std::string& identifier) const { 382 const std::string& identifier) const {
380 return gatt_services_.get(identifier); 383 auto it = gatt_services_.find(identifier);
384 if (it == gatt_services_.end())
385 return nullptr;
386 return it->second.get();
381 } 387 }
382 388
383 // static 389 // static
384 std::string BluetoothDevice::CanonicalizeAddress(const std::string& address) { 390 std::string BluetoothDevice::CanonicalizeAddress(const std::string& address) {
385 std::string canonicalized = address; 391 std::string canonicalized = address;
386 if (address.size() == 12) { 392 if (address.size() == 12) {
387 // Might be an address in the format "1A2B3C4D5E6F". Add separators. 393 // Might be an address in the format "1A2B3C4D5E6F". Add separators.
388 for (size_t i = 2; i < canonicalized.size(); i += 3) { 394 for (size_t i = 2; i < canonicalized.size(); i += 3) {
389 canonicalized.insert(i, ":"); 395 canonicalized.insert(i, ":");
390 } 396 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 if (power < INT8_MIN) { 521 if (power < INT8_MIN) {
516 return INT8_MIN; 522 return INT8_MIN;
517 } 523 }
518 if (power > INT8_MAX) { 524 if (power > INT8_MAX) {
519 return INT8_MAX; 525 return INT8_MAX;
520 } 526 }
521 return static_cast<int8_t>(power); 527 return static_cast<int8_t>(power);
522 } 528 }
523 529
524 } // namespace device 530 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698