Commit 7df6f9fc authored by antrim's avatar antrim Committed by Commit bot

Cryptohome: Notify about error in async calls if cryptohome is not ready yet.

BUG=451148

Review URL: https://codereview.chromium.org/880303003

Cr-Commit-Position: refs/heads/master@{#313687}
parent 86f137da
......@@ -624,6 +624,10 @@ void ExistingUserController::OnAuthFailure(const AuthFailure& failure) {
ShowTPMError();
} else if (!online_succeeded_for_.empty()) {
ShowGaiaPasswordChanged(online_succeeded_for_);
} else if (last_login_attempt_username_ == chromeos::login::kGuestUserName) {
// Show no errors, just re-enable input.
login_display_->ClearAndEnablePassword();
StartPublicSessionAutoLoginTimer();
} else {
// Check networking after trying to login in case user is
// cached locally or the local admin account.
......
......@@ -308,10 +308,17 @@ class AsyncMethodCallerImpl : public AsyncMethodCaller {
base::Bind(it->second.data_callback, return_status, return_data));
data_callback_map_.erase(it);
}
// Registers a callback which is called when the result for AsyncXXX is ready.
void RegisterAsyncCallback(
Callback callback, const char* error, int async_id) {
if (async_id == chromeos::CryptohomeClient::kNotReadyAsyncId) {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE, base::Bind(callback,
false, // return status
cryptohome::MOUNT_ERROR_FATAL));
return;
}
if (async_id == 0) {
LOG(ERROR) << error;
return;
......@@ -325,6 +332,13 @@ class AsyncMethodCallerImpl : public AsyncMethodCaller {
// Registers a callback which is called when the result for AsyncXXX is ready.
void RegisterAsyncDataCallback(
DataCallback callback, const char* error, int async_id) {
if (async_id == chromeos::CryptohomeClient::kNotReadyAsyncId) {
base::MessageLoopProxy::current()->PostTask(
FROM_HERE, base::Bind(callback,
false, // return status
std::string()));
return;
}
if (async_id == 0) {
LOG(ERROR) << error;
return;
......
......@@ -20,6 +20,8 @@
namespace chromeos {
const int CryptohomeClient::kNotReadyAsyncId = -1;
namespace {
// This suffix is appended to user_id to get hash in stub implementation:
......@@ -882,8 +884,10 @@ class CryptohomeClientImpl : public CryptohomeClient {
// Handles the result of AsyncXXX methods.
void OnAsyncMethodCall(const AsyncMethodCallback& callback,
dbus::Response* response) {
if (!response)
if (!response) {
callback.Run(kNotReadyAsyncId);
return;
}
dbus::MessageReader reader(response);
int async_id = 0;
if (!reader.PopInt32(&async_id)) {
......
......@@ -39,6 +39,10 @@ namespace chromeos {
// initializes the DBusThreadManager instance.
class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
public:
// Constant that will be passed to AsyncMethodCallback to indicate that
// cryptohome is not ready yet.
static const int kNotReadyAsyncId;
// A callback to handle AsyncCallStatus signals.
typedef base::Callback<void(int async_id,
bool return_status,
......
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