OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
6 #define CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | 6 #define CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "content/browser/bad_message.h" | 13 #include "content/browser/bad_message.h" |
14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
15 #include "content/public/browser/web_contents_observer.h" | 15 #include "content/public/browser/web_contents_observer.h" |
16 #include "device/bluetooth/bluetooth_adapter.h" | 16 #include "device/bluetooth/bluetooth_adapter.h" |
17 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | |
18 #include "device/bluetooth/bluetooth_gatt_notify_session.h" | 17 #include "device/bluetooth/bluetooth_gatt_notify_session.h" |
19 #include "device/bluetooth/bluetooth_gatt_service.h" | 18 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| 19 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
20 #include "mojo/public/cpp/bindings/binding.h" | 20 #include "mojo/public/cpp/bindings/binding.h" |
21 #include "third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.moj
om.h" | 21 #include "third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.moj
om.h" |
22 | 22 |
23 namespace url { | 23 namespace url { |
24 class Origin; | 24 class Origin; |
25 } // namespace url | 25 } // namespace url |
26 | 26 |
27 namespace content { | 27 namespace content { |
28 | 28 |
29 class BluetoothDispatcherHost; | 29 class BluetoothDispatcherHost; |
(...skipping 27 matching lines...) Expand all Loading... |
57 // WebContentsObserver: | 57 // WebContentsObserver: |
58 // These functions should always check that the affected RenderFrameHost | 58 // These functions should always check that the affected RenderFrameHost |
59 // is this->render_frame_host_ and not some other frame in the same tab. | 59 // is this->render_frame_host_ and not some other frame in the same tab. |
60 void DidFinishNavigation(NavigationHandle* navigation_handle) override; | 60 void DidFinishNavigation(NavigationHandle* navigation_handle) override; |
61 | 61 |
62 // BluetoothAdapter::Observer: | 62 // BluetoothAdapter::Observer: |
63 void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 63 void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
64 bool present) override; | 64 bool present) override; |
65 void GattCharacteristicValueChanged( | 65 void GattCharacteristicValueChanged( |
66 device::BluetoothAdapter* adapter, | 66 device::BluetoothAdapter* adapter, |
67 device::BluetoothGattCharacteristic* characteristic, | 67 device::BluetoothRemoteGattCharacteristic* characteristic, |
68 const std::vector<uint8_t>& value) override; | 68 const std::vector<uint8_t>& value) override; |
69 | 69 |
70 // Notifies the WebBluetoothServiceClient that characteristic | 70 // Notifies the WebBluetoothServiceClient that characteristic |
71 // |characteristic_instance_id| changed it's value. We only do this for | 71 // |characteristic_instance_id| changed it's value. We only do this for |
72 // characteristics that have been returned to the client in the past. | 72 // characteristics that have been returned to the client in the past. |
73 void NotifyCharacteristicValueChanged( | 73 void NotifyCharacteristicValueChanged( |
74 const std::string& characteristic_instance_id, | 74 const std::string& characteristic_instance_id, |
75 std::vector<uint8_t> value); | 75 std::vector<uint8_t> value); |
76 | 76 |
77 // WebBluetoothService methods: | 77 // WebBluetoothService methods: |
78 void SetClient( | 78 void SetClient( |
79 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo client) override; | 79 blink::mojom::WebBluetoothServiceClientAssociatedPtrInfo client) override; |
80 | 80 |
81 // WebBluetoothService methods: | 81 // WebBluetoothService methods: |
82 void RemoteCharacteristicReadValue( | 82 void RemoteCharacteristicReadValue( |
83 const mojo::String& characteristic_instance_id, | 83 const mojo::String& characteristic_instance_id, |
84 const RemoteCharacteristicReadValueCallback& callback) override; | 84 const RemoteCharacteristicReadValueCallback& callback) override; |
85 void RemoteCharacteristicWriteValue( | 85 void RemoteCharacteristicWriteValue( |
86 const mojo::String& characteristic_instance_id, | 86 const mojo::String& characteristic_instance_id, |
87 mojo::Array<uint8_t> value, | 87 mojo::Array<uint8_t> value, |
88 const RemoteCharacteristicWriteValueCallback& callback) override; | 88 const RemoteCharacteristicWriteValueCallback& callback) override; |
89 void RemoteCharacteristicStartNotifications( | 89 void RemoteCharacteristicStartNotifications( |
90 const mojo::String& characteristic_instance_id, | 90 const mojo::String& characteristic_instance_id, |
91 const RemoteCharacteristicStartNotificationsCallback& callback) override; | 91 const RemoteCharacteristicStartNotificationsCallback& callback) override; |
92 void RemoteCharacteristicStopNotifications( | 92 void RemoteCharacteristicStopNotifications( |
93 const mojo::String& characteristic_instance_id, | 93 const mojo::String& characteristic_instance_id, |
94 const RemoteCharacteristicStopNotificationsCallback& callback) override; | 94 const RemoteCharacteristicStopNotificationsCallback& callback) override; |
95 | 95 |
96 // Callbacks for BluetoothGattCharacteristic::ReadRemoteCharacteristic. | 96 // Callbacks for BluetoothRemoteGattCharacteristic::ReadRemoteCharacteristic. |
97 void OnReadValueSuccess(const RemoteCharacteristicReadValueCallback& callback, | 97 void OnReadValueSuccess(const RemoteCharacteristicReadValueCallback& callback, |
98 const std::vector<uint8_t>& value); | 98 const std::vector<uint8_t>& value); |
99 void OnReadValueFailed( | 99 void OnReadValueFailed( |
100 const RemoteCharacteristicReadValueCallback& callback, | 100 const RemoteCharacteristicReadValueCallback& callback, |
101 device::BluetoothGattService::GattErrorCode error_code); | 101 device::BluetoothRemoteGattService::GattErrorCode error_code); |
102 | 102 |
103 // Callbacks for BluetoothGattCharacteristic::WriteRemoteCharacteristic. | 103 // Callbacks for BluetoothRemoteGattCharacteristic::WriteRemoteCharacteristic. |
104 void OnWriteValueSuccess( | 104 void OnWriteValueSuccess( |
105 const RemoteCharacteristicWriteValueCallback& callback); | 105 const RemoteCharacteristicWriteValueCallback& callback); |
106 void OnWriteValueFailed( | 106 void OnWriteValueFailed( |
107 const RemoteCharacteristicWriteValueCallback& callback, | 107 const RemoteCharacteristicWriteValueCallback& callback, |
108 device::BluetoothGattService::GattErrorCode error_code); | 108 device::BluetoothRemoteGattService::GattErrorCode error_code); |
109 | 109 |
110 // Callbacks for BluetoothGattCharacteristic::StartNotifySession. | 110 // Callbacks for BluetoothRemoteGattCharacteristic::StartNotifySession. |
111 void OnStartNotifySessionSuccess( | 111 void OnStartNotifySessionSuccess( |
112 const RemoteCharacteristicStartNotificationsCallback& callback, | 112 const RemoteCharacteristicStartNotificationsCallback& callback, |
113 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); | 113 std::unique_ptr<device::BluetoothGattNotifySession> notify_session); |
114 void OnStartNotifySessionFailed( | 114 void OnStartNotifySessionFailed( |
115 const RemoteCharacteristicStartNotificationsCallback& callback, | 115 const RemoteCharacteristicStartNotificationsCallback& callback, |
116 device::BluetoothGattService::GattErrorCode error_code); | 116 device::BluetoothRemoteGattService::GattErrorCode error_code); |
117 | 117 |
118 // Callback for BluetoothGattNotifySession::Stop. | 118 // Callback for BluetoothGattNotifySession::Stop. |
119 void OnStopNotifySessionComplete( | 119 void OnStopNotifySessionComplete( |
120 const std::string& characteristic_instance_id, | 120 const std::string& characteristic_instance_id, |
121 const RemoteCharacteristicStopNotificationsCallback& callback); | 121 const RemoteCharacteristicStopNotificationsCallback& callback); |
122 | 122 |
123 RenderProcessHost* GetRenderProcessHost(); | 123 RenderProcessHost* GetRenderProcessHost(); |
124 BluetoothDispatcherHost* GetBluetoothDispatcherHost(); | 124 BluetoothDispatcherHost* GetBluetoothDispatcherHost(); |
125 void CrashRendererAndClosePipe(bad_message::BadMessageReason reason); | 125 void CrashRendererAndClosePipe(bad_message::BadMessageReason reason); |
126 url::Origin GetOrigin(); | 126 url::Origin GetOrigin(); |
(...skipping 18 matching lines...) Expand all Loading... |
145 mojo::Binding<blink::mojom::WebBluetoothService> binding_; | 145 mojo::Binding<blink::mojom::WebBluetoothService> binding_; |
146 | 146 |
147 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; | 147 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; |
148 | 148 |
149 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); | 149 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); |
150 }; | 150 }; |
151 | 151 |
152 } // namespace content | 152 } // namespace content |
153 | 153 |
154 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | 154 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
OLD | NEW |