OLD | NEW |
---|---|
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 <string> | |
9 #include <vector> | |
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 Loading... | |
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 salt from cryptohomed asynchronously | |
hashimoto
2013/10/24 06:50:00
nit: Did you mean "the system salt from cryptohome
satorux1
2013/10/24 07:33:08
Done.
| |
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 | |
48 DeviceOAuth2TokenService* token_service_; | 68 DeviceOAuth2TokenService* token_service_; |
69 std::vector<GetCallback> pending_callbacks_; | |
70 base::WeakPtrFactory<DeviceOAuth2TokenServiceFactory> weak_ptr_factory_; | |
49 | 71 |
50 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenServiceFactory); | 72 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenServiceFactory); |
51 }; | 73 }; |
52 | 74 |
53 } // namespace chromeos | 75 } // namespace chromeos |
54 | 76 |
55 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_ H_ | 77 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_ H_ |
OLD | NEW |