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

Unified Diff: chromeos/cryptohome/system_salt_getter.cc

Issue 2220433002: ChromeOS: fix crash in HashWallpaperFilesIdStr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: AddOnSystemSaltReady() should immediately run callback if system salt is ready. Created 4 years, 4 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') | no next file » | 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 48f565e90a350f0fcaceeb5a01fab74edd9a85f1..45461458b5adcacefcd7a384b8f09c6101097d2e 100644
--- a/chromeos/cryptohome/system_salt_getter.cc
+++ b/chromeos/cryptohome/system_salt_getter.cc
@@ -42,6 +42,15 @@ void SystemSaltGetter::GetSystemSalt(
callback));
}
+void SystemSaltGetter::AddOnSystemSaltReady(const base::Closure& closure) {
+ if (!raw_salt_.empty()) {
+ closure.Run();
+ return;
+ }
+
+ on_system_salt_ready_.push_back(closure);
+}
+
const SystemSaltGetter::RawSalt* SystemSaltGetter::GetRawSalt() const {
return raw_salt_.empty() ? nullptr : &raw_salt_;
}
@@ -74,6 +83,12 @@ void SystemSaltGetter::DidGetSystemSalt(
system_salt.size() % 2 == 0U) {
raw_salt_ = system_salt;
system_salt_ = ConvertRawSaltToHexString(system_salt);
+
+ std::vector<base::Closure> callbacks;
+ callbacks.swap(on_system_salt_ready_);
+ for (const base::Closure& callback : callbacks) {
+ callback.Run();
+ }
} else {
LOG(WARNING) << "System salt not available";
}
« no previous file with comments | « chromeos/cryptohome/system_salt_getter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698