blob: f0729bb4fb7877c3cbefe4d7d99f341fdaadc033 [file] [log] [blame]
Torne (Richard Coles)c2e0dbd2013-05-09 18:35:53 +01001// 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
12namespace device {
13
14BluetoothProfileWin::BluetoothProfileWin(const std::string& uuid,
15 const std::string& name)
16 : BluetoothProfile(), uuid_(uuid), name_(name) {
17}
18
19BluetoothProfileWin::~BluetoothProfileWin() {
20}
21
22void BluetoothProfileWin::Unregister() {
23 delete this;
24}
25
26void BluetoothProfileWin::SetConnectionCallback(
27 const ConnectionCallback& callback) {
28 connection_callback_ = callback;
29}
30
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