summaryrefslogtreecommitdiffstats
path: root/chromeos
diff options
context:
space:
mode:
authorhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-10 04:17:57 +0000
committerhashimoto@chromium.org <hashimoto@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-10 04:17:57 +0000
commit87dea54d9cedc742d52a78c767b02fa21a2c78dc (patch)
treed80bbe28dfaa052b4da96076943308c5c2097c0e /chromeos
parenta776924c9514253d425bfe48cd2061da4e2ea494 (diff)
downloadchromium_src-87dea54d9cedc742d52a78c767b02fa21a2c78dc.zip
chromium_src-87dea54d9cedc742d52a78c767b02fa21a2c78dc.tar.gz
chromium_src-87dea54d9cedc742d52a78c767b02fa21a2c78dc.tar.bz2
chromeos: Add asynchronous version of GetSystemSalt()
The old synchronous implementation is renamed to GetSystemSaltSync(). The old implementation is marked as deprecated and all users will switch to GetSystemSalt() soon. BUG=141009 TEST=build R=satorux@chromium.org TBR=bbudge@chromium.org for c/b/renderer_host/pepper, benwells@chromium.org for c/b/extensions/api/music_manager_private Review URL: https://codereview.chromium.org/26697005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227874 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos')
-rw-r--r--chromeos/cryptohome/cryptohome_library.cc17
-rw-r--r--chromeos/cryptohome/cryptohome_library.h13
2 files changed, 25 insertions, 5 deletions
diff --git a/chromeos/cryptohome/cryptohome_library.cc b/chromeos/cryptohome/cryptohome_library.cc
index 29745ca..e07dd60 100644
--- a/chromeos/cryptohome/cryptohome_library.cc
+++ b/chromeos/cryptohome/cryptohome_library.cc
@@ -7,7 +7,9 @@
#include <map>
#include "base/bind.h"
+#include "base/location.h"
#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop_proxy.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/sys_info.h"
@@ -32,7 +34,13 @@ class CryptohomeLibraryImpl : public CryptohomeLibrary {
virtual ~CryptohomeLibraryImpl() {
}
- virtual std::string GetSystemSalt() OVERRIDE {
+ virtual void GetSystemSalt(const GetSystemSaltCallback& callback) OVERRIDE {
+ // TODO(hashimoto): Stop using GetSystemSaltSynt(). crbug.com/141009
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE, base::Bind(callback, GetSystemSaltSync()));
+ }
+
+ virtual std::string GetSystemSaltSync() OVERRIDE {
LoadSystemSalt(); // no-op if it's already loaded.
return system_salt_;
}
@@ -65,7 +73,12 @@ class CryptohomeLibraryStubImpl : public CryptohomeLibrary {
CryptohomeLibraryStubImpl() {}
virtual ~CryptohomeLibraryStubImpl() {}
- virtual std::string GetSystemSalt() OVERRIDE {
+ virtual void GetSystemSalt(const GetSystemSaltCallback& callback) OVERRIDE {
+ base::MessageLoopProxy::current()->PostTask(
+ FROM_HERE, base::Bind(callback, kStubSystemSalt));
+ }
+
+ virtual std::string GetSystemSaltSync() OVERRIDE {
return kStubSystemSalt;
}
diff --git a/chromeos/cryptohome/cryptohome_library.h b/chromeos/cryptohome/cryptohome_library.h
index b427ae2..9b33bd5 100644
--- a/chromeos/cryptohome/cryptohome_library.h
+++ b/chromeos/cryptohome/cryptohome_library.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/callback_forward.h"
#include "chromeos/chromeos_export.h"
namespace chromeos {
@@ -16,6 +17,9 @@ namespace chromeos {
// APIs.
class CHROMEOS_EXPORT CryptohomeLibrary {
public:
+ typedef base::Callback<void(const std::string& system_salt)>
+ GetSystemSaltCallback;
+
// Manage an explicitly initialized global instance.
static void Initialize();
static bool IsInitialized();
@@ -36,9 +40,12 @@ class CHROMEOS_EXPORT CryptohomeLibrary {
// Returns system hash in hex encoded ascii format. Note: this may return
// an empty string (e.g. if cryptohome is not running). It is up to the
// calling function to try again after a delay if desired.
- //
- // TODO(hashimoto): Make it asynchronous. crbug.com/141009.
- virtual std::string GetSystemSalt() = 0;
+ virtual void GetSystemSalt(const GetSystemSaltCallback& callback) = 0;
+
+ // Synchronous version of GetSystemSalt().
+ // Blocks the UI thread until the Cryptohome service returns the result.
+ // DEPRECATED: DO NOT USE.
+ virtual std::string GetSystemSaltSync() = 0;
// Returns system hash in hex encoded ascii format, cached by a prior call
// to GetSystemSalt(). Note: this may return an empty string (e.g. if