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/renderer/bluetooth/web_bluetooth_impl.h"
7 #include "content/child/thread_safe_sender.h"
8 #include "content/renderer/bluetooth/bluetooth_dispatcher.h"
9 #include "ipc/ipc_message.h"
13 WebBluetoothImpl::WebBluetoothImpl(ThreadSafeSender
* thread_safe_sender
)
14 : WebBluetoothImpl(thread_safe_sender
, MSG_ROUTING_NONE
) {}
16 WebBluetoothImpl::WebBluetoothImpl(ThreadSafeSender
* thread_safe_sender
,
18 : thread_safe_sender_(thread_safe_sender
),
19 frame_routing_id_(frame_routing_id
) {}
21 WebBluetoothImpl::~WebBluetoothImpl() {
24 void WebBluetoothImpl::requestDevice(
25 const blink::WebRequestDeviceOptions
& options
,
26 blink::WebBluetoothRequestDeviceCallbacks
* callbacks
) {
27 GetDispatcher()->requestDevice(frame_routing_id_
, options
, callbacks
);
30 void WebBluetoothImpl::connectGATT(const blink::WebString
& device_instance_id
,
31 blink::WebBluetoothConnectGATTCallbacks
* callbacks
) {
32 GetDispatcher()->connectGATT(device_instance_id
, callbacks
);
35 void WebBluetoothImpl::getPrimaryService(
36 const blink::WebString
& device_instance_id
,
37 const blink::WebString
& service_uuid
,
38 blink::WebBluetoothGetPrimaryServiceCallbacks
* callbacks
) {
39 GetDispatcher()->getPrimaryService(device_instance_id
, service_uuid
,
43 void WebBluetoothImpl::getCharacteristic(
44 const blink::WebString
& service_instance_id
,
45 const blink::WebString
& characteristic_uuid
,
46 blink::WebBluetoothGetCharacteristicCallbacks
* callbacks
) {
47 GetDispatcher()->getCharacteristic(service_instance_id
, characteristic_uuid
,
51 void WebBluetoothImpl::readValue(
52 const blink::WebString
& characteristic_instance_id
,
53 blink::WebBluetoothReadValueCallbacks
* callbacks
) {
54 GetDispatcher()->readValue(characteristic_instance_id
, callbacks
);
57 void WebBluetoothImpl::writeValue(
58 const blink::WebString
& characteristic_instance_id
,
59 const std::vector
<uint8_t>& value
,
60 blink::WebBluetoothWriteValueCallbacks
* callbacks
) {
61 GetDispatcher()->writeValue(characteristic_instance_id
, value
, callbacks
);
64 BluetoothDispatcher
* WebBluetoothImpl::GetDispatcher() {
65 return BluetoothDispatcher::GetOrCreateThreadSpecificInstance(
66 thread_safe_sender_
.get());
69 } // namespace content