Commit 97d68ec2 authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Create SystemRoutineController

This change introduces the SystemRoutineController class that connects
to the cros_healthd DiagnosticsService. Subsequent CLs will declare and
implement a SystemRoutineController mojo interface.

Bug: 1128204
Change-Id: Ic510e1f90efedbbcba42827ca843323f04803e1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2457807Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#816182}
parent b4b8f552
......@@ -12,6 +12,8 @@ static_library("backend") {
"power_manager_client_conversions.h",
"system_data_provider.cc",
"system_data_provider.h",
"system_routine_controller.cc",
"system_routine_controller.h",
]
deps = [
......@@ -30,6 +32,7 @@ source_set("unit_tests") {
sources = [
"power_manager_client_conversions_unittest.cc",
"system_data_provider_unittest.cc",
"system_routine_controller_unittest.cc",
]
deps = [
......
// Copyright 2020 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/components/diagnostics_ui/backend/system_routine_controller.h"
#include "base/bind.h"
#include "chromeos/services/cros_healthd/public/cpp/service_connection.h"
namespace chromeos {
namespace diagnostics {
void SystemRoutineController::BindCrosHealthdDiagnosticsServiceIfNeccessary() {
if (!diagnostics_service_ || !diagnostics_service_.is_connected()) {
cros_healthd::ServiceConnection::GetInstance()->GetDiagnosticsService(
diagnostics_service_.BindNewPipeAndPassReceiver());
diagnostics_service_.set_disconnect_handler(base::BindOnce(
&SystemRoutineController::OnDiagnosticsServiceDisconnected,
base::Unretained(this)));
}
}
void SystemRoutineController::OnDiagnosticsServiceDisconnected() {
diagnostics_service_.reset();
}
} // namespace diagnostics
} // namespace chromeos
// Copyright 2020 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.
#ifndef CHROMEOS_COMPONENTS_DIAGNOSTICS_UI_BACKEND_SYSTEM_ROUTINE_CONTROLLER_H_
#define CHROMEOS_COMPONENTS_DIAGNOSTICS_UI_BACKEND_SYSTEM_ROUTINE_CONTROLLER_H_
#include "chromeos/services/cros_healthd/public/mojom/cros_healthd.mojom.h"
#include "mojo/public/cpp/bindings/remote.h"
namespace chromeos {
namespace diagnostics {
class SystemRoutineController {
public:
SystemRoutineController();
~SystemRoutineController();
SystemRoutineController(const SystemRoutineController&) = delete;
SystemRoutineController& operator=(const SystemRoutineController&) = delete;
private:
void BindCrosHealthdDiagnosticsServiceIfNeccessary();
void OnDiagnosticsServiceDisconnected();
mojo::Remote<cros_healthd::mojom::CrosHealthdDiagnosticsService>
diagnostics_service_;
};
} // namespace diagnostics
} // namespace chromeos
#endif // CHROMEOS_COMPONENTS_DIAGNOSTICS_UI_BACKEND_SYSTEM_ROUTINE_CONTROLLER_H_
// Copyright 2020 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/components/diagnostics_ui/backend/system_routine_controller.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace chromeos {
namespace diagnostics {
class SystemRoutineControllerTest : public testing::Test {
SystemRoutineControllerTest() = default;
~SystemRoutineControllerTest() override = default;
};
} // namespace diagnostics
} // namespace chromeos
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