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 3 // found in the LICENSE file. 4 5 #include "device/bluetooth/bluetooth_profile_win.h" 6 7 #include "base/memory/ref_counted.h" 8 #include "device/bluetooth/bluetooth_device_win.h" 9 #include "device/bluetooth/bluetooth_service_record.h" 10 #include "device/bluetooth/bluetooth_socket_win.h" 11 12 namespace device { 13 BluetoothProfileWin(const std::string & uuid,const std::string & name)14BluetoothProfileWin::BluetoothProfileWin(const std::string& uuid, 15 const std::string& name) 16 : BluetoothProfile(), uuid_(uuid), name_(name) { 17 } 18 ~BluetoothProfileWin()19BluetoothProfileWin::~BluetoothProfileWin() { 20 } 21 Unregister()22void BluetoothProfileWin::Unregister() { 23 delete this; 24 } 25 SetConnectionCallback(const ConnectionCallback & callback)26void BluetoothProfileWin::SetConnectionCallback( 27 const ConnectionCallback& callback) { 28 connection_callback_ = callback; 29 } 30 Connect(const BluetoothDeviceWin * device)31bool BluetoothProfileWin::Connect(const BluetoothDeviceWin* device) { 32 if (connection_callback_.is_null()) 33 return false; 34 35 const BluetoothServiceRecord* record = device->GetServiceRecord(uuid_); 36 if (record) { 37 scoped_refptr<BluetoothSocket> socket( 38 BluetoothSocketWin::CreateBluetoothSocket(*record)); 39 if (socket.get() != NULL) { 40 connection_callback_.Run(device, socket); 41 return true; 42 } 43 } 44 return false; 45 } 46 47 } // namespace device 48