Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / public / platform / modules / bluetooth / WebBluetooth.h
blobefe698ed7375673a05dd25905f37e8402f9a03f4
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 #ifndef WebBluetooth_h
6 #define WebBluetooth_h
8 #include "public/platform/WebCallbacks.h"
9 #include "public/platform/WebPassOwnPtr.h"
10 #include "public/platform/WebString.h"
11 #include "public/platform/WebVector.h"
12 #include "public/platform/modules/bluetooth/WebBluetoothError.h"
13 #include <vector>
15 namespace blink {
17 struct WebBluetoothDevice;
18 struct WebBluetoothGATTCharacteristic;
19 struct WebBluetoothGATTRemoteServer;
20 struct WebBluetoothGATTService;
21 struct WebRequestDeviceOptions;
23 // Success and failure callbacks for requestDevice.
24 using WebBluetoothRequestDeviceCallbacks = WebCallbacks<WebPassOwnPtr<WebBluetoothDevice>, const WebBluetoothError&>;
26 // Success and failure callbacks for connectGATT.
27 using WebBluetoothConnectGATTCallbacks = WebCallbacks<WebPassOwnPtr<WebBluetoothGATTRemoteServer>, const WebBluetoothError&>;
29 // Success and failure callbacks for getPrimaryService.
30 using WebBluetoothGetPrimaryServiceCallbacks = WebCallbacks<WebPassOwnPtr<WebBluetoothGATTService>, const WebBluetoothError&>;
32 // Success and failure callbacks for getCharacteristic.
33 using WebBluetoothGetCharacteristicCallbacks = WebCallbacks<WebPassOwnPtr<WebBluetoothGATTCharacteristic>, const WebBluetoothError&>;
35 // Success and failure callbacks for readValue.
36 using WebBluetoothReadValueCallbacks = WebCallbacks<const WebVector<uint8_t>&, const WebBluetoothError&>;
38 // Success and failure callbacks for writeValue.
39 using WebBluetoothWriteValueCallbacks = WebCallbacks<void, const WebBluetoothError&>;
41 class WebBluetooth {
42 public:
43 virtual ~WebBluetooth() { }
45 // Bluetooth Methods:
46 // See https://webbluetoothchrome.github.io/web-bluetooth/#device-discovery
47 // WebBluetoothRequestDeviceCallbacks ownership transferred to the client.
48 virtual void requestDevice(const WebRequestDeviceOptions&, WebBluetoothRequestDeviceCallbacks*) { }
50 // BluetoothDevice methods:
51 // See https://webbluetoothchrome.github.io/web-bluetooth/#idl-def-bluetoothdevice
52 // WebBluetoothConnectGATTCallbacks ownership transferred to the callee.
53 virtual void connectGATT(const WebString& /* deviceInstanceID */,
54 WebBluetoothConnectGATTCallbacks*) { }
56 // BluetoothGATTRemoteServer methods:
57 // See https://webbluetoothchrome.github.io/web-bluetooth/#idl-def-bluetoothgattremoteserver
58 virtual void disconnect() { }
59 virtual void getPrimaryService(const WebString& deviceInstanceID,
60 const WebString& serviceUUID,
61 WebBluetoothGetPrimaryServiceCallbacks*) { }
62 // virtual void getPrimaryServices() { }
64 // BluetoothGATTService methods:
65 // See https://webbluetoothchrome.github.io/web-bluetooth/#idl-def-bluetoothgattservice
66 virtual void getCharacteristic(const WebString& serviceInstanceID,
67 const WebString& characteristicUUID,
68 WebBluetoothGetCharacteristicCallbacks*) { }
70 // BluetoothGATTCharacteristic methods:
71 // See https://webbluetoothchrome.github.io/web-bluetooth/#bluetoothgattcharacteristic
72 virtual void readValue(const WebString& characteristicInstanceID,
73 WebBluetoothReadValueCallbacks*) { }
74 virtual void writeValue(const WebString& characteristicInstanceID,
75 const std::vector<uint8_t>& value,
76 WebBluetoothWriteValueCallbacks*) { }
79 } // namespace blink
81 #endif // WebBluetooth_h