Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | |
| 6 #define CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | |
| 7 | |
| 8 #include "base/macros.h" | |
| 9 #include "content/browser/bad_message.h" | |
| 10 #include "content/common/content_export.h" | |
| 11 #include "device/bluetooth/bluetooth_gatt_service.h" | |
| 12 #include "mojo/public/cpp/bindings/binding.h" | |
| 13 #include "third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.moj om.h" | |
| 14 | |
| 15 namespace url { | |
| 16 class Origin; | |
| 17 } // namespace url | |
| 18 | |
| 19 namespace content { | |
| 20 | |
| 21 class BluetoothDispatcherHost; | |
| 22 class RenderFrameHost; | |
| 23 class RenderProcessHost; | |
| 24 | |
| 25 class WebBluetoothServiceImpl : public blink::mojom::WebBluetoothService { | |
| 26 public: | |
| 27 WebBluetoothServiceImpl(RenderFrameHost* render_frame_host, | |
| 28 blink::mojom::WebBluetoothServiceRequest request); | |
| 29 ~WebBluetoothServiceImpl() override; | |
| 30 | |
| 31 private: | |
| 32 // WebBluetoothService methods: | |
| 33 void RemoteCharacteristicWriteValue( | |
| 34 const mojo::String& characteristic_instance_id, | |
| 35 mojo::Array<uint8_t> value, | |
| 36 const RemoteCharacteristicWriteValueCallback& callback) override; | |
| 37 | |
| 38 // Callbacks for BluetoothGattCharacteristic::WriteRemoteCharacteristic. | |
| 39 void OnWriteValueSuccess( | |
| 40 const RemoteCharacteristicWriteValueCallback& callback); | |
| 41 void OnWriteValueFailed( | |
| 42 const RemoteCharacteristicWriteValueCallback& callback, | |
| 43 device::BluetoothGattService::GattErrorCode error_code); | |
| 44 | |
| 45 BluetoothDispatcherHost* GetBluetoothDispatcherHost(); | |
| 46 void CrashRendererAndClosePipe(bad_message::BadMessageReason reason); | |
| 47 url::Origin GetOrigin(); | |
| 48 | |
| 49 RenderFrameHost* render_frame_host_; | |
| 50 RenderProcessHost* render_process_host_; | |
| 51 | |
| 52 mojo::Binding<blink::mojom::WebBluetoothService> binding_; | |
|
Jeffrey Yasskin
2016/03/25 00:48:23
Why is this just a 'Binding' while the testing ser
ortuno
2016/03/29 17:58:34
StrongBinding will delete the service if the conne
| |
| 53 | |
| 54 // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and | |
| 55 // because it exists and has been bound to the UI thread enforces that all | |
| 56 // copies verify they are also used on the UI thread. | |
| 57 base::WeakPtr<WebBluetoothServiceImpl> weak_ptr_on_ui_thread_; | |
| 58 base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; | |
| 59 | |
| 60 DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); | |
| 61 }; | |
| 62 | |
| 63 } // namespace content | |
| 64 | |
| 65 #endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ | |
| OLD | NEW |