Chromium Code Reviews| Index: chromeos/dbus/auth_policy_client.cc |
| diff --git a/chromeos/dbus/auth_policy_client.cc b/chromeos/dbus/auth_policy_client.cc |
| index 7c86b81702a56891f8eebca4a9f3eaaee946d206..88d2136d4ce66d3a5306636578d7981303f77d32 100644 |
| --- a/chromeos/dbus/auth_policy_client.cc |
| +++ b/chromeos/dbus/auth_policy_client.cc |
| @@ -14,6 +14,11 @@ namespace chromeos { |
| namespace { |
| +const char kUpstartServiceName[] = "com.ubuntu.Upstart"; |
|
hashimoto
2016/11/08 00:12:26
AuthPolicyClient should deal only with AuthPolicy
Roman Sorokin (ftl)
2016/11/08 10:43:13
Done.
|
| +const char kUpstartObjectPath[] = "/com/ubuntu/Upstart/jobs/authpolicyd"; |
| +const char kUpstartJobInterface[] = "com.ubuntu.Upstart0_6.Job"; |
| +const char kUpstartStartMethod[] = "Start"; |
| + |
| class AuthPolicyClientImpl : public AuthPolicyClient { |
| public: |
| AuthPolicyClientImpl() : weak_ptr_factory_(this) {} |
| @@ -21,6 +26,20 @@ class AuthPolicyClientImpl : public AuthPolicyClient { |
| ~AuthPolicyClientImpl() override {} |
| // AuthPolicyClient override. |
| + void StartService() override { |
| + dbus::ObjectPath objectPath(kUpstartObjectPath); |
| + dbus::ObjectProxy* proxy = |
| + bus_->GetObjectProxy(kUpstartServiceName, objectPath); |
| + dbus::MethodCall method_call(kUpstartJobInterface, kUpstartStartMethod); |
| + dbus::MessageWriter writer(&method_call); |
| + dbus::MessageWriter sub_writer(nullptr); |
| + writer.OpenArray("s", &sub_writer); |
| + writer.CloseContainer(&sub_writer); |
| + writer.AppendBool(false); // No waiting for response. |
| + proxy->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| + base::Bind(&AuthPolicyClientImpl::HandleUpstartCallback, |
| + weak_ptr_factory_.GetWeakPtr())); |
| + } |
| void JoinAdDomain(const std::string& machine_name, |
| const std::string& user, |
| int password_fd, |
| @@ -43,6 +62,12 @@ class AuthPolicyClientImpl : public AuthPolicyClient { |
| void Init(dbus::Bus* bus) override { bus_ = bus; } |
| private: |
| + void HandleUpstartCallback(dbus::Response* response) { |
| + if (!response) { |
| + LOG(ERROR) << "Failed to start authpolicyd, response is null"; |
| + return; |
| + } |
| + } |
| void HandleJoinCallback(const JoinCallback& callback, |
| dbus::Response* response) { |
| if (!response) { |