| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_device_win.h" | 5 #include "device/bluetooth/bluetooth_device_win.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/containers/scoped_ptr_hash_map.h" | 10 #include "base/containers/scoped_ptr_hash_map.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/sequenced_task_runner.h" | 13 #include "base/sequenced_task_runner.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "device/bluetooth/bluetooth_service_record_win.h" | 15 #include "device/bluetooth/bluetooth_service_record_win.h" |
| 16 #include "device/bluetooth/bluetooth_socket_thread.h" | 16 #include "device/bluetooth/bluetooth_socket_thread.h" |
| 17 #include "device/bluetooth/bluetooth_socket_win.h" | 17 #include "device/bluetooth/bluetooth_socket_win.h" |
| 18 #include "device/bluetooth/bluetooth_task_manager_win.h" | 18 #include "device/bluetooth/bluetooth_task_manager_win.h" |
| 19 #include "device/bluetooth/bluetooth_uuid.h" | 19 #include "device/bluetooth/bluetooth_uuid.h" |
| 20 | 20 |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 const int kSdpBytesBufferSize = 1024; | 23 const int kSdpBytesBufferSize = 1024; |
| 24 | 24 |
| 25 const char kApiUnavailable[] = "This API is not implemented on this platform."; |
| 26 |
| 25 } // namespace | 27 } // namespace |
| 26 | 28 |
| 27 namespace device { | 29 namespace device { |
| 28 | 30 |
| 29 BluetoothDeviceWin::BluetoothDeviceWin( | 31 BluetoothDeviceWin::BluetoothDeviceWin( |
| 30 const BluetoothTaskManagerWin::DeviceState& device_state, | 32 const BluetoothTaskManagerWin::DeviceState& device_state, |
| 31 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, | 33 const scoped_refptr<base::SequencedTaskRunner>& ui_task_runner, |
| 32 const scoped_refptr<BluetoothSocketThread>& socket_thread, | 34 const scoped_refptr<BluetoothSocketThread>& socket_thread, |
| 33 net::NetLog* net_log, | 35 net::NetLog* net_log, |
| 34 const net::NetLog::Source& net_log_source) | 36 const net::NetLog::Source& net_log_source) |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 void BluetoothDeviceWin::ConnectToService( | 258 void BluetoothDeviceWin::ConnectToService( |
| 257 const BluetoothUUID& uuid, | 259 const BluetoothUUID& uuid, |
| 258 const ConnectToServiceCallback& callback, | 260 const ConnectToServiceCallback& callback, |
| 259 const ConnectToServiceErrorCallback& error_callback) { | 261 const ConnectToServiceErrorCallback& error_callback) { |
| 260 scoped_refptr<BluetoothSocketWin> socket( | 262 scoped_refptr<BluetoothSocketWin> socket( |
| 261 BluetoothSocketWin::CreateBluetoothSocket( | 263 BluetoothSocketWin::CreateBluetoothSocket( |
| 262 ui_task_runner_, socket_thread_)); | 264 ui_task_runner_, socket_thread_)); |
| 263 socket->Connect(this, uuid, base::Bind(callback, socket), error_callback); | 265 socket->Connect(this, uuid, base::Bind(callback, socket), error_callback); |
| 264 } | 266 } |
| 265 | 267 |
| 268 void BluetoothDeviceWin::ConnectToServiceInsecurely( |
| 269 const BluetoothUUID& uuid, |
| 270 const ConnectToServiceCallback& callback, |
| 271 const ConnectToServiceErrorCallback& error_callback) { |
| 272 error_callback.Run(kApiUnavailable); |
| 273 } |
| 274 |
| 266 void BluetoothDeviceWin::CreateGattConnection( | 275 void BluetoothDeviceWin::CreateGattConnection( |
| 267 const GattConnectionCallback& callback, | 276 const GattConnectionCallback& callback, |
| 268 const ConnectErrorCallback& error_callback) { | 277 const ConnectErrorCallback& error_callback) { |
| 269 // TODO(armansito): Implement. | 278 // TODO(armansito): Implement. |
| 270 error_callback.Run(ERROR_UNSUPPORTED_DEVICE); | 279 error_callback.Run(ERROR_UNSUPPORTED_DEVICE); |
| 271 } | 280 } |
| 272 | 281 |
| 273 void BluetoothDeviceWin::StartConnectionMonitor( | 282 void BluetoothDeviceWin::StartConnectionMonitor( |
| 274 const base::Closure& callback, | 283 const base::Closure& callback, |
| 275 const ErrorCallback& error_callback) { | 284 const ErrorCallback& error_callback) { |
| 276 NOTIMPLEMENTED(); | 285 NOTIMPLEMENTED(); |
| 277 } | 286 } |
| 278 | 287 |
| 279 const BluetoothServiceRecordWin* BluetoothDeviceWin::GetServiceRecord( | 288 const BluetoothServiceRecordWin* BluetoothDeviceWin::GetServiceRecord( |
| 280 const device::BluetoothUUID& uuid) const { | 289 const device::BluetoothUUID& uuid) const { |
| 281 for (ServiceRecordList::const_iterator iter = service_record_list_.begin(); | 290 for (ServiceRecordList::const_iterator iter = service_record_list_.begin(); |
| 282 iter != service_record_list_.end(); | 291 iter != service_record_list_.end(); |
| 283 ++iter) { | 292 ++iter) { |
| 284 if ((*iter)->uuid() == uuid) | 293 if ((*iter)->uuid() == uuid) |
| 285 return *iter; | 294 return *iter; |
| 286 } | 295 } |
| 287 return NULL; | 296 return NULL; |
| 288 } | 297 } |
| 289 | 298 |
| 290 } // namespace device | 299 } // namespace device |
| OLD | NEW |