Chromium Code Reviews| Index: third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp |
| diff --git a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp |
| index b28791ac4230a57bc40261193f3c5eee41baac04..e780d8db03e5a599b987d382ce1963b65f6af40e 100644 |
| --- a/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp |
| +++ b/third_party/WebKit/Source/modules/bluetooth/Bluetooth.cpp |
| @@ -160,8 +160,8 @@ void Bluetooth::RequestDeviceCallback( |
| return; |
| if (result == mojom::blink::WebBluetoothResult::SUCCESS) { |
| - BluetoothDevice* bluetoothDevice = getBluetoothDeviceRepresentingDevice( |
| - device->id->device_id, device->name, resolver); |
| + BluetoothDevice* bluetoothDevice = |
| + getBluetoothDeviceRepresentingDevice(std::move(device), resolver); |
| resolver->resolve(bluetoothDevice); |
| } else { |
| resolver->reject(BluetoothError::take(resolver, result)); |
| @@ -236,6 +236,7 @@ ScriptPromise Bluetooth::requestDevice(ScriptState* scriptState, |
| convertToBaseCallback(WTF::bind(&Bluetooth::RequestDeviceCallback, |
| wrapPersistent(this), |
| wrapPersistent(resolver)))); |
| + |
|
scheib
2017/01/07 01:25:53
nit: avoid whitespace changes
juncai
2017/01/09 20:25:50
Done.
|
| return promise; |
| } |
| @@ -275,29 +276,28 @@ void Bluetooth::RemoteCharacteristicValueChanged( |
| characteristic->dispatchCharacteristicValueChanged(value); |
| } |
| -void Bluetooth::GattServerDisconnected( |
| - mojom::blink::WebBluetoothDeviceIdPtr deviceId) { |
| - BluetoothDevice* device = m_connectedDevices.get(deviceId->device_id); |
| +void Bluetooth::GattServerDisconnected(const WTF::String& deviceId) { |
| + BluetoothDevice* device = m_connectedDevices.get(deviceId); |
| if (device) { |
| // Remove device from the map before calling dispatchGattServerDisconnected |
| // to avoid removing a device the gattserverdisconnected event handler might |
| // have re-connected. |
| - m_connectedDevices.remove(deviceId->device_id); |
| + m_connectedDevices.remove(deviceId); |
| device->dispatchGattServerDisconnected(); |
| } |
| } |
| BluetoothDevice* Bluetooth::getBluetoothDeviceRepresentingDevice( |
| - const String& id, |
| - const String& name, |
| + mojom::blink::WebBluetoothDevicePtr device, |
|
scheib
2017/01/07 01:25:53
I recommend renaming the parameter 'device_ptr' an
juncai
2017/01/09 20:25:50
Done.
|
| ScriptPromiseResolver* resolver) { |
| - BluetoothDevice* device = m_deviceInstanceMap.get(id); |
| - if (!device) { |
| - device = BluetoothDevice::take(resolver, id, name, this); |
| - auto result = m_deviceInstanceMap.add(id, device); |
| + WTF::String id = device->id; |
| + BluetoothDevice* bluetoothDevice = m_deviceInstanceMap.get(id); |
| + if (!bluetoothDevice) { |
| + bluetoothDevice = BluetoothDevice::take(resolver, std::move(device), this); |
| + auto result = m_deviceInstanceMap.add(id, bluetoothDevice); |
| DCHECK(result.isNewEntry); |
| } |
| - return device; |
| + return bluetoothDevice; |
| } |
| } // namespace blink |