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

Side by Side Diff: device/bluetooth/bluetooth_device_win.cc

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code review feedback. Created 6 years, 9 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
OLDNEW
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;
22 23
23 } // namespace 24 } // namespace
24 25
25 namespace device { 26 namespace device {
26 27
27 BluetoothDeviceWin::BluetoothDeviceWin( 28 BluetoothDeviceWin::BluetoothDeviceWin(
28 const BluetoothTaskManagerWin::DeviceState& state) 29 const BluetoothTaskManagerWin::DeviceState& state,
29 : BluetoothDevice() { 30 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
31 scoped_refptr<base::SequencedTaskRunner> file_task_runner,
32 net::NetLog* net_log,
33 const net::NetLog::Source& net_log_source)
34 : BluetoothDevice(),
35 ui_task_runner_(ui_task_runner),
36 file_task_runner_(file_task_runner),
37 net_log_(net_log),
38 net_log_source_(net_log_source) {
30 name_ = state.name; 39 name_ = state.name;
31 address_ = state.address; 40 address_ = state.address;
32 bluetooth_class_ = state.bluetooth_class; 41 bluetooth_class_ = state.bluetooth_class;
33 visible_ = state.visible; 42 visible_ = state.visible;
34 connected_ = state.connected; 43 connected_ = state.connected;
35 paired_ = state.authenticated; 44 paired_ = state.authenticated;
36 45
37 for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator 46 for (ScopedVector<BluetoothTaskManagerWin::ServiceRecordState>::const_iterator
38 iter = state.service_record_states.begin(); 47 iter = state.service_record_states.begin();
39 iter != state.service_record_states.end(); 48 iter != state.service_record_states.end();
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 NOTIMPLEMENTED(); 185 NOTIMPLEMENTED();
177 } 186 }
178 187
179 void BluetoothDeviceWin::Forget(const ErrorCallback& error_callback) { 188 void BluetoothDeviceWin::Forget(const ErrorCallback& error_callback) {
180 NOTIMPLEMENTED(); 189 NOTIMPLEMENTED();
181 } 190 }
182 191
183 void BluetoothDeviceWin::ConnectToService( 192 void BluetoothDeviceWin::ConnectToService(
184 const std::string& service_uuid, 193 const std::string& service_uuid,
185 const SocketCallback& callback) { 194 const SocketCallback& callback) {
186 for (ServiceRecordList::const_iterator iter = service_record_list_.begin(); 195 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 } 196 }
200 197
201 void BluetoothDeviceWin::ConnectToProfile( 198 void BluetoothDeviceWin::ConnectToProfile(
202 device::BluetoothProfile* profile, 199 device::BluetoothProfile* profile,
203 const base::Closure& callback, 200 const base::Closure& callback,
204 const ErrorCallback& error_callback) { 201 const ErrorCallback& error_callback) {
205 if (static_cast<BluetoothProfileWin*>(profile)->Connect(this)) 202 DCHECK(ui_task_runner_->RunsTasksOnCurrentThread());
206 callback.Run(); 203 static_cast<BluetoothProfileWin*>(profile)->Connect(this,
207 else 204 ui_task_runner_,
208 error_callback.Run(); 205 file_task_runner_,
206 net_log_,
207 net_log_source_,
208 callback,
209 error_callback);
209 } 210 }
210 211
211 void BluetoothDeviceWin::SetOutOfBandPairingData( 212 void BluetoothDeviceWin::SetOutOfBandPairingData(
212 const BluetoothOutOfBandPairingData& data, 213 const BluetoothOutOfBandPairingData& data,
213 const base::Closure& callback, 214 const base::Closure& callback,
214 const ErrorCallback& error_callback) { 215 const ErrorCallback& error_callback) {
215 NOTIMPLEMENTED(); 216 NOTIMPLEMENTED();
216 } 217 }
217 218
218 void BluetoothDeviceWin::ClearOutOfBandPairingData( 219 void BluetoothDeviceWin::ClearOutOfBandPairingData(
219 const base::Closure& callback, 220 const base::Closure& callback,
220 const ErrorCallback& error_callback) { 221 const ErrorCallback& error_callback) {
221 NOTIMPLEMENTED(); 222 NOTIMPLEMENTED();
222 } 223 }
223 224
224 const BluetoothServiceRecord* BluetoothDeviceWin::GetServiceRecord( 225 const BluetoothServiceRecord* BluetoothDeviceWin::GetServiceRecord(
225 const std::string& uuid) const { 226 const std::string& uuid) const {
226 for (ServiceRecordList::const_iterator iter = service_record_list_.begin(); 227 for (ServiceRecordList::const_iterator iter = service_record_list_.begin();
227 iter != service_record_list_.end(); 228 iter != service_record_list_.end();
228 ++iter) { 229 ++iter) {
229 if ((*iter)->uuid().compare(uuid) == 0) 230 if ((*iter)->uuid().compare(uuid) == 0)
230 return *iter; 231 return *iter;
231 } 232 }
232 return NULL; 233 return NULL;
233 } 234 }
234 235
235 } // namespace device 236 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698