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..8a7ce6b565f5ff1528c315af903b70c4e609e9dc 100644 |
| --- a/chromeos/dbus/auth_policy_client.cc |
| +++ b/chromeos/dbus/auth_policy_client.cc |
| @@ -25,24 +25,57 @@ class AuthPolicyClientImpl : public AuthPolicyClient { |
| const std::string& user, |
| int password_fd, |
| const JoinCallback& callback) override { |
| - dbus::ObjectPath objectPath(authpolicy::kAuthPolicyServicePath); |
| - dbus::ObjectProxy* proxy = |
| - bus_->GetObjectProxy(authpolicy::kAuthPolicyServiceName, objectPath); |
| dbus::MethodCall method_call(authpolicy::kAuthPolicyInterface, |
| authpolicy::kAuthPolicyJoinADDomain); |
| dbus::MessageWriter writer(&method_call); |
| writer.AppendString(machine_name); |
| writer.AppendString(user); |
| writer.AppendFileDescriptor(password_fd); |
| - proxy->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| - base::Bind(&AuthPolicyClientImpl::HandleJoinCallback, |
| - weak_ptr_factory_.GetWeakPtr(), callback)); |
| + proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| + base::Bind(&AuthPolicyClientImpl::HandleJoinCallback, |
| + weak_ptr_factory_.GetWeakPtr(), callback)); |
| + } |
| + |
| + void RefreshDevicePolicies(const RefreshPoliciesCallback& callback) override { |
| + dbus::MethodCall method_call(authpolicy::kAuthPolicyInterface, |
| + authpolicy::kAuthPolicyRefreshDevicePolicy); |
|
hashimoto
2016/11/10 23:02:19
Policies (RefreshDevicePolicies) or Policy (kAuthP
Roman Sorokin (ftl)
2016/11/14 14:10:18
Done.
|
| + dbus::MessageWriter writer(&method_call); |
|
hashimoto
2016/11/10 23:02:19
This writer looks unneeded.
Roman Sorokin (ftl)
2016/11/14 14:10:18
Done.
|
| + proxy_->CallMethod( |
| + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| + base::Bind(&AuthPolicyClientImpl::HandleRefreshPolicyCallback, |
| + weak_ptr_factory_.GetWeakPtr(), callback)); |
| + } |
| + |
| + void RefreshUserPolicies(const std::string& account_id, |
| + const RefreshPoliciesCallback& callback) override { |
| + dbus::MethodCall method_call(authpolicy::kAuthPolicyInterface, |
| + authpolicy::kAuthPolicyRefreshUserPolicy); |
| + dbus::MessageWriter writer(&method_call); |
| + writer.AppendString(account_id); |
| + proxy_->CallMethod( |
| + &method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| + base::Bind(&AuthPolicyClientImpl::HandleRefreshPolicyCallback, |
| + weak_ptr_factory_.GetWeakPtr(), callback)); |
| } |
| protected: |
| - void Init(dbus::Bus* bus) override { bus_ = bus; } |
| + void Init(dbus::Bus* bus) override { |
| + bus_ = bus; |
| + proxy_ = bus_->GetObjectProxy( |
| + authpolicy::kAuthPolicyServiceName, |
| + dbus::ObjectPath(authpolicy::kAuthPolicyServicePath)); |
| + } |
| private: |
| + void HandleRefreshPolicyCallback(const RefreshPoliciesCallback& callback, |
| + dbus::Response* response) { |
| + if (!response) { |
| + LOG(ERROR) << "RefreshDevicePolicies: failed to call to authpolicy"; |
| + callback.Run(false); |
| + return; |
| + } |
| + callback.Run(true); |
| + } |
|
hashimoto
2016/11/10 23:02:19
nit: Put a blank line between methods.
Roman Sorokin (ftl)
2016/11/14 14:10:18
Done.
|
| void HandleJoinCallback(const JoinCallback& callback, |
| dbus::Response* response) { |
| if (!response) { |
| @@ -65,6 +98,7 @@ class AuthPolicyClientImpl : public AuthPolicyClient { |
| } |
| dbus::Bus* bus_ = nullptr; |
| + dbus::ObjectProxy* proxy_; |
|
hashimoto
2016/11/10 23:02:19
= nullptr;
Roman Sorokin (ftl)
2016/11/14 14:10:18
Done.
|
| // Note: This should remain the last member so it'll be destroyed and |
| // invalidate its weak pointers before any other members are destroyed. |