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

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

Issue 2282763004: bluetooth: mac: Improve classic device discovery and update (Closed)
Patch Set: Address moar comments Created 4 years, 2 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 "device/bluetooth/bluetooth_discovery_manager_mac.h" 5 #include "device/bluetooth/bluetooth_discovery_manager_mac.h"
6 6
7 #import <IOBluetooth/objc/IOBluetoothDevice.h> 7 #import <IOBluetooth/objc/IOBluetoothDevice.h>
8 #import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h> 8 #import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 13 matching lines...) Expand all
24 @private 24 @private
25 device::BluetoothDiscoveryManagerMacClassic* manager_; // weak 25 device::BluetoothDiscoveryManagerMacClassic* manager_; // weak
26 } 26 }
27 27
28 - (id)initWithManager:(device::BluetoothDiscoveryManagerMacClassic*)manager; 28 - (id)initWithManager:(device::BluetoothDiscoveryManagerMacClassic*)manager;
29 29
30 @end 30 @end
31 31
32 namespace device { 32 namespace device {
33 33
34 // ementation of BluetoothDiscoveryManagerMac for Bluetooth classic device 34 // Implementation of BluetoothDiscoveryManagerMac for Bluetooth classic device
35 // discovery, using the IOBluetooth framework. 35 // discovery, using the IOBluetooth framework.
36 class BluetoothDiscoveryManagerMacClassic 36 class BluetoothDiscoveryManagerMacClassic
37 : public BluetoothDiscoveryManagerMac { 37 : public BluetoothDiscoveryManagerMac {
38 public: 38 public:
39 explicit BluetoothDiscoveryManagerMacClassic(Observer* observer) 39 explicit BluetoothDiscoveryManagerMacClassic(Observer* observer)
40 : BluetoothDiscoveryManagerMac(observer), 40 : BluetoothDiscoveryManagerMac(observer),
41 should_do_discovery_(false), 41 should_do_discovery_(false),
42 inquiry_running_(false), 42 inquiry_running_(false),
43 inquiry_delegate_( 43 inquiry_delegate_(
44 [[BluetoothDeviceInquiryDelegate alloc] initWithManager:this]), 44 [[BluetoothDeviceInquiryDelegate alloc] initWithManager:this]),
45 inquiry_([[IOBluetoothDeviceInquiry alloc] 45 inquiry_([[IOBluetoothDeviceInquiry alloc]
46 initWithDelegate:inquiry_delegate_]) {} 46 initWithDelegate:inquiry_delegate_]) {}
47 47
48 ~BluetoothDiscoveryManagerMacClassic() override {} 48 ~BluetoothDiscoveryManagerMacClassic() override {}
49 49
50 // BluetoothDiscoveryManagerMac override. 50 // BluetoothDiscoveryManagerMac override.
51 bool IsDiscovering() const override { return should_do_discovery_; } 51 bool IsDiscovering() const override { return should_do_discovery_; }
52 52
53 // BluetoothDiscoveryManagerMac override. 53 // BluetoothDiscoveryManagerMac override.
54 bool StartDiscovery() override { 54 bool StartDiscovery() override {
55 DVLOG(1) << "Bluetooth Classic: StartDiscovery"; 55 DVLOG(1) << "Bluetooth Classic: StartDiscovery";
56 DCHECK(!should_do_discovery_); 56 DCHECK(!should_do_discovery_);
57 57
58 DVLOG(1) << "Discovery requested"; 58 DVLOG(1) << "Discovery requested";
59 should_do_discovery_ = true; 59 should_do_discovery_ = true;
60 60
61 // Clean the cache so that new discovery sessions find previously
62 // discovered devices as well.
63 [inquiry_ clearFoundDevices];
64
61 if (inquiry_running_) { 65 if (inquiry_running_) {
62 DVLOG(1) << "Device inquiry already running"; 66 DVLOG(1) << "Device inquiry already running";
63 return true; 67 return true;
64 } 68 }
65 69
66 DVLOG(1) << "Requesting to start device inquiry"; 70 DVLOG(1) << "Requesting to start device inquiry";
67 if ([inquiry_ start] != kIOReturnSuccess) { 71 if ([inquiry_ start] != kIOReturnSuccess) {
68 DVLOG(1) << "Failed to start device inquiry"; 72 DVLOG(1) << "Failed to start device inquiry";
69 73
70 // Set |should_do_discovery_| to false here. Since we're reporting an 74 // Set |should_do_discovery_| to false here. Since we're reporting an
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 manager_->DeviceFound(sender, device); 218 manager_->DeviceFound(sender, device);
215 } 219 }
216 220
217 - (void)deviceInquiryComplete:(IOBluetoothDeviceInquiry*)sender 221 - (void)deviceInquiryComplete:(IOBluetoothDeviceInquiry*)sender
218 error:(IOReturn)error 222 error:(IOReturn)error
219 aborted:(BOOL)aborted { 223 aborted:(BOOL)aborted {
220 manager_->DeviceInquiryComplete(sender, error, aborted); 224 manager_->DeviceInquiryComplete(sender, error, aborted);
221 } 225 }
222 226
223 @end 227 @end
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device.cc ('k') | device/bluetooth/bluetooth_low_energy_discovery_manager_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698