ml: Switch to new Mojo types

Migrate from &, Request, etc to pending_receiver, etc, now that these
are supported in libchrome.

This includes migrating from "connection error" to "disconnection"
terminology that Mojo switched to (since disconnection is not always
error).

BUG=chromium:1103123
TEST=ebuild bla/ml-9999.ebuild clean test
TEST=tast -verbose run bla platform.MLServiceBootstrap power.SmartDim

Change-Id: I015e116442281cbda313eb8d0593bb543090008c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2289245
Tested-by: Andrew Moylan <amoylan@chromium.org>
Auto-Submit: Andrew Moylan <amoylan@chromium.org>
Reviewed-by: Honglin Yu <honglinyu@chromium.org>
Reviewed-by: Sam McNally <sammc@chromium.org>
Reviewed-by: Thanh Nguyen <thanhdng@chromium.org>
Commit-Queue: Andrew Moylan <amoylan@chromium.org>
diff --git a/ml/graph_executor_impl.h b/ml/graph_executor_impl.h
index 7f3f2ad..f5e9bd4 100644
--- a/ml/graph_executor_impl.h
+++ b/ml/graph_executor_impl.h
@@ -13,7 +13,8 @@
 #include <base/callback_forward.h>
 #include <base/containers/flat_map.h>
 #include <base/macros.h>
-#include <mojo/public/cpp/bindings/binding.h>
+#include <mojo/public/cpp/bindings/pending_receiver.h>
+#include <mojo/public/cpp/bindings/receiver.h>
 #include <tensorflow/lite/model.h>
 
 #include "ml/mojom/graph_executor.mojom.h"
@@ -32,7 +33,7 @@
 class GraphExecutorImpl
     : public chromeos::machine_learning::mojom::GraphExecutor {
  public:
-  // Creates an instance bound to `request`.
+  // Creates an instance bound to `receiver`.
   //
   // The `required_inputs` and `required_outputs` arguments specify a mapping
   // from required input / output tensor names to their indices in the TF lite
@@ -46,10 +47,11 @@
       const std::map<std::string, int>& required_inputs,
       const std::map<std::string, int>& required_outputs,
       std::unique_ptr<tflite::Interpreter> interpreter,
-      chromeos::machine_learning::mojom::GraphExecutorRequest request,
+      mojo::PendingReceiver<chromeos::machine_learning::mojom::GraphExecutor>
+          receiver,
       const std::string& metrics_model_name);
 
-  void set_connection_error_handler(base::Closure connection_error_handler);
+  void set_disconnect_handler(base::Closure disconnect_handler);
 
  private:
   // chromeos::machine_learning::mojom::GraphExecutor:
@@ -64,7 +66,7 @@
 
   const std::unique_ptr<tflite::Interpreter> interpreter_;
 
-  mojo::Binding<chromeos::machine_learning::mojom::GraphExecutor> binding_;
+  mojo::Receiver<chromeos::machine_learning::mojom::GraphExecutor> receiver_;
 
   // Model name as it should appear in UMA histogram names.
   const std::string metrics_model_name_;