Currently //chromeos/services/machine_learning/public/cpp/service_connection.h communications with Chrome OS's src/platform2/ml/daemon.cc via a MachineLearningService (
//chromeos/services/machine_learning/public/mojom/machine_learning_service.mojom) that is is bound via a one-off bootstrap using D-Bus.
All Chrome clients then share this bound MachineLearningServicePtr.
This is unpleasant since the Chrome clients may be on different threads. It would be better if they can each have their own MachineLearningServicePtr.
To this end, we should introduce an extra layer:
interface MachineLearningServiceBootstrap {
BindMachineLearningService(MachineLearningService& service)
}
and have one of these be the top-level link between Chrome and Chrome OS.
The "client library" in Chrome can consist of a single thread-safe function:
// Call from any sequence:
void BindMachineLearningService(mojom::MachineLearningServiceRequest request);
The existing machine_learning::ServiceConnection class would be a private implementation detail of the above function.
Later, When a Service-Manager like thing comes to Chrome OS (or when ML Service comes to non-CrOS Chrome), it can be swapped in for BindMachineLearningService easily.