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

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

Issue 2282763004: bluetooth: mac: Improve classic device discovery and update (Closed)
Patch Set: Override getlastupdate and make constexpr Created 4 years, 3 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_classic_device_mac.h" 5 #include "device/bluetooth/bluetooth_classic_device_mac.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/hash.h" 10 #include "base/hash.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 uuid_str.insert(18, "-"); 55 uuid_str.insert(18, "-");
56 uuid_str.insert(23, "-"); 56 uuid_str.insert(23, "-");
57 return BluetoothUUID(uuid_str); 57 return BluetoothUUID(uuid_str);
58 } 58 }
59 59
60 } // namespace 60 } // namespace
61 61
62 BluetoothClassicDeviceMac::BluetoothClassicDeviceMac( 62 BluetoothClassicDeviceMac::BluetoothClassicDeviceMac(
63 BluetoothAdapterMac* adapter, 63 BluetoothAdapterMac* adapter,
64 IOBluetoothDevice* device) 64 IOBluetoothDevice* device)
65 : BluetoothDeviceMac(adapter), device_([device retain]) {} 65 : BluetoothDeviceMac(adapter), device_([device retain]) {
66 UpdateTimestamp();
67 }
66 68
67 BluetoothClassicDeviceMac::~BluetoothClassicDeviceMac() { 69 BluetoothClassicDeviceMac::~BluetoothClassicDeviceMac() {
68 } 70 }
69 71
70 uint32_t BluetoothClassicDeviceMac::GetBluetoothClass() const { 72 uint32_t BluetoothClassicDeviceMac::GetBluetoothClass() const {
71 return [device_ classOfDevice]; 73 return [device_ classOfDevice];
72 } 74 }
73 75
74 void BluetoothClassicDeviceMac::CreateGattConnectionImpl() { 76 void BluetoothClassicDeviceMac::CreateGattConnectionImpl() {
75 // Classic devices do not support GATT connection. 77 // Classic devices do not support GATT connection.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 250 }
249 251
250 void BluetoothClassicDeviceMac::CreateGattConnection( 252 void BluetoothClassicDeviceMac::CreateGattConnection(
251 const GattConnectionCallback& callback, 253 const GattConnectionCallback& callback,
252 const ConnectErrorCallback& error_callback) { 254 const ConnectErrorCallback& error_callback) {
253 // TODO(armansito): Implement. 255 // TODO(armansito): Implement.
254 error_callback.Run(ERROR_UNSUPPORTED_DEVICE); 256 error_callback.Run(ERROR_UNSUPPORTED_DEVICE);
255 } 257 }
256 258
257 base::Time BluetoothClassicDeviceMac::GetLastUpdateTime() const { 259 base::Time BluetoothClassicDeviceMac::GetLastUpdateTime() const {
258 return base::Time::FromDoubleT( 260 // Even when a device is discovered during an inquiry procedure this returns
259 [[device_ getLastInquiryUpdate] timeIntervalSince1970]); 261 // nil so we implement out own last_update_time_ which gets updated whenever
262 // the device is found.
263 NSDate* inquiry_update = [device_ getLastInquiryUpdate];
264 if (inquiry_update != nil) {
265 return base::Time::FromDoubleT([inquiry_update timeIntervalSince1970]);
266 }
267 return last_update_time_;
260 } 268 }
261 269
262 int BluetoothClassicDeviceMac::GetHostTransmitPower( 270 int BluetoothClassicDeviceMac::GetHostTransmitPower(
263 BluetoothHCITransmitPowerLevelType power_level_type) const { 271 BluetoothHCITransmitPowerLevelType power_level_type) const {
264 IOBluetoothHostController* controller = 272 IOBluetoothHostController* controller =
265 [IOBluetoothHostController defaultController]; 273 [IOBluetoothHostController defaultController];
266 274
267 // Bail if the undocumented API is unavailable on this machine. 275 // Bail if the undocumented API is unavailable on this machine.
268 SEL selector = @selector(BluetoothHCIReadTransmitPowerLevel: 276 SEL selector = @selector(BluetoothHCIReadTransmitPowerLevel:
269 inType: 277 inType:
(...skipping 12 matching lines...) Expand all
282 return power_level; 290 return power_level;
283 } 291 }
284 292
285 // static 293 // static
286 std::string BluetoothClassicDeviceMac::GetDeviceAddress( 294 std::string BluetoothClassicDeviceMac::GetDeviceAddress(
287 IOBluetoothDevice* device) { 295 IOBluetoothDevice* device) {
288 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString])); 296 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString]));
289 } 297 }
290 298
291 } // namespace device 299 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698