| OLD | NEW | 
|    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" | 
|   11 #include "base/mac/sdk_forward_declarations.h" |   11 #include "base/mac/sdk_forward_declarations.h" | 
|   12 #include "base/sequenced_task_runner.h" |   12 #include "base/sequenced_task_runner.h" | 
|   13 #include "base/strings/string_number_conversions.h" |   13 #include "base/strings/string_number_conversions.h" | 
|   14 #include "base/strings/string_util.h" |   14 #include "base/strings/string_util.h" | 
|   15 #include "base/strings/sys_string_conversions.h" |   15 #include "base/strings/sys_string_conversions.h" | 
 |   16 #include "base/time/time.h" | 
|   16 #include "device/bluetooth/bluetooth_socket_mac.h" |   17 #include "device/bluetooth/bluetooth_socket_mac.h" | 
|   17 #include "device/bluetooth/bluetooth_uuid.h" |   18 #include "device/bluetooth/bluetooth_uuid.h" | 
|   18  |   19  | 
|   19 // Undocumented API for accessing the Bluetooth transmit power level. |   20 // Undocumented API for accessing the Bluetooth transmit power level. | 
|   20 // Similar to the API defined here [ http://goo.gl/20Q5vE ]. |   21 // Similar to the API defined here [ http://goo.gl/20Q5vE ]. | 
|   21 @interface IOBluetoothHostController (UndocumentedAPI) |   22 @interface IOBluetoothHostController (UndocumentedAPI) | 
|   22 - (IOReturn) |   23 - (IOReturn) | 
|   23     BluetoothHCIReadTransmitPowerLevel:(BluetoothConnectionHandle)connection |   24     BluetoothHCIReadTransmitPowerLevel:(BluetoothConnectionHandle)connection | 
|   24                                 inType:(BluetoothHCITransmitPowerLevelType)type |   25                                 inType:(BluetoothHCITransmitPowerLevelType)type | 
|   25                  outTransmitPowerLevel:(BluetoothHCITransmitPowerLevel*)level; |   26                  outTransmitPowerLevel:(BluetoothHCITransmitPowerLevel*)level; | 
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  245   error_callback.Run(kApiUnavailable); |  246   error_callback.Run(kApiUnavailable); | 
|  246 } |  247 } | 
|  247  |  248  | 
|  248 void BluetoothClassicDeviceMac::CreateGattConnection( |  249 void BluetoothClassicDeviceMac::CreateGattConnection( | 
|  249     const GattConnectionCallback& callback, |  250     const GattConnectionCallback& callback, | 
|  250     const ConnectErrorCallback& error_callback) { |  251     const ConnectErrorCallback& error_callback) { | 
|  251   // TODO(armansito): Implement. |  252   // TODO(armansito): Implement. | 
|  252   error_callback.Run(ERROR_UNSUPPORTED_DEVICE); |  253   error_callback.Run(ERROR_UNSUPPORTED_DEVICE); | 
|  253 } |  254 } | 
|  254  |  255  | 
|  255 NSDate* BluetoothClassicDeviceMac::GetLastUpdateTime() const { |  256 base::Time BluetoothClassicDeviceMac::GetLastUpdateTime() const { | 
|  256   return [device_ getLastInquiryUpdate]; |  257   return base::Time::FromDoubleT( | 
 |  258       [[device_ getLastInquiryUpdate] timeIntervalSince1970]); | 
|  257 } |  259 } | 
|  258  |  260  | 
|  259 int BluetoothClassicDeviceMac::GetHostTransmitPower( |  261 int BluetoothClassicDeviceMac::GetHostTransmitPower( | 
|  260     BluetoothHCITransmitPowerLevelType power_level_type) const { |  262     BluetoothHCITransmitPowerLevelType power_level_type) const { | 
|  261   IOBluetoothHostController* controller = |  263   IOBluetoothHostController* controller = | 
|  262       [IOBluetoothHostController defaultController]; |  264       [IOBluetoothHostController defaultController]; | 
|  263  |  265  | 
|  264   // Bail if the undocumented API is unavailable on this machine. |  266   // Bail if the undocumented API is unavailable on this machine. | 
|  265   SEL selector = @selector(BluetoothHCIReadTransmitPowerLevel: |  267   SEL selector = @selector(BluetoothHCIReadTransmitPowerLevel: | 
|  266                                                        inType: |  268                                                        inType: | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
|  279   return power_level; |  281   return power_level; | 
|  280 } |  282 } | 
|  281  |  283  | 
|  282 // static |  284 // static | 
|  283 std::string BluetoothClassicDeviceMac::GetDeviceAddress( |  285 std::string BluetoothClassicDeviceMac::GetDeviceAddress( | 
|  284     IOBluetoothDevice* device) { |  286     IOBluetoothDevice* device) { | 
|  285   return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString])); |  287   return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString])); | 
|  286 } |  288 } | 
|  287  |  289  | 
|  288 }  // namespace device |  290 }  // namespace device | 
| OLD | NEW |