- add sources.
[platform/framework/web/crosswalk.git] / src / device / bluetooth / bluetooth_profile_win.cc
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
14 BluetoothProfileWin::BluetoothProfileWin(const std::string& uuid,
15                                          const std::string& name)
16     : BluetoothProfile(), uuid_(uuid), name_(name) {
17 }
18
19 BluetoothProfileWin::~BluetoothProfileWin() {
20 }
21
22 void BluetoothProfileWin::Unregister() {
23   delete this;
24 }
25
26 void BluetoothProfileWin::SetConnectionCallback(
27     const ConnectionCallback& callback) {
28   connection_callback_ = callback;
29 }
30
31 bool 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