Commit 353dcbf6 authored by Bailey Berro's avatar Bailey Berro Committed by Commit Bot

Introduce DiagnosticsManager to manage service lifetimes

This change creates the DiagnosticsManager class which is responsible
for managing the lifetime of the various services used by the
Diagnostics SWA. DiagnosticsManager will be owned by the SWA's
MojoWebUIController and is brought up and torn down when the app is
opened/closed.

Bug: 1128204
Change-Id: Ie9be65e3d6ab74aa4037cc1e916cdbd3f2981da5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2492641Reviewed-by: default avatarBailey Berro <baileyberro@chromium.org>
Reviewed-by: default avatarZentaro Kavanagh <zentaro@chromium.org>
Commit-Queue: Bailey Berro <baileyberro@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820314}
parent 58ed8a06
...@@ -8,6 +8,8 @@ static_library("backend") { ...@@ -8,6 +8,8 @@ static_library("backend") {
sources = [ sources = [
"cros_healthd_helpers.cc", "cros_healthd_helpers.cc",
"cros_healthd_helpers.h", "cros_healthd_helpers.h",
"diagnostics_manager.cc",
"diagnostics_manager.h",
"power_manager_client_conversions.cc", "power_manager_client_conversions.cc",
"power_manager_client_conversions.h", "power_manager_client_conversions.h",
"system_data_provider.cc", "system_data_provider.cc",
......
// 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/diagnostics_manager.h"
#include "chromeos/components/diagnostics_ui/backend/system_data_provider.h"
#include "chromeos/components/diagnostics_ui/backend/system_routine_controller.h"
namespace chromeos {
namespace diagnostics {
DiagnosticsManager::DiagnosticsManager()
: system_data_provider_(std::make_unique<SystemDataProvider>()),
system_routine_controller_(std::make_unique<SystemRoutineController>()) {}
DiagnosticsManager::~DiagnosticsManager() = default;
SystemDataProvider* DiagnosticsManager::GetSystemDataProvider() const {
return system_data_provider_.get();
}
SystemRoutineController* DiagnosticsManager::GetSystemRoutineController()
const {
return system_routine_controller_.get();
}
} // 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_DIAGNOSTICS_MANAGER_H_
#define CHROMEOS_COMPONENTS_DIAGNOSTICS_UI_BACKEND_DIAGNOSTICS_MANAGER_H_
#include <memory>
namespace chromeos {
namespace diagnostics {
class SystemDataProvider;
class SystemRoutineController;
// DiagnosticsManager is responsible for managing the lifetime of the services
// used by the Diagnostics SWA.
class DiagnosticsManager {
public:
DiagnosticsManager();
~DiagnosticsManager();
DiagnosticsManager(const DiagnosticsManager&) = delete;
DiagnosticsManager& operator=(const DiagnosticsManager&) = delete;
SystemDataProvider* GetSystemDataProvider() const;
SystemRoutineController* GetSystemRoutineController() const;
private:
std::unique_ptr<SystemDataProvider> system_data_provider_;
std::unique_ptr<SystemRoutineController> system_routine_controller_;
};
} // namespace diagnostics
} // namespace chromeos
#endif // CHROMEOS_COMPONENTS_DIAGNOSTICS_UI_BACKEND_DIAGNOSTICS_MANAGER_H_
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