 Chromium Code Reviews
 Chromium Code Reviews Issue 2718583002:
  Refactor WebBluetoothServiceClient in the web_bluetooth.mojom  (Closed)
    
  
    Issue 2718583002:
  Refactor WebBluetoothServiceClient in the web_bluetooth.mojom  (Closed) 
  | 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 e8bfd64563bdf251b212300efc866d168e273907..ef197ba91da1e9a084eadc6d53687059ab40b55b 100644 | 
| --- a/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp | 
| +++ b/third_party/WebKit/Source/modules/bluetooth/BluetoothDevice.cpp | 
| @@ -76,27 +76,14 @@ bool BluetoothDevice::isValidDescriptor(const String& descriptorInstanceId) { | 
| } | 
| void BluetoothDevice::dispose() { | 
| 
ortuno
2017/03/01 04:52:06
Let's just do both on BluetoothRemoteGATTServer.
 
juncai
2017/03/02 03:23:47
Done.
 
ortuno
2017/03/06 11:31:20
Also add contextDestroyed to BluetoothRemoteGATTSe
 
juncai
2017/03/09 07:30:57
Done.
 | 
| - disconnectGATTIfConnected(); | 
| + m_gatt->disconnectIfConnected(); | 
| } | 
| void BluetoothDevice::contextDestroyed(ExecutionContext*) { | 
| - disconnectGATTIfConnected(); | 
| + m_gatt->disconnectIfConnected(); | 
| } | 
| -void BluetoothDevice::disconnectGATTIfConnected() { | 
| - if (m_gatt->connected()) { | 
| - m_gatt->setConnected(false); | 
| - m_gatt->ClearActiveAlgorithms(); | 
| - m_bluetooth->removeFromConnectedDevicesMap(id()); | 
| - mojom::blink::WebBluetoothService* service = m_bluetooth->service(); | 
| - service->RemoteServerDisconnect(id()); | 
| - } | 
| -} | 
| - | 
| -void BluetoothDevice::cleanupDisconnectedDeviceAndFireEvent() { | 
| - DCHECK(m_gatt->connected()); | 
| - m_gatt->setConnected(false); | 
| - m_gatt->ClearActiveAlgorithms(); | 
| +void BluetoothDevice::clearAttributeInstanceMapAndFireEvent() { | 
| m_attributeInstanceMap->Clear(); | 
| dispatchEvent(Event::createBubble(EventTypeNames::gattserverdisconnected)); | 
| } | 
| @@ -109,13 +96,6 @@ ExecutionContext* BluetoothDevice::getExecutionContext() const { | 
| return ContextLifecycleObserver::getExecutionContext(); | 
| } | 
| -void BluetoothDevice::dispatchGattServerDisconnected() { | 
| - if (!m_gatt->connected()) { | 
| - return; | 
| - } | 
| - cleanupDisconnectedDeviceAndFireEvent(); | 
| -} | 
| - | 
| DEFINE_TRACE(BluetoothDevice) { | 
| visitor->trace(m_attributeInstanceMap); | 
| visitor->trace(m_gatt); |