| 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_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/IOBluetoothDeviceInquiry.h> | 8 #import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h> |
| 9 #import <IOBluetooth/objc/IOBluetoothHostController.h> | 9 #import <IOBluetooth/objc/IOBluetoothHostController.h> |
| 10 | 10 |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 void BluetoothAdapterMac::PollAdapter() { | 242 void BluetoothAdapterMac::PollAdapter() { |
| 243 bool was_present = IsPresent(); | 243 bool was_present = IsPresent(); |
| 244 std::string name; | 244 std::string name; |
| 245 std::string address; | 245 std::string address; |
| 246 bool powered = false; | 246 bool powered = false; |
| 247 IOBluetoothHostController* controller = | 247 IOBluetoothHostController* controller = |
| 248 [IOBluetoothHostController defaultController]; | 248 [IOBluetoothHostController defaultController]; |
| 249 | 249 |
| 250 if (controller != nil) { | 250 if (controller != nil) { |
| 251 name = base::SysNSStringToUTF8([controller nameAsString]); | 251 name = base::SysNSStringToUTF8([controller nameAsString]); |
| 252 address = BluetoothDeviceMac::NormalizeAddress( | 252 address = BluetoothDevice::CanonicalizeAddress( |
| 253 base::SysNSStringToUTF8([controller addressAsString])); | 253 base::SysNSStringToUTF8([controller addressAsString])); |
| 254 powered = ([controller powerState] == kBluetoothHCIPowerStateON); | 254 powered = ([controller powerState] == kBluetoothHCIPowerStateON); |
| 255 } | 255 } |
| 256 | 256 |
| 257 bool is_present = !address.empty(); | 257 bool is_present = !address.empty(); |
| 258 name_ = name; | 258 name_ = name; |
| 259 address_ = address; | 259 address_ = address; |
| 260 | 260 |
| 261 if (was_present != is_present) { | 261 if (was_present != is_present) { |
| 262 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, | 262 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 379 iter != callback_list.end(); | 379 iter != callback_list.end(); |
| 380 ++iter) { | 380 ++iter) { |
| 381 if (success) | 381 if (success) |
| 382 ui_task_runner_->PostTask(FROM_HERE, iter->first); | 382 ui_task_runner_->PostTask(FROM_HERE, iter->first); |
| 383 else | 383 else |
| 384 ui_task_runner_->PostTask(FROM_HERE, iter->second); | 384 ui_task_runner_->PostTask(FROM_HERE, iter->second); |
| 385 } | 385 } |
| 386 } | 386 } |
| 387 | 387 |
| 388 } // namespace device | 388 } // namespace device |
| OLD | NEW |