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/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" | 14 #include "device/bluetooth/bluetooth_out_of_band_pairing_data.h" |
14 #include "device/bluetooth/bluetooth_profile_win.h" | 15 #include "device/bluetooth/bluetooth_profile_win.h" |
15 #include "device/bluetooth/bluetooth_service_record_win.h" | 16 #include "device/bluetooth/bluetooth_service_record_win.h" |
16 #include "device/bluetooth/bluetooth_socket_win.h" | 17 #include "device/bluetooth/bluetooth_socket_win.h" |
17 #include "device/bluetooth/bluetooth_task_manager_win.h" | 18 #include "device/bluetooth/bluetooth_task_manager_win.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 const int kSdpBytesBufferSize = 1024; | 22 const int kSdpBytesBufferSize = 1024; |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 NOTIMPLEMENTED(); | 177 NOTIMPLEMENTED(); |
177 } | 178 } |
178 | 179 |
179 void BluetoothDeviceWin::Forget(const ErrorCallback& error_callback) { | 180 void BluetoothDeviceWin::Forget(const ErrorCallback& error_callback) { |
180 NOTIMPLEMENTED(); | 181 NOTIMPLEMENTED(); |
181 } | 182 } |
182 | 183 |
183 void BluetoothDeviceWin::ConnectToService( | 184 void BluetoothDeviceWin::ConnectToService( |
184 const std::string& service_uuid, | 185 const std::string& service_uuid, |
185 const SocketCallback& callback) { | 186 const SocketCallback& callback) { |
186 for (ServiceRecordList::const_iterator iter = service_record_list_.begin(); | 187 NOTIMPLEMENTED(); |
187 iter != service_record_list_.end(); | |
188 ++iter) { | |
189 if ((*iter)->uuid() == service_uuid) { | |
190 // If multiple service records are found, use the first one that works. | |
191 scoped_refptr<BluetoothSocket> socket( | |
192 BluetoothSocketWin::CreateBluetoothSocket(**iter)); | |
193 if (socket.get() != NULL) { | |
194 callback.Run(socket); | |
195 return; | |
196 } | |
197 } | |
198 } | |
199 } | 188 } |
200 | 189 |
201 void BluetoothDeviceWin::ConnectToProfile( | 190 void BluetoothDeviceWin::ConnectToProfile( |
202 device::BluetoothProfile* profile, | 191 device::BluetoothProfile* profile, |
| 192 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, |
| 193 scoped_refptr<base::SequencedTaskRunner> file_task_runner, |
| 194 net::NetLog* net_log, |
| 195 const net::NetLog::Source& source, |
203 const base::Closure& callback, | 196 const base::Closure& callback, |
204 const ErrorCallback& error_callback) { | 197 const ErrorCallback& error_callback) { |
205 if (static_cast<BluetoothProfileWin*>(profile)->Connect(this)) | 198 DCHECK(ui_task_runner->RunsTasksOnCurrentThread()); |
206 callback.Run(); | 199 static_cast<BluetoothProfileWin*>(profile)->Connect(this, |
207 else | 200 ui_task_runner, |
208 error_callback.Run(); | 201 file_task_runner, |
| 202 net_log, |
| 203 source, |
| 204 callback, |
| 205 error_callback); |
209 } | 206 } |
210 | 207 |
211 void BluetoothDeviceWin::SetOutOfBandPairingData( | 208 void BluetoothDeviceWin::SetOutOfBandPairingData( |
212 const BluetoothOutOfBandPairingData& data, | 209 const BluetoothOutOfBandPairingData& data, |
213 const base::Closure& callback, | 210 const base::Closure& callback, |
214 const ErrorCallback& error_callback) { | 211 const ErrorCallback& error_callback) { |
215 NOTIMPLEMENTED(); | 212 NOTIMPLEMENTED(); |
216 } | 213 } |
217 | 214 |
218 void BluetoothDeviceWin::ClearOutOfBandPairingData( | 215 void BluetoothDeviceWin::ClearOutOfBandPairingData( |
219 const base::Closure& callback, | 216 const base::Closure& callback, |
220 const ErrorCallback& error_callback) { | 217 const ErrorCallback& error_callback) { |
221 NOTIMPLEMENTED(); | 218 NOTIMPLEMENTED(); |
222 } | 219 } |
223 | 220 |
224 const BluetoothServiceRecord* BluetoothDeviceWin::GetServiceRecord( | 221 const BluetoothServiceRecord* BluetoothDeviceWin::GetServiceRecord( |
225 const std::string& uuid) const { | 222 const std::string& uuid) const { |
226 for (ServiceRecordList::const_iterator iter = service_record_list_.begin(); | 223 for (ServiceRecordList::const_iterator iter = service_record_list_.begin(); |
227 iter != service_record_list_.end(); | 224 iter != service_record_list_.end(); |
228 ++iter) { | 225 ++iter) { |
229 if ((*iter)->uuid().compare(uuid) == 0) | 226 if ((*iter)->uuid().compare(uuid) == 0) |
230 return *iter; | 227 return *iter; |
231 } | 228 } |
232 return NULL; | 229 return NULL; |
233 } | 230 } |
234 | 231 |
235 } // namespace device | 232 } // namespace device |
OLD | NEW |