Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: chromeos/dbus/auth_policy_client.cc

Issue 2587993002: Chromad: Switch AuthPolicyClient to use cros_system_api enums. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #include "chromeos/dbus/auth_policy_client.h" 4 #include "chromeos/dbus/auth_policy_client.h"
5 5
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/memory/weak_ptr.h" 7 #include "base/memory/weak_ptr.h"
8 #include "dbus/bus.h" 8 #include "dbus/bus.h"
9 #include "dbus/message.h" 9 #include "dbus/message.h"
10 #include "dbus/object_proxy.h" 10 #include "dbus/object_proxy.h"
11 #include "third_party/cros_system_api/dbus/service_constants.h"
12 11
13 namespace chromeos { 12 namespace chromeos {
14 13
15 namespace { 14 namespace {
16 15
17 class AuthPolicyClientImpl : public AuthPolicyClient { 16 class AuthPolicyClientImpl : public AuthPolicyClient {
18 public: 17 public:
19 AuthPolicyClientImpl() : weak_ptr_factory_(this) {} 18 AuthPolicyClientImpl() : weak_ptr_factory_(this) {}
20 19
21 ~AuthPolicyClientImpl() override {} 20 ~AuthPolicyClientImpl() override {}
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 return; 73 return;
75 } 74 }
76 callback.Run(true); 75 callback.Run(true);
77 } 76 }
78 77
79 void HandleJoinCallback(const JoinCallback& callback, 78 void HandleJoinCallback(const JoinCallback& callback,
80 dbus::Response* response) { 79 dbus::Response* response) {
81 if (!response) { 80 if (!response) {
82 LOG(ERROR) << "Join: Couldn't call to authpolicy"; 81 LOG(ERROR) << "Join: Couldn't call to authpolicy";
83 // TODO(rsorokin): make proper call, after defining possible errors codes. 82 // TODO(rsorokin): make proper call, after defining possible errors codes.
84 callback.Run(authpolicy::types::AD_JOIN_ERROR_UNKNOWN); 83 callback.Run(authpolicy::AD_JOIN_ERROR_UNKNOWN);
85 return; 84 return;
86 } 85 }
87 86
88 dbus::MessageReader reader(response); 87 dbus::MessageReader reader(response);
89 int res = authpolicy::types::AD_JOIN_ERROR_UNKNOWN; 88 int32_t res = static_cast<int32_t>(authpolicy::AD_JOIN_ERROR_UNKNOWN);
90 if (!reader.PopInt32(&res)) { 89 if (!reader.PopInt32(&res)) {
91 LOG(ERROR) << "Join: Couldn't get an error from the response"; 90 LOG(ERROR) << "Join: Couldn't get an error from the response";
92 // TODO(rsorokin): make proper call, after defining possible errors codes. 91 // TODO(rsorokin): make proper call, after defining possible errors codes.
93 callback.Run(authpolicy::types::AD_JOIN_ERROR_DBUS_FAIL); 92 callback.Run(authpolicy::AD_JOIN_ERROR_DBUS_FAILURE);
94 return; 93 return;
95 } 94 }
96 95
97 callback.Run(res); 96 callback.Run(static_cast<authpolicy::ADJoinErrorType>(res));
98 } 97 }
99 98
100 dbus::Bus* bus_ = nullptr; 99 dbus::Bus* bus_ = nullptr;
101 dbus::ObjectProxy* proxy_ = nullptr; 100 dbus::ObjectProxy* proxy_ = nullptr;
102 101
103 // Note: This should remain the last member so it'll be destroyed and 102 // Note: This should remain the last member so it'll be destroyed and
104 // invalidate its weak pointers before any other members are destroyed. 103 // invalidate its weak pointers before any other members are destroyed.
105 base::WeakPtrFactory<AuthPolicyClientImpl> weak_ptr_factory_; 104 base::WeakPtrFactory<AuthPolicyClientImpl> weak_ptr_factory_;
106 105
107 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClientImpl); 106 DISALLOW_COPY_AND_ASSIGN(AuthPolicyClientImpl);
108 }; 107 };
109 108
110 } // namespace 109 } // namespace
111 110
112 AuthPolicyClient::AuthPolicyClient() {} 111 AuthPolicyClient::AuthPolicyClient() {}
113 112
114 AuthPolicyClient::~AuthPolicyClient() {} 113 AuthPolicyClient::~AuthPolicyClient() {}
115 114
116 // static 115 // static
117 AuthPolicyClient* AuthPolicyClient::Create() { 116 AuthPolicyClient* AuthPolicyClient::Create() {
118 return new AuthPolicyClientImpl(); 117 return new AuthPolicyClientImpl();
119 } 118 }
120 119
121 } // namespace chromeos 120 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698