| 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 25 matching lines...) Expand all Loading... |
| 36 // Implementation of Mojo WebBluetoothService located in | 36 // Implementation of Mojo WebBluetoothService located in |
| 37 // third_party/WebKit/public/platform/modules/bluetooth. | 37 // third_party/WebKit/public/platform/modules/bluetooth. |
| 38 // It handles Web Bluetooth API requests coming from Blink / renderer | 38 // It handles Web Bluetooth API requests coming from Blink / renderer |
| 39 // process and uses the platform abstraction of device/bluetooth. | 39 // process and uses the platform abstraction of device/bluetooth. |
| 40 // WebBluetoothServiceImpl is not thread-safe and should be created on the | 40 // WebBluetoothServiceImpl is not thread-safe and should be created on the |
| 41 // UI thread as required by device/bluetooth. | 41 // UI thread as required by device/bluetooth. |
| 42 // This class is instantiated on-demand via Mojo's ConnectToRemoteService | 42 // This class is instantiated on-demand via Mojo's ConnectToRemoteService |
| 43 // from the renderer when the first Web Bluetooth API request is handled. | 43 // from the renderer when the first Web Bluetooth API request is handled. |
| 44 // RenderFrameHostImpl will create an instance of this class and keep | 44 // RenderFrameHostImpl will create an instance of this class and keep |
| 45 // ownership of it. | 45 // ownership of it. |
| 46 class WebBluetoothServiceImpl : public blink::mojom::WebBluetoothService, | 46 class CONTENT_EXPORT WebBluetoothServiceImpl |
| 47 public WebContentsObserver, | 47 : public NON_EXPORTED_BASE(blink::mojom::WebBluetoothService), |
| 48 public device::BluetoothAdapter::Observer { | 48 public WebContentsObserver, |
| 49 public device::BluetoothAdapter::Observer { |
| 49 public: | 50 public: |
| 50 // |render_frame_host|: The RFH that owns this instance. | 51 // |render_frame_host|: The RFH that owns this instance. |
| 51 // |request|: The instance will be bound to this request's pipe. | 52 // |request|: The instance will be bound to this request's pipe. |
| 52 WebBluetoothServiceImpl(RenderFrameHost* render_frame_host, | 53 WebBluetoothServiceImpl(RenderFrameHost* render_frame_host, |
| 53 blink::mojom::WebBluetoothServiceRequest request); | 54 blink::mojom::WebBluetoothServiceRequest request); |
| 54 ~WebBluetoothServiceImpl() override; | 55 ~WebBluetoothServiceImpl() override; |
| 55 | 56 |
| 56 // Sets the connection error handler for WebBluetoothServiceImpl's Binding. | 57 // Sets the connection error handler for WebBluetoothServiceImpl's Binding. |
| 57 void SetClientConnectionErrorHandler(base::Closure closure); | 58 void SetClientConnectionErrorHandler(base::Closure closure); |
| 58 | 59 |
| 59 private: | 60 private: |
| 61 friend class FrameConnectedBluetoothDevicesTest; |
| 60 typedef base::Callback<void(device::BluetoothDevice*)> | 62 typedef base::Callback<void(device::BluetoothDevice*)> |
| 61 PrimaryServicesRequestCallback; | 63 PrimaryServicesRequestCallback; |
| 62 | 64 |
| 63 // WebContentsObserver: | 65 // WebContentsObserver: |
| 64 // These functions should always check that the affected RenderFrameHost | 66 // These functions should always check that the affected RenderFrameHost |
| 65 // is this->render_frame_host_ and not some other frame in the same tab. | 67 // is this->render_frame_host_ and not some other frame in the same tab. |
| 66 void DidFinishNavigation(NavigationHandle* navigation_handle) override; | 68 void DidFinishNavigation(NavigationHandle* navigation_handle) override; |
| 67 | 69 |
| 68 // BluetoothAdapter::Observer: | 70 // BluetoothAdapter::Observer: |
| 69 void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 71 void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 mojo::Binding<blink::mojom::WebBluetoothService> binding_; | 217 mojo::Binding<blink::mojom::WebBluetoothService> binding_; |
| 216 | 218 |
| 217 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; | 219 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; |
| 218 | 220 |
| 219 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); | 221 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); |
| 220 }; | 222 }; |
| 221 | 223 |
| 222 } // namespace content | 224 } // namespace content |
| 223 | 225 |
| 224 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | 226 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
| OLD | NEW |