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) { ...@@ -624,6 +624,10 @@ void ExistingUserController::OnAuthFailure(const AuthFailure& failure) {
ShowTPMError(); ShowTPMError();
} else if (!online_succeeded_for_.empty()) { } else if (!online_succeeded_for_.empty()) {
ShowGaiaPasswordChanged(online_succeeded_for_); 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 { } else {
// Check networking after trying to login in case user is // Check networking after trying to login in case user is
// cached locally or the local admin account. // cached locally or the local admin account.
......
...@@ -308,10 +308,17 @@ class AsyncMethodCallerImpl : public AsyncMethodCaller { ...@@ -308,10 +308,17 @@ class AsyncMethodCallerImpl : public AsyncMethodCaller {
base::Bind(it->second.data_callback, return_status, return_data)); base::Bind(it->second.data_callback, return_status, return_data));
data_callback_map_.erase(it); data_callback_map_.erase(it);
} }
// Registers a callback which is called when the result for AsyncXXX is ready. // Registers a callback which is called when the result for AsyncXXX is ready.
void RegisterAsyncCallback( void RegisterAsyncCallback(
Callback callback, const char* error, int async_id) { 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) { if (async_id == 0) {
LOG(ERROR) << error; LOG(ERROR) << error;
return; return;
...@@ -325,6 +332,13 @@ class AsyncMethodCallerImpl : public AsyncMethodCaller { ...@@ -325,6 +332,13 @@ class AsyncMethodCallerImpl : public AsyncMethodCaller {
// Registers a callback which is called when the result for AsyncXXX is ready. // Registers a callback which is called when the result for AsyncXXX is ready.
void RegisterAsyncDataCallback( void RegisterAsyncDataCallback(
DataCallback callback, const char* error, int async_id) { 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) { if (async_id == 0) {
LOG(ERROR) << error; LOG(ERROR) << error;
return; return;
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
namespace chromeos { namespace chromeos {
const int CryptohomeClient::kNotReadyAsyncId = -1;
namespace { namespace {
// This suffix is appended to user_id to get hash in stub implementation: // This suffix is appended to user_id to get hash in stub implementation:
...@@ -882,8 +884,10 @@ class CryptohomeClientImpl : public CryptohomeClient { ...@@ -882,8 +884,10 @@ class CryptohomeClientImpl : public CryptohomeClient {
// Handles the result of AsyncXXX methods. // Handles the result of AsyncXXX methods.
void OnAsyncMethodCall(const AsyncMethodCallback& callback, void OnAsyncMethodCall(const AsyncMethodCallback& callback,
dbus::Response* response) { dbus::Response* response) {
if (!response) if (!response) {
callback.Run(kNotReadyAsyncId);
return; return;
}
dbus::MessageReader reader(response); dbus::MessageReader reader(response);
int async_id = 0; int async_id = 0;
if (!reader.PopInt32(&async_id)) { if (!reader.PopInt32(&async_id)) {
......
...@@ -39,6 +39,10 @@ namespace chromeos { ...@@ -39,6 +39,10 @@ namespace chromeos {
// initializes the DBusThreadManager instance. // initializes the DBusThreadManager instance.
class CHROMEOS_EXPORT CryptohomeClient : public DBusClient { class CHROMEOS_EXPORT CryptohomeClient : public DBusClient {
public: 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. // A callback to handle AsyncCallStatus signals.
typedef base::Callback<void(int async_id, typedef base::Callback<void(int async_id,
bool return_status, 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