Commit c013db9d authored by Andreea Costinas's avatar Andreea Costinas Committed by Commit Bot

system-proxy: Call ShutDownProcess D-Bus method

This CL replaces the call to |ShutDown| with |ShutDownProcess|.

The D-Bus method ShutDownProcess allows, depending on the argument, to
shut down the daemon or just one of the worker processes. Since
System-proxy will have a worker which tunnels only ARC traffic, we need
a shut down method that can kill the ARC worker when ARC is disabled by
policy.

Bug:1042639,1109144
TEST=unittests pass

Change-Id: I73c5898095f5a6ee9d454c4a83b824667d2825d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2317958
Commit-Queue: Andreea-Elena Costinas <acostinas@google.com>
Reviewed-by: default avatarOmar Morsi <omorsi@google.com>
Reviewed-by: default avatarPavol Marko <pmarko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#794981}
parent 7e3680cb
......@@ -125,8 +125,11 @@ void SystemProxyManager::OnSystemProxySettingsPolicyChanged() {
// daemon and tell it to exit.
// TODO(crbug.com/1055245,acostinas): Do not send shut-down command if
// System-proxy is inactive.
chromeos::SystemProxyClient::Get()->ShutDownDaemon(base::BindOnce(
&SystemProxyManager::OnDaemonShutDown, weak_factory_.GetWeakPtr()));
system_proxy::ShutDownRequest request;
request.set_traffic_type(system_proxy::TrafficOrigin::ALL);
chromeos::SystemProxyClient::Get()->ShutDownProcess(
request, base::BindOnce(&SystemProxyManager::OnShutDownProcess,
weak_factory_.GetWeakPtr()));
system_services_address_.clear();
return;
}
......@@ -205,10 +208,11 @@ void SystemProxyManager::OnSetAuthenticationDetails(
}
}
void SystemProxyManager::OnDaemonShutDown(
void SystemProxyManager::OnShutDownProcess(
const system_proxy::ShutDownResponse& response) {
if (response.has_error_message() && !response.error_message().empty()) {
NET_LOG(ERROR) << "Failed to shutdown system proxy: " << kSystemProxyService
NET_LOG(ERROR) << "Failed to shutdown system proxy process: "
<< kSystemProxyService
<< ", error: " << response.error_message();
}
}
......
......@@ -62,7 +62,7 @@ class SystemProxyManager {
private:
void OnSetAuthenticationDetails(
const system_proxy::SetAuthenticationDetailsResponse& response);
void OnDaemonShutDown(const system_proxy::ShutDownResponse& response);
void OnShutDownProcess(const system_proxy::ShutDownResponse& response);
void OnClearUserCredentials(
const system_proxy::ClearUserCredentialsResponse& response);
......
......@@ -24,13 +24,6 @@ void FakeSystemProxyClient::SetAuthenticationDetails(
FROM_HERE, base::BindOnce(std::move(callback), response));
}
void FakeSystemProxyClient::ShutDownDaemon(ShutDownDaemonCallback callback) {
++shut_down_call_count_;
system_proxy::ShutDownResponse response;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), response));
}
void FakeSystemProxyClient::ClearUserCredentials(
const system_proxy::ClearUserCredentialsRequest& request,
ClearUserCredentialsCallback callback) {
......@@ -40,6 +33,15 @@ void FakeSystemProxyClient::ClearUserCredentials(
FROM_HERE, base::BindOnce(std::move(callback), response));
}
void FakeSystemProxyClient::ShutDownProcess(
const system_proxy::ShutDownRequest& request,
ShutDownProcessCallback callback) {
++shut_down_call_count_;
system_proxy::ShutDownResponse response;
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(std::move(callback), response));
}
void FakeSystemProxyClient::SetWorkerActiveSignalCallback(
WorkerActiveCallback callback) {
worker_active_callback_ = callback;
......
......@@ -24,13 +24,14 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakeSystemProxyClient
void SetAuthenticationDetails(
const system_proxy::SetAuthenticationDetailsRequest& request,
SetAuthenticationDetailsCallback callback) override;
void ShutDownDaemon(ShutDownDaemonCallback callback) override;
void SetWorkerActiveSignalCallback(WorkerActiveCallback callback) override;
void SetAuthenticationRequiredSignalCallback(
AuthenticationRequiredCallback callback) override;
void ClearUserCredentials(
const system_proxy::ClearUserCredentialsRequest& request,
ClearUserCredentialsCallback callback) override;
void ShutDownProcess(const system_proxy::ShutDownRequest& request,
ShutDownProcessCallback callback) override;
void ConnectToWorkerSignals() override;
......
......@@ -67,10 +67,6 @@ class SystemProxyClientImpl : public SystemProxyClient {
request, std::move(callback));
}
void ShutDownDaemon(ShutDownDaemonCallback callback) override {
CallProtoMethod(system_proxy::kShutDownMethod, std::move(callback));
}
void ClearUserCredentials(
const system_proxy::ClearUserCredentialsRequest& request,
ClearUserCredentialsCallback callback) override {
......@@ -78,6 +74,12 @@ class SystemProxyClientImpl : public SystemProxyClient {
request, std::move(callback));
}
void ShutDownProcess(const system_proxy::ShutDownRequest& request,
ShutDownProcessCallback callback) override {
CallProtoMethodWithRequest(system_proxy::kShutDownProcessMethod, request,
std::move(callback));
}
void SetWorkerActiveSignalCallback(WorkerActiveCallback callback) override {
DCHECK(callback);
DCHECK(!worker_active_callback_);
......
......@@ -23,14 +23,14 @@ class COMPONENT_EXPORT(SYSTEM_PROXY) SystemProxyClient {
public:
using SetAuthenticationDetailsCallback = base::OnceCallback<void(
const system_proxy::SetAuthenticationDetailsResponse& response)>;
using ShutDownDaemonCallback =
base::OnceCallback<void(const system_proxy::ShutDownResponse& response)>;
using WorkerActiveCallback = base::RepeatingCallback<void(
const system_proxy::WorkerActiveSignalDetails& details)>;
using AuthenticationRequiredCallback = base::RepeatingCallback<void(
const system_proxy::AuthenticationRequiredDetails& details)>;
using ClearUserCredentialsCallback = base::OnceCallback<void(
const system_proxy::ClearUserCredentialsResponse& response)>;
using ShutDownProcessCallback =
base::OnceCallback<void(const system_proxy::ShutDownResponse& response)>;
// Interface with testing functionality. Accessed through GetTestInterface(),
// only implemented in the fake implementation.
......@@ -38,7 +38,7 @@ class COMPONENT_EXPORT(SYSTEM_PROXY) SystemProxyClient {
public:
// Returns how many times |SetAuthenticationDetails| was called.
virtual int GetSetAuthenticationDetailsCallCount() const = 0;
// Returns how many times |ShutDownDaemon| was called.
// Returns how many times |ShutDownProcess| was called.
virtual int GetShutDownCallCount() const = 0;
// Returns how many times |ClearUserCredentials| was called.
virtual int GetClearUserCredentialsCount() const = 0;
......@@ -79,14 +79,16 @@ class COMPONENT_EXPORT(SYSTEM_PROXY) SystemProxyClient {
const system_proxy::SetAuthenticationDetailsRequest& request,
SetAuthenticationDetailsCallback callback) = 0;
// When receiving a shut-down call, System-proxy will schedule a shut-down
// task and reply. |callback| is called when the daemon starts to shut-down.
virtual void ShutDownDaemon(ShutDownDaemonCallback callback) = 0;
virtual void ClearUserCredentials(
const system_proxy::ClearUserCredentialsRequest& request,
ClearUserCredentialsCallback callback) = 0;
// When receiving a shut down call, System-proxy will schedule a shut down
// task and reply. |callback| is called when the daemon or one of the
// processes starts to shut down.
virtual void ShutDownProcess(const system_proxy::ShutDownRequest& request,
ShutDownProcessCallback callback) = 0;
// Returns an interface for testing (fake only), or returns nullptr.
virtual TestInterface* GetTestInterface() = 0;
......
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