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

Unified Diff: chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h

Issue 39443002: settings: Add async system salt retrieval logic in DeviceOAuth2TokenServiceFactory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments 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
Index: chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
diff --git a/chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h b/chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
index 16bd680ff573ea51f2d7f42dc6cc14e00cee16da..cd68763b7a870a32bef843431df2619e0b561d18 100644
--- a/chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
+++ b/chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
@@ -5,8 +5,12 @@
#ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_H_
#define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_H_
+#include <queue>
+#include <string>
+
#include "base/basictypes.h"
#include "base/callback_forward.h"
+#include "base/memory/weak_ptr.h"
namespace chromeos {
@@ -45,7 +49,28 @@ class DeviceOAuth2TokenServiceFactory {
DeviceOAuth2TokenServiceFactory();
~DeviceOAuth2TokenServiceFactory();
+ // Creates the token service asynchronously in the following steps:
+ // 1) Get the system salt from cryptohomed asynchronously
+ // 2) Create CryptohomeTokenEncryptor using the system salt
+ // 3) Create DeviceOAuth2TokenServiceFactory using the token encryptor
+ void CreateTokenService();
+
+ // Continuation of CreateTokenService(). Called when GetSystemSalt() is
+ // complete.
+ void DidGetSystemSalt(const std::string& system_salt);
+
+ // Runs the callback asynchronously. If |token_service_| is ready, the
+ // callback will be simply run via MessageLoop. Otherwise, the callback
+ // will be queued in |pending_callbacks_| and run when |token_service_| is
+ // ready.
+ void RunAsync(const GetCallback& callback);
+
+ // True if the factory is initialized (i.e. system salt retrieval is done
+ // regardless of whether it succeeded or failed).
+ bool initialized_;
DeviceOAuth2TokenService* token_service_;
+ std::queue<GetCallback> pending_callbacks_;
+ base::WeakPtrFactory<DeviceOAuth2TokenServiceFactory> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenServiceFactory);
};

Powered by Google App Engine
This is Rietveld 408576698