| 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> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // Sets the connection error handler for WebBluetoothServiceImpl's Binding. | 53 // Sets the connection error handler for WebBluetoothServiceImpl's Binding. |
| 54 void SetClientConnectionErrorHandler(base::Closure closure); | 54 void SetClientConnectionErrorHandler(base::Closure closure); |
| 55 | 55 |
| 56 private: | 56 private: |
| 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, |
| 64 bool present) override; |
| 63 void GattCharacteristicValueChanged( | 65 void GattCharacteristicValueChanged( |
| 64 device::BluetoothAdapter* adapter, | 66 device::BluetoothAdapter* adapter, |
| 65 device::BluetoothGattCharacteristic* characteristic, | 67 device::BluetoothGattCharacteristic* characteristic, |
| 66 const std::vector<uint8_t>& value) override; | 68 const std::vector<uint8_t>& value) override; |
| 67 | 69 |
| 68 // Notifies the WebBluetoothServiceClient that characteristic | 70 // Notifies the WebBluetoothServiceClient that characteristic |
| 69 // |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 |
| 70 // characteristics that have been returned to the client in the past. | 72 // characteristics that have been returned to the client in the past. |
| 71 void NotifyCharacteristicValueChanged( | 73 void NotifyCharacteristicValueChanged( |
| 72 const std::string& characteristic_instance_id, | 74 const std::string& characteristic_instance_id, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 // Callback for BluetoothGattNotifySession::Stop. | 118 // Callback for BluetoothGattNotifySession::Stop. |
| 117 void OnStopNotifySessionComplete( | 119 void OnStopNotifySessionComplete( |
| 118 const std::string& characteristic_instance_id, | 120 const std::string& characteristic_instance_id, |
| 119 const RemoteCharacteristicStopNotificationsCallback& callback); | 121 const RemoteCharacteristicStopNotificationsCallback& callback); |
| 120 | 122 |
| 121 RenderProcessHost* GetRenderProcessHost(); | 123 RenderProcessHost* GetRenderProcessHost(); |
| 122 BluetoothDispatcherHost* GetBluetoothDispatcherHost(); | 124 BluetoothDispatcherHost* GetBluetoothDispatcherHost(); |
| 123 void CrashRendererAndClosePipe(bad_message::BadMessageReason reason); | 125 void CrashRendererAndClosePipe(bad_message::BadMessageReason reason); |
| 124 url::Origin GetOrigin(); | 126 url::Origin GetOrigin(); |
| 125 | 127 |
| 126 // All state (maps, sets, etc.) should be cleaned after navigations | 128 // Clears all state (maps, sets, etc). |
| 127 // that are not in the same page. | 129 void ClearState(); |
| 128 | 130 |
| 129 // Map to keep track of the characteristics' notify sessions. | 131 // Map to keep track of the characteristics' notify sessions. |
| 130 std::unordered_map<std::string, | 132 std::unordered_map<std::string, |
| 131 std::unique_ptr<device::BluetoothGattNotifySession>> | 133 std::unique_ptr<device::BluetoothGattNotifySession>> |
| 132 characteristic_id_to_notify_session_; | 134 characteristic_id_to_notify_session_; |
| 133 | 135 |
| 134 // The RFH that owns this instance. | 136 // The RFH that owns this instance. |
| 135 RenderFrameHost* render_frame_host_; | 137 RenderFrameHost* render_frame_host_; |
| 136 | 138 |
| 137 // Proxy to the WebBluetoothServiceClient to send device events to. | 139 // Proxy to the WebBluetoothServiceClient to send device events to. |
| 138 blink::mojom::WebBluetoothServiceClientAssociatedPtr client_; | 140 blink::mojom::WebBluetoothServiceClientAssociatedPtr client_; |
| 139 | 141 |
| 140 // The lifetime of this instance is exclusively managed by the RFH that | 142 // The lifetime of this instance is exclusively managed by the RFH that |
| 141 // owns it so we use a "Binding" as opposed to a "StrongBinding" which deletes | 143 // owns it so we use a "Binding" as opposed to a "StrongBinding" which deletes |
| 142 // the service on pipe connection errors. | 144 // the service on pipe connection errors. |
| 143 mojo::Binding<blink::mojom::WebBluetoothService> binding_; | 145 mojo::Binding<blink::mojom::WebBluetoothService> binding_; |
| 144 | 146 |
| 145 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; | 147 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; |
| 146 | 148 |
| 147 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); | 149 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); |
| 148 }; | 150 }; |
| 149 | 151 |
| 150 } // namespace content | 152 } // namespace content |
| 151 | 153 |
| 152 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | 154 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
| OLD | NEW |