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

Side by Side Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 2906883004: bluetooth: macOS: Removing useless |.get()| (Closed)
Patch Set: Created 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_adapter_mac.h" 5 #include "device/bluetooth/bluetooth_adapter_mac.h"
6 6
7 #import <IOBluetooth/objc/IOBluetoothDevice.h> 7 #import <IOBluetooth/objc/IOBluetoothDevice.h>
8 #import <IOBluetooth/objc/IOBluetoothHostController.h> 8 #import <IOBluetooth/objc/IOBluetoothHostController.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 BluetoothDiscoveryManagerMac::CreateClassic(this)), 93 BluetoothDiscoveryManagerMac::CreateClassic(this)),
94 weak_ptr_factory_(this) { 94 weak_ptr_factory_(this) {
95 if (IsLowEnergyAvailable()) { 95 if (IsLowEnergyAvailable()) {
96 low_energy_discovery_manager_.reset( 96 low_energy_discovery_manager_.reset(
97 BluetoothLowEnergyDiscoveryManagerMac::Create(this)); 97 BluetoothLowEnergyDiscoveryManagerMac::Create(this));
98 low_energy_central_manager_delegate_.reset( 98 low_energy_central_manager_delegate_.reset(
99 [[BluetoothLowEnergyCentralManagerDelegate alloc] 99 [[BluetoothLowEnergyCentralManagerDelegate alloc]
100 initWithDiscoveryManager:low_energy_discovery_manager_.get() 100 initWithDiscoveryManager:low_energy_discovery_manager_.get()
101 andAdapter:this]); 101 andAdapter:this]);
102 low_energy_central_manager_.reset([[CBCentralManager alloc] 102 low_energy_central_manager_.reset([[CBCentralManager alloc]
103 initWithDelegate:low_energy_central_manager_delegate_.get() 103 initWithDelegate:low_energy_central_manager_delegate_
104 queue:dispatch_get_main_queue()]); 104 queue:dispatch_get_main_queue()]);
105 low_energy_discovery_manager_->SetCentralManager( 105 low_energy_discovery_manager_->SetCentralManager(
106 low_energy_central_manager_.get()); 106 low_energy_central_manager_);
107 } 107 }
108 DCHECK(classic_discovery_manager_.get()); 108 DCHECK(classic_discovery_manager_);
109 } 109 }
110 110
111 BluetoothAdapterMac::~BluetoothAdapterMac() { 111 BluetoothAdapterMac::~BluetoothAdapterMac() {
112 // When devices will be destroyed, they will need this current instance to 112 // When devices will be destroyed, they will need this current instance to
113 // disconnect the gatt connection. To make sure they don't use the mac 113 // disconnect the gatt connection. To make sure they don't use the mac
114 // adapter, they should be explicitly destroyed here. 114 // adapter, they should be explicitly destroyed here.
115 devices_.clear(); 115 devices_.clear();
116 // Set low_energy_central_manager_ to nil so no devices will try to use it 116 // Set low_energy_central_manager_ to nil so no devices will try to use it
117 // while being destroyed after this method. |devices_| is owned by 117 // while being destroyed after this method. |devices_| is owned by
118 // BluetoothAdapter. 118 // BluetoothAdapter.
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 286
287 void BluetoothAdapterMac::RemovePairingDelegateInternal( 287 void BluetoothAdapterMac::RemovePairingDelegateInternal(
288 BluetoothDevice::PairingDelegate* pairing_delegate) {} 288 BluetoothDevice::PairingDelegate* pairing_delegate) {}
289 289
290 void BluetoothAdapterMac::SetCentralManagerForTesting( 290 void BluetoothAdapterMac::SetCentralManagerForTesting(
291 CBCentralManager* central_manager) { 291 CBCentralManager* central_manager) {
292 CHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); 292 CHECK(BluetoothAdapterMac::IsLowEnergyAvailable());
293 central_manager.delegate = low_energy_central_manager_delegate_; 293 central_manager.delegate = low_energy_central_manager_delegate_;
294 low_energy_central_manager_.reset(central_manager, 294 low_energy_central_manager_.reset(central_manager,
295 base::scoped_policy::RETAIN); 295 base::scoped_policy::RETAIN);
296 low_energy_discovery_manager_->SetCentralManager( 296 low_energy_discovery_manager_->SetCentralManager(low_energy_central_manager_);
297 low_energy_central_manager_.get());
298 } 297 }
299 298
300 CBCentralManager* BluetoothAdapterMac::GetCentralManager() { 299 CBCentralManager* BluetoothAdapterMac::GetCentralManager() {
301 return low_energy_central_manager_; 300 return low_energy_central_manager_;
302 } 301 }
303 302
304 void BluetoothAdapterMac::AddDiscoverySession( 303 void BluetoothAdapterMac::AddDiscoverySession(
305 BluetoothDiscoveryFilter* discovery_filter, 304 BluetoothDiscoveryFilter* discovery_filter,
306 const base::Closure& callback, 305 const base::Closure& callback,
307 const DiscoverySessionErrorCallback& error_callback) { 306 const DiscoverySessionErrorCallback& error_callback) {
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 // hash the probability of this occuring with 10,000 devices 746 // hash the probability of this occuring with 10,000 devices
748 // simultaneously present is 1e-6 (see 747 // simultaneously present is 1e-6 (see
749 // https://en.wikipedia.org/wiki/Birthday_problem#Probability_table). We 748 // https://en.wikipedia.org/wiki/Birthday_problem#Probability_table). We
750 // ignore the second device by returning. 749 // ignore the second device by returning.
751 return true; 750 return true;
752 } 751 }
753 return false; 752 return false;
754 } 753 }
755 754
756 } // namespace device 755 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_adapter_mac_unittest.mm » ('j') | device/bluetooth/bluetooth_adapter_mac_unittest.mm » ('J')

Powered by Google App Engine
This is Rietveld 408576698