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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_H_
6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_H_ 6 #define CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_H_
7 7
8 #include <queue>
9 #include <string>
10
8 #include "base/basictypes.h" 11 #include "base/basictypes.h"
9 #include "base/callback_forward.h" 12 #include "base/callback_forward.h"
13 #include "base/memory/weak_ptr.h"
10 14
11 namespace chromeos { 15 namespace chromeos {
12 16
13 class DeviceOAuth2TokenService; 17 class DeviceOAuth2TokenService;
14 18
15 class DeviceOAuth2TokenServiceFactory { 19 class DeviceOAuth2TokenServiceFactory {
16 public: 20 public:
17 // Callback type used for Get() function. 21 // Callback type used for Get() function.
18 typedef base::Callback<void(DeviceOAuth2TokenService*)> GetCallback; 22 typedef base::Callback<void(DeviceOAuth2TokenService*)> GetCallback;
19 23
(...skipping 18 matching lines...) Expand all
38 // Called by ChromeBrowserMainPartsChromeOS in order to shutdown the 42 // Called by ChromeBrowserMainPartsChromeOS in order to shutdown the
39 // DeviceOAuth2TokenService instance and cancel all in-flight requests 43 // DeviceOAuth2TokenService instance and cancel all in-flight requests
40 // before the required global data is destroyed (local state and request 44 // before the required global data is destroyed (local state and request
41 // context getter). 45 // context getter).
42 static void Shutdown(); 46 static void Shutdown();
43 47
44 private: 48 private:
45 DeviceOAuth2TokenServiceFactory(); 49 DeviceOAuth2TokenServiceFactory();
46 ~DeviceOAuth2TokenServiceFactory(); 50 ~DeviceOAuth2TokenServiceFactory();
47 51
52 // Creates the token service asynchronously in the following steps:
53 // 1) Get the system salt from cryptohomed asynchronously
54 // 2) Create CryptohomeTokenEncryptor using the system salt
55 // 3) Create DeviceOAuth2TokenServiceFactory using the token encryptor
56 void CreateTokenService();
57
58 // Continuation of CreateTokenService(). Called when GetSystemSalt() is
59 // complete.
60 void DidGetSystemSalt(const std::string& system_salt);
61
62 // Runs the callback asynchronously. If |token_service_| is ready, the
63 // callback will be simply run via MessageLoop. Otherwise, the callback
64 // will be queued in |pending_callbacks_| and run when |token_service_| is
65 // ready.
66 void RunAsync(const GetCallback& callback);
67
68 // True if the factory is initialized (i.e. system salt retrieval is done
69 // regardless of whether it succeeded or failed).
70 bool initialized_;
48 DeviceOAuth2TokenService* token_service_; 71 DeviceOAuth2TokenService* token_service_;
72 std::queue<GetCallback> pending_callbacks_;
73 base::WeakPtrFactory<DeviceOAuth2TokenServiceFactory> weak_ptr_factory_;
49 74
50 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenServiceFactory); 75 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenServiceFactory);
51 }; 76 };
52 77
53 } // namespace chromeos 78 } // namespace chromeos
54 79
55 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_ H_ 80 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698