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

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

Issue 229463003: MacOS implementation of BluetoothSocket. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix build error on OSX SDK < 10.7. Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_device_mac.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/IOBluetoothDeviceInquiry.h> 8 #import <IOBluetooth/objc/IOBluetoothDeviceInquiry.h>
9 #import <IOBluetooth/objc/IOBluetoothHostController.h> 9 #import <IOBluetooth/objc/IOBluetoothHostController.h>
10 10
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 base::Bind(&BluetoothAdapterMac::PollAdapter, 258 base::Bind(&BluetoothAdapterMac::PollAdapter,
259 weak_ptr_factory_.GetWeakPtr()), 259 weak_ptr_factory_.GetWeakPtr()),
260 base::TimeDelta::FromMilliseconds(kPollIntervalMs)); 260 base::TimeDelta::FromMilliseconds(kPollIntervalMs));
261 } 261 }
262 262
263 void BluetoothAdapterMac::UpdateDevices(NSArray* devices) { 263 void BluetoothAdapterMac::UpdateDevices(NSArray* devices) {
264 STLDeleteValues(&devices_); 264 STLDeleteValues(&devices_);
265 for (IOBluetoothDevice* device in devices) { 265 for (IOBluetoothDevice* device in devices) {
266 std::string device_address = 266 std::string device_address =
267 base::SysNSStringToUTF8([device addressString]); 267 base::SysNSStringToUTF8([device addressString]);
268 devices_[device_address] = new BluetoothDeviceMac(device); 268 devices_[device_address] = new BluetoothDeviceMac(ui_task_runner_, device);
269 } 269 }
270 } 270 }
271 271
272 void BluetoothAdapterMac::DeviceInquiryStarted( 272 void BluetoothAdapterMac::DeviceInquiryStarted(
273 IOBluetoothDeviceInquiry* inquiry) { 273 IOBluetoothDeviceInquiry* inquiry) {
274 DCHECK(device_inquiry_ == inquiry); 274 DCHECK(device_inquiry_ == inquiry);
275 if (discovery_status_ == DISCOVERING) 275 if (discovery_status_ == DISCOVERING)
276 return; 276 return;
277 277
278 discovery_status_ = DISCOVERING; 278 discovery_status_ = DISCOVERING;
279 RunCallbacks(on_start_discovery_callbacks_, true); 279 RunCallbacks(on_start_discovery_callbacks_, true);
280 num_discovery_listeners_ = on_start_discovery_callbacks_.size(); 280 num_discovery_listeners_ = on_start_discovery_callbacks_.size();
281 on_start_discovery_callbacks_.clear(); 281 on_start_discovery_callbacks_.clear();
282 282
283 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 283 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
284 AdapterDiscoveringChanged(this, true)); 284 AdapterDiscoveringChanged(this, true));
285 MaybeStopDeviceInquiry(); 285 MaybeStopDeviceInquiry();
286 } 286 }
287 287
288 void BluetoothAdapterMac::DeviceFound(IOBluetoothDeviceInquiry* inquiry, 288 void BluetoothAdapterMac::DeviceFound(IOBluetoothDeviceInquiry* inquiry,
289 IOBluetoothDevice* device) { 289 IOBluetoothDevice* device) {
290 DCHECK(device_inquiry_ == inquiry); 290 DCHECK(device_inquiry_ == inquiry);
291 std::string device_address = base::SysNSStringToUTF8([device addressString]); 291 std::string device_address = base::SysNSStringToUTF8([device addressString]);
292 if (discovered_devices_.find(device_address) == discovered_devices_.end()) { 292 if (discovered_devices_.find(device_address) == discovered_devices_.end()) {
293 scoped_ptr<BluetoothDeviceMac> device_mac(new BluetoothDeviceMac(device)); 293 scoped_ptr<BluetoothDeviceMac> device_mac(
294 new BluetoothDeviceMac(ui_task_runner_, device));
294 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_, 295 FOR_EACH_OBSERVER(BluetoothAdapter::Observer, observers_,
295 DeviceAdded(this, device_mac.get())); 296 DeviceAdded(this, device_mac.get()));
296 discovered_devices_.insert(device_address); 297 discovered_devices_.insert(device_address);
297 } 298 }
298 } 299 }
299 300
300 void BluetoothAdapterMac::DeviceInquiryComplete( 301 void BluetoothAdapterMac::DeviceInquiryComplete(
301 IOBluetoothDeviceInquiry* inquiry, 302 IOBluetoothDeviceInquiry* inquiry,
302 IOReturn error, 303 IOReturn error,
303 bool aborted) { 304 bool aborted) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 iter != callback_list.end(); 355 iter != callback_list.end();
355 ++iter) { 356 ++iter) {
356 if (success) 357 if (success)
357 ui_task_runner_->PostTask(FROM_HERE, iter->first); 358 ui_task_runner_->PostTask(FROM_HERE, iter->first);
358 else 359 else
359 ui_task_runner_->PostTask(FROM_HERE, iter->second); 360 ui_task_runner_->PostTask(FROM_HERE, iter->second);
360 } 361 }
361 } 362 }
362 363
363 } // namespace device 364 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/bluetooth/bluetooth_device_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698