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

Unified Diff: chromeos/dbus/auth_policy_client.cc

Issue 2587993002: Chromad: Switch AuthPolicyClient to use cros_system_api enums. (Closed)
Patch Set: Switch to new universal enum type. 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 side-by-side diff with in-line comments
Download patch
Index: chromeos/dbus/auth_policy_client.cc
diff --git a/chromeos/dbus/auth_policy_client.cc b/chromeos/dbus/auth_policy_client.cc
index 499d09bc64f7d46e91518c5090740ce6c8e14f1a..de5485181f94efed997199e26c705a3c33034f88 100644
--- a/chromeos/dbus/auth_policy_client.cc
+++ b/chromeos/dbus/auth_policy_client.cc
@@ -8,7 +8,6 @@
#include "dbus/bus.h"
#include "dbus/message.h"
#include "dbus/object_proxy.h"
-#include "third_party/cros_system_api/dbus/service_constants.h"
namespace chromeos {
@@ -93,45 +92,47 @@ class AuthPolicyClientImpl : public AuthPolicyClient {
dbus::Response* response) {
if (!response) {
DLOG(ERROR) << "Join: Couldn't call to authpolicy";
- // TODO(rsorokin): make proper call, after defining possible errors codes.
- callback.Run(authpolicy::types::AD_JOIN_ERROR_UNKNOWN);
+ callback.Run(authpolicy::ERROR_DBUS_FAILURE);
return;
}
dbus::MessageReader reader(response);
- int res = authpolicy::types::AD_JOIN_ERROR_UNKNOWN;
+ int32_t res = static_cast<int32_t>(authpolicy::ERROR_UNKNOWN);
if (!reader.PopInt32(&res)) {
DLOG(ERROR) << "Join: Couldn't get an error from the response";
- // TODO(rsorokin): make proper call, after defining possible errors codes.
- callback.Run(authpolicy::types::AD_JOIN_ERROR_DBUS_FAIL);
+ callback.Run(authpolicy::ERROR_DBUS_FAILURE);
return;
}
+ authpolicy::ErrorType error(authpolicy::ERROR_UNKNOWN);
+ // Check if result code is out of the enum range.
+ if (res >= 0 && res < authpolicy::ERROR_COUNT)
+ error = static_cast<authpolicy::ErrorType>(res);
- callback.Run(res);
+ callback.Run(error);
}
void HandleAuthCallback(const AuthCallback& callback,
dbus::Response* response) {
- std::string user_id;
- int32_t res = static_cast<int32_t>(authpolicy::AUTH_USER_ERROR_UNKNOWN);
if (!response) {
DLOG(ERROR) << "Auth: Failed to call to authpolicy";
- // TODO(rsorokin): make proper call, after defining possible errors codes.
- callback.Run(authpolicy::AUTH_USER_ERROR_DBUS_FAILURE, user_id);
+ callback.Run(authpolicy::ERROR_DBUS_FAILURE, std::string());
return;
}
dbus::MessageReader reader(response);
+ int32_t res = static_cast<int32_t>(authpolicy::ERROR_UNKNOWN);
if (!reader.PopInt32(&res)) {
DLOG(ERROR) << "Auth: Failed to get an error from the response";
- // TODO(rsorokin): make proper call, after defining possible errors codes.
- callback.Run(static_cast<authpolicy::AuthUserErrorType>(res), user_id);
+ callback.Run(authpolicy::ERROR_DBUS_FAILURE, std::string());
return;
}
- if (res < 0 || res >= authpolicy::AUTH_USER_ERROR_COUNT)
- res = static_cast<int32_t>(authpolicy::AUTH_USER_ERROR_UNKNOWN);
+ authpolicy::ErrorType error(authpolicy::ERROR_UNKNOWN);
+ // Check if result code is out of the enum range.
+ if (res >= 0 && res < authpolicy::ERROR_COUNT)
+ error = static_cast<authpolicy::ErrorType>(res);
stevenjb 2016/12/27 17:52:26 Rather than duplicate this logic, add a helper fun
Roman Sorokin (ftl) 2016/12/28 11:04:09 Done.
+ std::string user_id;
if (!reader.PopString(&user_id))
DLOG(ERROR) << "Auth: Failed to get user_id from the response";
- callback.Run(static_cast<authpolicy::AuthUserErrorType>(res), user_id);
+ callback.Run(error, user_id);
}
dbus::Bus* bus_ = nullptr;

Powered by Google App Engine
This is Rietveld 408576698