Chromium Code Reviews| Index: third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp |
| diff --git a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp |
| index edf8326abf33722fa21ff893961af5ea1d5c2988..bfca397ca1707d3760f89d5d66d3760bd4193359 100644 |
| --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp |
| +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp |
| @@ -9,39 +9,43 @@ |
| #include "bindings/core/v8/ScriptPromiseResolver.h" |
| #include "core/dom/DOMException.h" |
| #include "core/events/Event.h" |
| +#include "modules/bluetooth/Bluetooth.h" |
| #include "modules/bluetooth/BluetoothAttributeInstanceMap.h" |
| #include "modules/bluetooth/BluetoothError.h" |
| #include "modules/bluetooth/BluetoothRemoteGATTServer.h" |
| -#include "modules/bluetooth/BluetoothSupplement.h" |
| -#include "public/platform/modules/bluetooth/WebBluetooth.h" |
| -#include "public/platform/modules/bluetooth/WebBluetoothRemoteGATTCharacteristicInit.h" |
| +#include "public/platform/modules/bluetooth/web_bluetooth.mojom-blink.h" |
| #include <memory> |
| #include <utility> |
| namespace blink { |
| -BluetoothDevice::BluetoothDevice( |
| - ExecutionContext* context, |
| - std::unique_ptr<WebBluetoothDeviceInit> webDevice) |
| +BluetoothDevice::BluetoothDevice(ExecutionContext* context, |
| + const String& id, |
| + const String& name, |
| + Bluetooth* bluetooth) |
| : ContextLifecycleObserver(context), |
| m_attributeInstanceMap(new BluetoothAttributeInstanceMap(this)), |
| - m_webDevice(std::move(webDevice)), |
| - m_gatt(BluetoothRemoteGATTServer::create(this)) { |
| -} |
| - |
| -BluetoothDevice* BluetoothDevice::take( |
| - ScriptPromiseResolver* resolver, |
| - std::unique_ptr<WebBluetoothDeviceInit> webDevice) { |
| - ASSERT(webDevice); |
| - return new BluetoothDevice(resolver->getExecutionContext(), |
| - std::move(webDevice)); |
| + m_id(id), |
| + m_name(name), |
| + m_gatt(BluetoothRemoteGATTServer::create(this)), |
| + m_bluetooth(bluetooth) {} |
| + |
| +BluetoothDevice* BluetoothDevice::take(ScriptPromiseResolver* resolver, |
| + const String& id, |
| + const String& name, |
| + Bluetooth* bluetooth) { |
| + return new BluetoothDevice(resolver->getExecutionContext(), id, name, |
| + bluetooth); |
| } |
| BluetoothRemoteGATTService* |
| BluetoothDevice::getOrCreateBluetoothRemoteGATTService( |
| - std::unique_ptr<WebBluetoothRemoteGATTService> webService) { |
| + const String& serviceInstanceId, |
| + const String& uuid, |
| + bool isPrimary, |
| + const String& deviceInstanceId) { |
| return m_attributeInstanceMap->getOrCreateBluetoothRemoteGATTService( |
| - std::move(webService)); |
| + serviceInstanceId, uuid, isPrimary, deviceInstanceId); |
| } |
| bool BluetoothDevice::isValidService(const String& serviceInstanceId) { |
| @@ -51,10 +55,14 @@ bool BluetoothDevice::isValidService(const String& serviceInstanceId) { |
| BluetoothRemoteGATTCharacteristic* |
| BluetoothDevice::getOrCreateBluetoothRemoteGATTCharacteristic( |
| ExecutionContext* context, |
| - std::unique_ptr<WebBluetoothRemoteGATTCharacteristicInit> webCharacteristic, |
| + const String& characteristicInstanceId, |
| + const String& serviceInstanceId, |
| + const String& uuid, |
| + uint32_t characteristicProperties, |
| BluetoothRemoteGATTService* service) { |
| return m_attributeInstanceMap->getOrCreateBluetoothRemoteGATTCharacteristic( |
| - context, std::move(webCharacteristic), service); |
| + context, characteristicInstanceId, serviceInstanceId, uuid, |
| + characteristicProperties, service); |
| } |
| bool BluetoothDevice::isValidCharacteristic( |
| @@ -75,8 +83,12 @@ void BluetoothDevice::disconnectGATTIfConnected() { |
| if (m_gatt->connected()) { |
| m_gatt->setConnected(false); |
| m_gatt->ClearActiveAlgorithms(); |
| - BluetoothSupplement::fromExecutionContext(getExecutionContext()) |
| - ->disconnect(id()); |
| + m_bluetooth->removeDevice(id()); |
| + mojom::blink::WebBluetoothService* service = m_bluetooth->service(); |
| + mojom::blink::WebBluetoothDeviceIdPtr deviceIdPtr = |
| + mojom::blink::WebBluetoothDeviceId::New(); |
|
Reilly Grant (use Gerrit)
2016/12/16 01:41:29
auto deviceId = mojom::blink::WebBluetoothDeviceId
juncai
2016/12/17 01:18:52
Done.
|
| + deviceIdPtr->device_id = id(); |
| + service->RemoteServerDisconnect(std::move(deviceIdPtr)); |
| } |
| } |
| @@ -108,6 +120,7 @@ DEFINE_TRACE(BluetoothDevice) { |
| ContextLifecycleObserver::trace(visitor); |
| visitor->trace(m_attributeInstanceMap); |
| visitor->trace(m_gatt); |
| + visitor->trace(m_bluetooth); |
| } |
| } // namespace blink |