chrome_models / 19 /cpp /lacros /service_connection_lacros.cc
dejanseo's picture
Upload 29 files
f8dc3a0 verified
// Copyright 2021 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chromeos/services/machine_learning/public/cpp/service_connection.h"
#include <utility>
#include "base/component_export.h"
#include "base/no_destructor.h"
#include "chromeos/lacros/lacros_service.h"
#include "chromeos/services/machine_learning/public/mojom/machine_learning_service.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace lacros {
namespace machine_learning {
namespace {
// Real Impl of ServiceConnection
class COMPONENT_EXPORT(CHROMEOS_MLSERVICE) ServiceConnectionLacros
: public chromeos::machine_learning::ServiceConnection {
public:
ServiceConnectionLacros();
ServiceConnectionLacros(const ServiceConnectionLacros&) = delete;
ServiceConnectionLacros& operator=(const ServiceConnectionLacros&) = delete;
~ServiceConnectionLacros() override;
chromeos::machine_learning::mojom::MachineLearningService&
GetMachineLearningService() override;
void BindMachineLearningService(
mojo::PendingReceiver<
chromeos::machine_learning::mojom::MachineLearningService> receiver)
override;
void Initialize() override;
};
ServiceConnectionLacros::ServiceConnectionLacros() = default;
ServiceConnectionLacros::~ServiceConnectionLacros() = default;
chromeos::machine_learning::mojom::MachineLearningService&
ServiceConnectionLacros::GetMachineLearningService() {
mojo::Remote<chromeos::machine_learning::mojom::MachineLearningService>&
machine_learning_service_remote =
chromeos::LacrosService::Get()
->GetRemote<
chromeos::machine_learning::mojom::MachineLearningService>();
return *machine_learning_service_remote.get();
}
void ServiceConnectionLacros::BindMachineLearningService(
mojo::PendingReceiver<
chromeos::machine_learning::mojom::MachineLearningService> receiver) {
chromeos::LacrosService::Get()->BindMachineLearningService(
std::move(receiver));
}
void ServiceConnectionLacros::Initialize() {}
} // namespace
} // namespace machine_learning
} // namespace lacros
namespace chromeos {
namespace machine_learning {
ServiceConnection* ServiceConnection::CreateRealInstance() {
static base::NoDestructor<lacros::machine_learning::ServiceConnectionLacros>
service_connection;
return service_connection.get();
}
} // namespace machine_learning
} // namespace chromeos