1 // Copyright 2014 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.
5 #include "content/child/bluetooth/web_bluetooth_impl.h"
7 #include "content/child/bluetooth/bluetooth_dispatcher.h"
8 #include "content/child/thread_safe_sender.h"
12 WebBluetoothImpl::WebBluetoothImpl(ThreadSafeSender
* thread_safe_sender
)
13 : thread_safe_sender_(thread_safe_sender
) {
16 WebBluetoothImpl::~WebBluetoothImpl() {
19 void WebBluetoothImpl::requestDevice(
20 const blink::WebRequestDeviceOptions
& options
,
21 blink::WebBluetoothRequestDeviceCallbacks
* callbacks
) {
22 GetDispatcher()->requestDevice(options
, callbacks
);
25 void WebBluetoothImpl::connectGATT(const blink::WebString
& device_instance_id
,
26 blink::WebBluetoothConnectGATTCallbacks
* callbacks
) {
27 GetDispatcher()->connectGATT(device_instance_id
, callbacks
);
30 void WebBluetoothImpl::getPrimaryService(
31 const blink::WebString
& device_instance_id
,
32 const blink::WebString
& service_uuid
,
33 blink::WebBluetoothGetPrimaryServiceCallbacks
* callbacks
) {
34 GetDispatcher()->getPrimaryService(device_instance_id
, service_uuid
,
38 void WebBluetoothImpl::getCharacteristic(
39 const blink::WebString
& service_instance_id
,
40 const blink::WebString
& characteristic_uuid
,
41 blink::WebBluetoothGetCharacteristicCallbacks
* callbacks
) {
42 GetDispatcher()->getCharacteristic(service_instance_id
, characteristic_uuid
,
46 void WebBluetoothImpl::readValue(
47 const blink::WebString
& characteristic_instance_id
,
48 blink::WebBluetoothReadValueCallbacks
* callbacks
) {
49 GetDispatcher()->readValue(characteristic_instance_id
, callbacks
);
52 void WebBluetoothImpl::writeValue(
53 const blink::WebString
& characteristic_instance_id
,
54 const std::vector
<uint8_t>& value
,
55 blink::WebBluetoothWriteValueCallbacks
* callbacks
) {
56 GetDispatcher()->writeValue(characteristic_instance_id
, value
, callbacks
);
59 BluetoothDispatcher
* WebBluetoothImpl::GetDispatcher() {
60 return BluetoothDispatcher::GetOrCreateThreadSpecificInstance(
61 thread_safe_sender_
.get());
64 } // namespace content