1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef MEDIA_LEARNING_MOJO_PUBLIC_CPP_MOJO_LEARNING_TASK_CONTROLLER_H_
6 #define MEDIA_LEARNING_MOJO_PUBLIC_CPP_MOJO_LEARNING_TASK_CONTROLLER_H_
7 
8 #include <utility>
9 
10 #include "base/component_export.h"
11 #include "base/macros.h"
12 #include "media/learning/common/learning_task_controller.h"
13 #include "media/learning/mojo/public/mojom/learning_task_controller.mojom.h"
14 #include "mojo/public/cpp/bindings/remote.h"
15 
16 namespace media {
17 namespace learning {
18 
19 // LearningTaskController implementation to forward to a remote impl via mojo.
COMPONENT_EXPORT(MEDIA_LEARNING_MOJO)20 class COMPONENT_EXPORT(MEDIA_LEARNING_MOJO) MojoLearningTaskController
21     : public LearningTaskController {
22  public:
23   // |task| will be provided by GetLearningTask().  Hopefully, it matches
24   // whatever |controller| uses.
25   MojoLearningTaskController(
26       const LearningTask& task,
27       mojo::Remote<mojom::LearningTaskController> controller);
28   ~MojoLearningTaskController() override;
29 
30   // LearningTaskController
31   void BeginObservation(
32       base::UnguessableToken id,
33       const FeatureVector& features,
34       const base::Optional<TargetValue>& default_target,
35       const base::Optional<ukm::SourceId>& source_id) override;
36   void CompleteObservation(base::UnguessableToken id,
37                            const ObservationCompletion& completion) override;
38   void CancelObservation(base::UnguessableToken id) override;
39   void UpdateDefaultTarget(
40       base::UnguessableToken id,
41       const base::Optional<TargetValue>& default_target) override;
42   const LearningTask& GetLearningTask() override;
43   void PredictDistribution(const FeatureVector& features,
44                            PredictionCB callback) override;
45 
46  private:
47   LearningTask task_;
48   mojo::Remote<mojom::LearningTaskController> controller_;
49 
50   DISALLOW_COPY_AND_ASSIGN(MojoLearningTaskController);
51 };
52 
53 }  // namespace learning
54 }  // namespace media
55 
56 #endif  // MEDIA_LEARNING_MOJO_PUBLIC_CPP_MOJO_LEARNING_TASK_CONTROLLER_H_
57