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/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_vector.h" | 11 #include "base/memory/scoped_vector.h" |
12 #include "base/sequenced_task_runner.h" | 12 #include "base/sequenced_task_runner.h" |
13 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
14 #include "device/bluetooth/bluetooth_profile_win.h" | |
15 #include "device/bluetooth/bluetooth_service_record_win.h" | 14 #include "device/bluetooth/bluetooth_service_record_win.h" |
16 #include "device/bluetooth/bluetooth_socket_thread.h" | 15 #include "device/bluetooth/bluetooth_socket_thread.h" |
17 #include "device/bluetooth/bluetooth_socket_win.h" | 16 #include "device/bluetooth/bluetooth_socket_win.h" |
18 #include "device/bluetooth/bluetooth_task_manager_win.h" | 17 #include "device/bluetooth/bluetooth_task_manager_win.h" |
19 #include "device/bluetooth/bluetooth_uuid.h" | 18 #include "device/bluetooth/bluetooth_uuid.h" |
20 | 19 |
21 namespace { | 20 namespace { |
22 | 21 |
23 const int kSdpBytesBufferSize = 1024; | 22 const int kSdpBytesBufferSize = 1024; |
24 | 23 |
(...skipping 20 matching lines...) Expand all Loading... |
45 paired_ = state.authenticated; | 44 paired_ = state.authenticated; |
46 | 45 |
47 for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator | 46 for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator |
48 iter = state.service_record_states.begin(); | 47 iter = state.service_record_states.begin(); |
49 iter != state.service_record_states.end(); | 48 iter != state.service_record_states.end(); |
50 ++iter) { | 49 ++iter) { |
51 uint8 sdp_bytes_buffer[kSdpBytesBufferSize]; | 50 uint8 sdp_bytes_buffer[kSdpBytesBufferSize]; |
52 std::copy((*iter)->sdp_bytes.begin(), | 51 std::copy((*iter)->sdp_bytes.begin(), |
53 (*iter)->sdp_bytes.end(), | 52 (*iter)->sdp_bytes.end(), |
54 sdp_bytes_buffer); | 53 sdp_bytes_buffer); |
55 BluetoothServiceRecord* service_record = new BluetoothServiceRecordWin( | 54 BluetoothServiceRecordWin* service_record = new BluetoothServiceRecordWin( |
56 (*iter)->name, | 55 (*iter)->name, |
57 (*iter)->address, | 56 (*iter)->address, |
58 (*iter)->sdp_bytes.size(), | 57 (*iter)->sdp_bytes.size(), |
59 sdp_bytes_buffer); | 58 sdp_bytes_buffer); |
60 service_record_list_.push_back(service_record); | 59 service_record_list_.push_back(service_record); |
61 uuids_.push_back(service_record->uuid()); | 60 uuids_.push_back(service_record->uuid()); |
62 } | 61 } |
63 } | 62 } |
64 | 63 |
65 BluetoothDeviceWin::~BluetoothDeviceWin() { | 64 BluetoothDeviceWin::~BluetoothDeviceWin() { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 195 |
197 void BluetoothDeviceWin::Forget(const ErrorCallback& error_callback) { | 196 void BluetoothDeviceWin::Forget(const ErrorCallback& error_callback) { |
198 NOTIMPLEMENTED(); | 197 NOTIMPLEMENTED(); |
199 } | 198 } |
200 | 199 |
201 void BluetoothDeviceWin::ConnectToProfile( | 200 void BluetoothDeviceWin::ConnectToProfile( |
202 device::BluetoothProfile* profile, | 201 device::BluetoothProfile* profile, |
203 const base::Closure& callback, | 202 const base::Closure& callback, |
204 const ConnectToProfileErrorCallback& error_callback) { | 203 const ConnectToProfileErrorCallback& error_callback) { |
205 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); | 204 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread()); |
206 static_cast<BluetoothProfileWin*>(profile)->Connect(this, | 205 error_callback.Run("Removed. Use chrome.bluetoothSocket.connect() instead."); |
207 ui_task_runner_, | |
208 socket_thread_, | |
209 net_log_, | |
210 net_log_source_, | |
211 callback, | |
212 error_callback); | |
213 } | 206 } |
214 | 207 |
215 void BluetoothDeviceWin::ConnectToService( | 208 void BluetoothDeviceWin::ConnectToService( |
216 const BluetoothUUID& uuid, | 209 const BluetoothUUID& uuid, |
217 const ConnectToServiceCallback& callback, | 210 const ConnectToServiceCallback& callback, |
218 const ConnectToServiceErrorCallback& error_callback) { | 211 const ConnectToServiceErrorCallback& error_callback) { |
219 // TODO(keybuk): implement | 212 scoped_refptr<BluetoothSocketWin> socket( |
220 NOTIMPLEMENTED(); | 213 BluetoothSocketWin::CreateBluetoothSocket( |
| 214 ui_task_runner_, socket_thread_, NULL, net::NetLog::Source())); |
| 215 socket->Connect(this, uuid, base::Bind(callback, socket), error_callback); |
221 } | 216 } |
222 | 217 |
223 void BluetoothDeviceWin::StartConnectionMonitor( | 218 void BluetoothDeviceWin::StartConnectionMonitor( |
224 const base::Closure& callback, | 219 const base::Closure& callback, |
225 const ErrorCallback& error_callback) { | 220 const ErrorCallback& error_callback) { |
226 NOTIMPLEMENTED(); | 221 NOTIMPLEMENTED(); |
227 } | 222 } |
228 | 223 |
229 const BluetoothServiceRecord* BluetoothDeviceWin::GetServiceRecord( | 224 const BluetoothServiceRecordWin* BluetoothDeviceWin::GetServiceRecord( |
230 const device::BluetoothUUID& uuid) const { | 225 const device::BluetoothUUID& uuid) const { |
231 for (ServiceRecordList::const_iterator iter = service_record_list_.begin(); | 226 for (ServiceRecordList::const_iterator iter = service_record_list_.begin(); |
232 iter != service_record_list_.end(); | 227 iter != service_record_list_.end(); |
233 ++iter) { | 228 ++iter) { |
234 if ((*iter)->uuid() == uuid) | 229 if ((*iter)->uuid() == uuid) |
235 return *iter; | 230 return *iter; |
236 } | 231 } |
237 return NULL; | 232 return NULL; |
238 } | 233 } |
239 | 234 |
240 } // namespace device | 235 } // namespace device |
OLD | NEW |