blob: 5cb35601eb7ddbad76b785ebc384cc7439cc3fce [file]
// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_WINDOWS_SERVICES_SERVICE_PROGRAM_TEST_SUPPORT_SCOPED_INSTALL_SERVICE_H_
#define CHROME_WINDOWS_SERVICES_SERVICE_PROGRAM_TEST_SUPPORT_SCOPED_INSTALL_SERVICE_H_
#include <memory>
#include <string_view>
#include "base/command_line.h"
#include "base/process/process.h"
#include "base/win/windows_types.h"
namespace installer {
class InstallServiceWorkItem;
}
class ScopedInstallService {
public:
ScopedInstallService(std::wstring_view service_name,
std::wstring_view display_name,
std::wstring_view description,
base::CommandLine service_command,
const CLSID& clsid,
const IID& iid);
ScopedInstallService(const ScopedInstallService&) = delete;
ScopedInstallService& operator=(const ScopedInstallService&) = delete;
~ScopedInstallService();
bool is_valid() const { return bool(work_item_); }
// Returns a handle to the service process if it is running, or an invalid
// process otherwise.
base::Process GetRunningService();
private:
std::wstring service_name_;
std::unique_ptr<installer::InstallServiceWorkItem> work_item_;
};
#endif // CHROME_WINDOWS_SERVICES_SERVICE_PROGRAM_TEST_SUPPORT_SCOPED_INSTALL_SERVICE_H_