Commit f3426705 authored by Andrew Moylan's avatar Andrew Moylan Committed by Commit Bot

Remove ModelProvider Mojo interface

We are collapsing the ModelProvider interface into the top-level
MachineLearningService interface. ModelProvider's sole method LoadModel
becomes a method of MachineLearningService.

This reflects the corresponding Chromium OS change: crrev.com/c/1158091.
(The changes are safe to perform simultaneously as no clients call this
interface yet.)

Bug: 836095
Change-Id: Ia30be3ff176a72f2873c589ad1bc8e5c53248031
Reviewed-on: https://chromium-review.googlesource.com/1160138Reviewed-by: default avatarMichael Martis <martis@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Commit-Queue: Andrew Moylan <amoylan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580401}
parent 3fba843d
...@@ -21,10 +21,11 @@ ServiceConnection* ServiceConnection::GetInstance() { ...@@ -21,10 +21,11 @@ ServiceConnection* ServiceConnection::GetInstance() {
return service_connection.get(); return service_connection.get();
} }
void ServiceConnection::BindModelProvider(mojom::ModelProviderRequest request) { void ServiceConnection::LoadModel(mojom::ModelSpecPtr spec,
mojom::ModelRequest request) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
BindMachineLearningServiceIfNeeded(); BindMachineLearningServiceIfNeeded();
machine_learning_service_->GetModelProvider(std::move(request)); machine_learning_service_->LoadModel(std::move(spec), std::move(request));
} }
void ServiceConnection::BindMachineLearningServiceIfNeeded() { void ServiceConnection::BindMachineLearningServiceIfNeeded() {
......
...@@ -16,18 +16,20 @@ namespace machine_learning { ...@@ -16,18 +16,20 @@ namespace machine_learning {
// Encapsulates a connection to the Chrome OS ML Service daemon via its Mojo // Encapsulates a connection to the Chrome OS ML Service daemon via its Mojo
// interface. // interface.
// Usage: // Usage:
// chromeos::machine_learning::mojom::ModelProviderPtr model_provider; // chromeos::machine_learning::mojom::ModelPtr model;
// chromeos::machine_learning::mojom::ModelSpec spec;
// chromeos::machine_learning::ServiceConnection::GetInstance() // chromeos::machine_learning::ServiceConnection::GetInstance()
// ->BindModelProvider(mojom::MakeRequest(&model_provider)); // ->LoadModel(spec, mojom::MakeRequest(&model));
// // Use model_provider ... // // Use model ...
// Sequencing: Must be used on a single sequence (may be created on another). // Sequencing: Must be used on a single sequence (may be created on another).
class ServiceConnection { class ServiceConnection {
public: public:
static ServiceConnection* GetInstance(); static ServiceConnection* GetInstance();
// Instruct ML daemon to bind a ModelProvider implementation to |request|. // Instruct ML daemon to load the model specified in |spec|, binding a Model
// implementation to |request|.
// Bootstraps the initial Mojo connection to the daemon if necessary. // Bootstraps the initial Mojo connection to the daemon if necessary.
void BindModelProvider(mojom::ModelProviderRequest request); void LoadModel(mojom::ModelSpecPtr spec, mojom::ModelRequest request);
private: private:
friend class base::NoDestructor<ServiceConnection>; friend class base::NoDestructor<ServiceConnection>;
......
...@@ -42,9 +42,10 @@ class ServiceConnectionTest : public testing::Test { ...@@ -42,9 +42,10 @@ class ServiceConnectionTest : public testing::Test {
// Tests that BindModelProvider runs OK (no crash) in a basic Mojo environment. // Tests that BindModelProvider runs OK (no crash) in a basic Mojo environment.
TEST_F(ServiceConnectionTest, BindModelProvider) { TEST_F(ServiceConnectionTest, BindModelProvider) {
mojom::ModelProviderPtr model_provider; mojom::ModelPtr model;
ServiceConnection::GetInstance()->BindModelProvider( mojom::ModelSpecPtr spec = mojom::ModelSpec::New(mojom::ModelId::UNKNOWN);
mojo::MakeRequest(&model_provider)); ServiceConnection::GetInstance()->LoadModel(std::move(spec),
mojo::MakeRequest(&model));
} }
} // namespace } // namespace
......
...@@ -13,12 +13,8 @@ module chromeos.machine_learning.mojom; ...@@ -13,12 +13,8 @@ module chromeos.machine_learning.mojom;
import "chromeos/services/machine_learning/public/mojom/model.mojom"; import "chromeos/services/machine_learning/public/mojom/model.mojom";
interface ModelProvider {
// The ModelId inside ModelSpec is used to specify the model to be loaded.
LoadModel(ModelSpec spec, Model& request);
};
// Top-level interface between Chromium and the ML Service daemon. // Top-level interface between Chromium and the ML Service daemon.
interface MachineLearningService { interface MachineLearningService {
GetModelProvider(ModelProvider& request); // The ModelId inside ModelSpec is used to specify the model to be loaded.
LoadModel(ModelSpec spec, Model& request);
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment