ml: Add Clone method
MachineLearningServiceImpl gains a separate BindingSet for cloned
connections. Unlike the primordial D-Bus connection, the ml_service
won't quit if these connections are closed.
This CL is part of the work to allow Chrome-side clients to get their
own bound MachineLearningServicePtrs (on a thread of their choice).
BUG=chromium:916760
TEST=Added new unit tests, ebuild ... clean test
Change-Id: I58f58848ee97e802571dbef2f8464fde0fa2492a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2289231
Tested-by: Andrew Moylan <amoylan@chromium.org>
Reviewed-by: Honglin Yu <honglinyu@chromium.org>
Commit-Queue: Andrew Moylan <amoylan@chromium.org>
diff --git a/ml/machine_learning_service_impl.cc b/ml/machine_learning_service_impl.cc
index ca05dfd..84d992b 100644
--- a/ml/machine_learning_service_impl.cc
+++ b/ml/machine_learning_service_impl.cc
@@ -36,6 +36,7 @@
using ::chromeos::machine_learning::mojom::HandwritingRecognizerSpec;
using ::chromeos::machine_learning::mojom::HandwritingRecognizerSpecPtr;
using ::chromeos::machine_learning::mojom::LoadModelResult;
+using ::chromeos::machine_learning::mojom::MachineLearningServiceRequest;
using ::chromeos::machine_learning::mojom::ModelRequest;
constexpr char kSystemModelDir[] = "/opt/google/chrome/ml_models/";
@@ -76,6 +77,10 @@
text_classifier_model_filename_ = filename;
}
+void MachineLearningServiceImpl::Clone(MachineLearningServiceRequest request) {
+ clone_bindings_.AddBinding(this, std::move(request));
+}
+
void MachineLearningServiceImpl::LoadBuiltinModel(
BuiltinModelSpecPtr spec,
ModelRequest request,