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

Unified Diff: chrome/browser/chromeos/login/tpm_password_fetcher.cc

Issue 10703162: chromeos: Remove CryptohomeLibrary::TpmGetPassword and TpmIsReady (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: More localized variables Created 8 years, 5 months 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: chrome/browser/chromeos/login/tpm_password_fetcher.cc
diff --git a/chrome/browser/chromeos/login/tpm_password_fetcher.cc b/chrome/browser/chromeos/login/tpm_password_fetcher.cc
index 0adfb60beb1febc9bf2acb179277e5b9b748e2c4..e4db8b948a2d87f74c31ff2f545e92ff31ba8d72 100644
--- a/chrome/browser/chromeos/login/tpm_password_fetcher.cc
+++ b/chrome/browser/chromeos/login/tpm_password_fetcher.cc
@@ -7,8 +7,8 @@
#include "base/bind.h"
#include "base/compiler_specific.h"
#include "base/message_loop.h"
-#include "chrome/browser/chromeos/cros/cros_library.h"
-#include "chrome/browser/chromeos/cros/cryptohome_library.h"
+#include "chromeos/dbus/cryptohome_client.h"
+#include "chromeos/dbus/dbus_thread_manager.h"
namespace chromeos {
@@ -32,12 +32,26 @@ void TpmPasswordFetcher::Fetch() {
// Since this method is also called directly.
weak_factory_.InvalidateWeakPtrs();
- std::string password;
+ DBusThreadManager::Get()->GetCryptohomeClient()->TpmIsReady(
+ base::Bind(&TpmPasswordFetcher::OnTpmIsReady,
+ weak_factory_.GetWeakPtr()));
+}
- chromeos::CryptohomeLibrary* cryptohome =
- chromeos::CrosLibrary::Get()->GetCryptohomeLibrary();
+void TpmPasswordFetcher::OnTpmIsReady(DBusMethodCallStatus call_status,
+ bool tpm_is_ready) {
+ if (call_status == DBUS_METHOD_CALL_SUCCESS && tpm_is_ready) {
+ DBusThreadManager::Get()->GetCryptohomeClient()->TpmGetPassword(
+ base::Bind(&TpmPasswordFetcher::OnTpmGetPassword,
+ weak_factory_.GetWeakPtr()));
+ } else {
+ // Password hasn't been acquired, reschedule fetch.
+ RescheduleFetch();
+ }
+}
- if (cryptohome->TpmIsReady() && cryptohome->TpmGetPassword(&password)) {
+void TpmPasswordFetcher::OnTpmGetPassword(DBusMethodCallStatus call_status,
+ const std::string& password) {
+ if (call_status == DBUS_METHOD_CALL_SUCCESS) {
if (password.empty()) {
// For a fresh OOBE flow TPM is uninitialized,
// ownership process is started at the EULA screen,
@@ -47,11 +61,15 @@ void TpmPasswordFetcher::Fetch() {
delegate_->OnPasswordFetched(password);
} else {
// Password hasn't been acquired, reschedule fetch.
- MessageLoop::current()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&TpmPasswordFetcher::Fetch, weak_factory_.GetWeakPtr()),
- base::TimeDelta::FromMilliseconds(kTpmCheckIntervalMs));
+ RescheduleFetch();
}
}
+void TpmPasswordFetcher::RescheduleFetch() {
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&TpmPasswordFetcher::Fetch, weak_factory_.GetWeakPtr()),
+ base::TimeDelta::FromMilliseconds(kTpmCheckIntervalMs));
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/tpm_password_fetcher.h ('k') | chrome/browser/resources/chromeos/cryptohome.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698