WebBluetoothServiceClient is only used in interface
WebBluetoothService's SetClient which comments that
"Sets the client for this WebBluetoothService."
It is always 1:1. dcheng requested in https://codereview.chromium.org/2635473004/
that we explore making sure this invariant always holds.
The current way to do that is using a factory interface,
though Mojo may explore alternatives if there's enough demand
See https://groups.google.com/a/chromium.org/forum/#!topic/chromium-mojo/j-kiK17V-Qc
I don't mind the Factory pattern but I wonder if we are really going to keep the current form for our client interface. More specifically, would more specialized clients make more sense?
We currently hold two maps in Bluetooth: m_connectedDevices and m_activeCharacteristics. When we get a response for connection/startNotifications, we add the device/characteristic to the respective map. When we receive an event on the client interface we have to first look for the device/characteristic in the map and then dispatch the event to that device/characteristic.
This seems unnecessary. We could instead return a pipe in the connect and startNotifications callbacks and have the BluetoothDevice and BluetoothRemoteGATTCharacteristic hold the references to those pipes. Then the events would be dispatched to the respective objects directly and we would avoid that lookup.
Comment 1 by scheib@chromium.org
, Jan 18 2017