Chromium Code Reviews| Index: content/browser/bluetooth/web_bluetooth_service_impl.h |
| diff --git a/content/browser/bluetooth/web_bluetooth_service_impl.h b/content/browser/bluetooth/web_bluetooth_service_impl.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..918097ff1cdb781cac9ff5b019f2c7c941dd288c |
| --- /dev/null |
| +++ b/content/browser/bluetooth/web_bluetooth_service_impl.h |
| @@ -0,0 +1,65 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
| +#define CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |
| + |
| +#include "base/macros.h" |
| +#include "content/browser/bad_message.h" |
| +#include "content/common/content_export.h" |
| +#include "device/bluetooth/bluetooth_gatt_service.h" |
| +#include "mojo/public/cpp/bindings/binding.h" |
| +#include "third_party/WebKit/public/platform/modules/bluetooth/web_bluetooth.mojom.h" |
| + |
| +namespace url { |
| +class Origin; |
| +} // namespace url |
| + |
| +namespace content { |
| + |
| +class BluetoothDispatcherHost; |
| +class RenderFrameHost; |
| +class RenderProcessHost; |
| + |
| +class WebBluetoothServiceImpl : public blink::mojom::WebBluetoothService { |
| + public: |
| + WebBluetoothServiceImpl(RenderFrameHost* render_frame_host, |
| + blink::mojom::WebBluetoothServiceRequest request); |
| + ~WebBluetoothServiceImpl() override; |
| + |
| + private: |
| + // WebBluetoothService methods: |
| + void RemoteCharacteristicWriteValue( |
| + const mojo::String& characteristic_instance_id, |
| + mojo::Array<uint8_t> value, |
| + const RemoteCharacteristicWriteValueCallback& callback) override; |
| + |
| + // Callbacks for BluetoothGattCharacteristic::WriteRemoteCharacteristic. |
| + void OnWriteValueSuccess( |
| + const RemoteCharacteristicWriteValueCallback& callback); |
| + void OnWriteValueFailed( |
| + const RemoteCharacteristicWriteValueCallback& callback, |
| + device::BluetoothGattService::GattErrorCode error_code); |
| + |
| + BluetoothDispatcherHost* GetBluetoothDispatcherHost(); |
| + void CrashRendererAndClosePipe(bad_message::BadMessageReason reason); |
| + url::Origin GetOrigin(); |
| + |
| + RenderFrameHost* render_frame_host_; |
| + RenderProcessHost* render_process_host_; |
| + |
| + 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
|
| + |
| + // |weak_ptr_on_ui_thread_| provides weak pointers, e.g. for callbacks, and |
| + // because it exists and has been bound to the UI thread enforces that all |
| + // copies verify they are also used on the UI thread. |
| + base::WeakPtr<WebBluetoothServiceImpl> weak_ptr_on_ui_thread_; |
| + base::WeakPtrFactory<WebBluetoothServiceImpl> weak_ptr_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(WebBluetoothServiceImpl); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_BROWSER_BLUETOOTH_WEB_BLUETOOTH_SERVICE_IMPL_H_ |