Commit 2c3939a7 authored by Sorin Jianu's avatar Sorin Jianu Committed by Commit Bot

Implement --single-process command line switch for Windows.

This allows debugging the updater engine without the hassles of dealing
with the client-server(service) RPC multiprocess model.

Consider implementing the mode for macOS too, if it is valuable.

Run updater --single-process to enter this mode.

Bug: 1060800
Change-Id: I63c198e1af454ec885b7248ec86d935351e79bea
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2099603Reviewed-by: default avatarS. Ganesh <ganesh@chromium.org>
Commit-Queue: Sorin Jianu <sorin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749432}
parent 78cd4841
......@@ -24,6 +24,7 @@ const char kInitDoneNotifierSwitch[] = "init-done-notifier";
const char kNoRateLimitSwitch[] = "no-rate-limit";
const char kEnableLoggingSwitch[] = "enable-logging";
const char kLoggingModuleSwitch[] = "vmodule";
const char kSingleProcessSwitch[] = "single-process";
// URLs.
const char kUpdaterJSONDefaultUrl[] =
......
......@@ -81,6 +81,11 @@ extern const char kEnableLoggingSwitch[];
// Specifies the logging module filter.
extern const char kLoggingModuleSwitch[];
// Specifies that the program uses a single process execution mode, meaning
// out of process RPC is not being used. This mode is for debugging purposes
// only and it may be removed at any time.
extern const char kSingleProcessSwitch[];
// URLs.
//
// Omaha server end point.
......
......@@ -4,16 +4,20 @@
#include "chrome/updater/update_apps.h"
#include "base/command_line.h"
#include "chrome/updater/configurator.h"
#include "chrome/updater/constants.h"
#include "chrome/updater/update_service_in_process.h"
#include "chrome/updater/win/update_service_out_of_process.h"
namespace updater {
std::unique_ptr<UpdateService> CreateUpdateService(
scoped_refptr<update_client::Configurator> config) {
// TODO(crbug.com/1048653): Try to connect to an existing OOP service. For
// now, run an in-process service.
return std::make_unique<UpdateServiceInProcess>(config);
if (base::CommandLine::ForCurrentProcess()->HasSwitch(kSingleProcessSwitch))
return std::make_unique<UpdateServiceInProcess>(config);
else
return std::make_unique<UpdateServiceOutOfProcess>();
}
} // namespace updater
......@@ -84,6 +84,11 @@ int HandleUpdaterCommands(const base::CommandLine* command_line) {
CHECK(false) << "--crash-me was used.";
}
#if defined(OS_MACOSX)
// TODO(crbug.com/1060800) Consider implementing --single-process on macOS.
CHECK(!command_line->HasSwitch(kSingleProcessSwitch));
#endif
if (command_line->HasSwitch(kServerSwitch)) {
return MakeAppServer()->Run();
}
......@@ -94,7 +99,7 @@ int HandleUpdaterCommands(const base::CommandLine* command_line) {
if (command_line->HasSwitch(kInstallSwitch))
return MakeAppInstall({kChromeAppId})->Run();
#endif
#endif // OS_WIN
if (command_line->HasSwitch(kUninstallSwitch))
return MakeAppUninstall()->Run();
......@@ -118,6 +123,7 @@ int UpdaterMain(int argc, const char* const* argv) {
InitLogging(*command_line);
VLOG(1) << "Command line: " << command_line->GetCommandLineString();
if (command_line->HasSwitch(kCrashHandlerSwitch))
return CrashReporterMain();
......
......@@ -96,6 +96,8 @@ source_set("lib") {
"setup/setup_util.h",
"setup/uninstall.cc",
"setup/uninstall.h",
"update_service_out_of_process.cc",
"update_service_out_of_process.h",
]
libs = [ "winhttp.lib" ]
......
......@@ -10,6 +10,7 @@
#include <vector>
#include "base/bind.h"
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/i18n/icu_util.h"
#include "base/logging.h"
......@@ -752,6 +753,10 @@ void AppInstall::SetupDone(int result) {
}
scoped_refptr<App> MakeAppInstall(const std::string& app_id) {
// TODO(sorin) "--install" must be run with "--single-process" until
// crbug.com/1053729 is resolved.
DCHECK(
base::CommandLine::ForCurrentProcess()->HasSwitch(kSingleProcessSwitch));
return base::MakeRefCounted<AppInstall>(app_id);
}
......
......@@ -230,6 +230,10 @@ int Setup(bool is_machine) {
base::CommandLine run_updater_ua_command(product_dir.Append(kUpdaterExe));
run_updater_ua_command.AppendSwitch(kUpdateAppsSwitch);
// TODO(sorin) remove "single-process" when the updater COM client works.
// crbug.com/1053729.
run_updater_ua_command.AppendSwitch(kSingleProcessSwitch);
#if !defined(NDEBUG)
run_updater_ua_command.AppendSwitch(kEnableLoggingSwitch);
run_updater_ua_command.AppendSwitchASCII(kLoggingModuleSwitch,
......
// 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 "chrome/updater/win/update_service_out_of_process.h"
#include "base/callback.h"
#include "base/logging.h"
namespace updater {
UpdateServiceOutOfProcess::UpdateServiceOutOfProcess() = default;
UpdateServiceOutOfProcess::~UpdateServiceOutOfProcess() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
void UpdateServiceOutOfProcess::RegisterApp(
const RegistrationRequest& request,
base::OnceCallback<void(const RegistrationResponse&)> callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// TODO(sorin) the updater must be run with "--single-process" until
// crbug.com/1053729 is resolved.
NOTREACHED();
}
void UpdateServiceOutOfProcess::UpdateAll(
base::OnceCallback<void(Result)> callback) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// TODO(sorin) the updater must be run with "--single-process" until
// crbug.com/1053729 is resolved.
NOTREACHED();
}
void UpdateServiceOutOfProcess::Update(const std::string& app_id,
UpdateService::Priority priority,
StateChangeCallback state_update,
base::OnceCallback<void(Result)> done) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// TODO(sorin) the updater must be run with "--single-process" until
// crbug.com/1053729 is resolved.
NOTREACHED();
}
} // namespace updater
// 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 CHROME_UPDATER_WIN_UPDATE_SERVICE_OUT_OF_PROCESS_H_
#define CHROME_UPDATER_WIN_UPDATE_SERVICE_OUT_OF_PROCESS_H_
#include <string>
#include "base/callback_forward.h"
#include "base/sequence_checker.h"
#include "chrome/updater/update_service.h"
namespace update_client {
enum class Error;
} // namespace update_client
namespace updater {
using StateChangeCallback =
base::RepeatingCallback<void(updater::UpdateService::UpdateState)>;
// All functions and callbacks must be called on the same sequence.
class UpdateServiceOutOfProcess : public UpdateService {
public:
UpdateServiceOutOfProcess();
UpdateServiceOutOfProcess(const UpdateServiceOutOfProcess&) = delete;
UpdateServiceOutOfProcess& operator=(const UpdateServiceOutOfProcess&) =
delete;
~UpdateServiceOutOfProcess() override;
// Overrides for updater::UpdateService.
// Update-checks all registered applications. Calls |callback| once the
// operation is complete.
void RegisterApp(
const RegistrationRequest& request,
base::OnceCallback<void(const RegistrationResponse&)> callback) override;
void UpdateAll(base::OnceCallback<void(Result)> callback) override;
void Update(const std::string& app_id,
Priority priority,
StateChangeCallback state_update,
base::OnceCallback<void(Result)> done) override;
private:
SEQUENCE_CHECKER(sequence_checker_);
};
} // namespace updater
#endif // CHROME_UPDATER_WIN_UPDATE_SERVICE_OUT_OF_PROCESS_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