Commit e704807e authored by derat's avatar derat Committed by Commit bot

chromeos: Avoid EasyUnlockGetKeysOperation D-Bus log spam.

Make EasyUnlockGetKeysOperation wait for the cryptohome
D-Bus service to be available before making a GetKeyDataEx
method call to it. Otherwise, we get repeated log spam at
boot:

  [1912:1912:0916/102203:ERROR:object_proxy.cc(583)] Failed to call method: org.chromium.CryptohomeInterface.GetKeyDataEx: object_path= /org/chromium/Cryptohome: org.freedesktop.DBus.Error.ServiceUnknown: The name org.chromium.Cryptohome was not provided by any .service files
  [1912:1912:0916/102203:ERROR:easy_unlock_get_keys_operation.cc(61)] Easy unlock failed to get key data, code=1

BUG=636554

Review-Url: https://codereview.chromium.org/2343213002
Cr-Commit-Position: refs/heads/master@{#419228}
parent 1aee657f
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h"
#include "chromeos/dbus/cryptohome_client.h"
#include "chromeos/dbus/dbus_thread_manager.h"
#include "components/proximity_auth/logging/logging.h" #include "components/proximity_auth/logging/logging.h"
#include "components/signin/core/account_id/account_id.h" #include "components/signin/core/account_id/account_id.h"
#include "google_apis/gaia/gaia_auth_util.h" #include "google_apis/gaia/gaia_auth_util.h"
...@@ -30,6 +32,20 @@ EasyUnlockGetKeysOperation::~EasyUnlockGetKeysOperation() { ...@@ -30,6 +32,20 @@ EasyUnlockGetKeysOperation::~EasyUnlockGetKeysOperation() {
} }
void EasyUnlockGetKeysOperation::Start() { void EasyUnlockGetKeysOperation::Start() {
// Register for asynchronous notification of cryptohome being ready.
DBusThreadManager::Get()->GetCryptohomeClient()->WaitForServiceToBeAvailable(
base::Bind(&EasyUnlockGetKeysOperation::OnCryptohomeAvailable,
weak_ptr_factory_.GetWeakPtr()));
}
void EasyUnlockGetKeysOperation::OnCryptohomeAvailable(bool available) {
if (!available) {
PA_LOG(ERROR) << "Failed to wait for cryptohome to become available";
callback_.Run(false, EasyUnlockDeviceKeyDataList());
return;
}
// Start the asynchronous key fetch.
// TODO(xiyuan): Use ListKeyEx. // TODO(xiyuan): Use ListKeyEx.
key_index_ = 0; key_index_ = 0;
GetKeyData(); GetKeyData();
...@@ -42,7 +58,6 @@ void EasyUnlockGetKeysOperation::GetKeyData() { ...@@ -42,7 +58,6 @@ void EasyUnlockGetKeysOperation::GetKeyData() {
EasyUnlockKeyManager::GetKeyLabel(key_index_), EasyUnlockKeyManager::GetKeyLabel(key_index_),
base::Bind(&EasyUnlockGetKeysOperation::OnGetKeyData, base::Bind(&EasyUnlockGetKeysOperation::OnGetKeyData,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
void EasyUnlockGetKeysOperation::OnGetKeyData( void EasyUnlockGetKeysOperation::OnGetKeyData(
......
...@@ -26,10 +26,19 @@ class EasyUnlockGetKeysOperation { ...@@ -26,10 +26,19 @@ class EasyUnlockGetKeysOperation {
const GetKeysCallback& callback); const GetKeysCallback& callback);
~EasyUnlockGetKeysOperation(); ~EasyUnlockGetKeysOperation();
// Starts the operation. If the cryptohome service is not yet available, the
// request will be deferred until it is ready.
void Start(); void Start();
private: private:
// Called once when the cryptohome service is available.
void OnCryptohomeAvailable(bool available);
// Asynchronously requests data for |key_index_| from cryptohome.
void GetKeyData(); void GetKeyData();
// Callback for GetKeyData(). Updates |devices_|, increments |key_index_|, and
// calls GetKeyData() again.
void OnGetKeyData( void OnGetKeyData(
bool success, bool success,
cryptohome::MountError return_code, cryptohome::MountError return_code,
......
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