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

Unified Diff: chromeos/cryptohome/system_salt_getter.cc

Issue 43503003: chromeos: Remove SystemSaltGetter::GetSystemSaltSync (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
« no previous file with comments | « chromeos/cryptohome/system_salt_getter.h ('k') | chromeos/dbus/cryptohome_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/cryptohome/system_salt_getter.cc
diff --git a/chromeos/cryptohome/system_salt_getter.cc b/chromeos/cryptohome/system_salt_getter.cc
index 1fa25a325056662694e7e9deb23fdfb1910569dd..70977b901ba6d7e007efd72675dc2201cbe143b0 100644
--- a/chromeos/cryptohome/system_salt_getter.cc
+++ b/chromeos/cryptohome/system_salt_getter.cc
@@ -27,35 +27,39 @@ SystemSaltGetter::~SystemSaltGetter() {
void SystemSaltGetter::GetSystemSalt(
const GetSystemSaltCallback& callback) {
+ if (!system_salt_.empty()) {
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE, base::Bind(callback, system_salt_));
+ return;
+ }
+
DBusThreadManager::Get()->GetCryptohomeClient()->WaitForServiceToBeAvailable(
- base::Bind(&SystemSaltGetter::GetSystemSaltInternal,
+ base::Bind(&SystemSaltGetter::DidWaitForServiceToBeAvailable,
weak_ptr_factory_.GetWeakPtr(),
callback));
}
-std::string SystemSaltGetter::GetSystemSaltSync() {
- LoadSystemSalt(); // no-op if it's already loaded.
- return system_salt_;
-}
-
-void SystemSaltGetter::GetSystemSaltInternal(
+void SystemSaltGetter::DidWaitForServiceToBeAvailable(
const GetSystemSaltCallback& callback,
bool service_is_available) {
LOG_IF(ERROR, !service_is_available) << "WaitForServiceToBeAvailable failed.";
satorux1 2013/10/25 07:59:17 I think we should not proceed if this is false. ma
hashimoto 2013/10/25 08:01:51 Done.
- // TODO(hashimoto): Stop using GetSystemSaltSync(). crbug.com/141009
- callback.Run(GetSystemSaltSync());
+ DBusThreadManager::Get()->GetCryptohomeClient()->GetSystemSalt(
+ base::Bind(&SystemSaltGetter::DidGetSystemSalt,
+ weak_ptr_factory_.GetWeakPtr(),
+ callback));
}
-void SystemSaltGetter::LoadSystemSalt() {
- if (!system_salt_.empty())
- return;
- std::vector<uint8> salt;
- DBusThreadManager::Get()->GetCryptohomeClient()->GetSystemSalt(&salt);
- if (salt.empty() || salt.size() % 2 != 0U) {
+void SystemSaltGetter::DidGetSystemSalt(const GetSystemSaltCallback& callback,
+ DBusMethodCallStatus call_status,
+ const std::vector<uint8>& system_salt) {
+ if (call_status == DBUS_METHOD_CALL_SUCCESS &&
+ !system_salt.empty() &&
+ system_salt.size() % 2 == 0U)
+ system_salt_ = ConvertRawSaltToHexString(system_salt);
+ else
LOG(WARNING) << "System salt not available";
- return;
- }
- system_salt_ = ConvertRawSaltToHexString(salt);
+
+ callback.Run(system_salt_);
}
// static
« no previous file with comments | « chromeos/cryptohome/system_salt_getter.h ('k') | chromeos/dbus/cryptohome_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698