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

Side by Side Diff: chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h

Issue 34523003: settings: Make DeviceOAuth2TokenServiceFactory::Get() async (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 1 month 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 "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/callback_forward.h"
9 10
10 namespace chromeos { 11 namespace chromeos {
11 12
12 class DeviceOAuth2TokenService; 13 class DeviceOAuth2TokenService;
13 14
14 class DeviceOAuth2TokenServiceFactory { 15 class DeviceOAuth2TokenServiceFactory {
15 public: 16 public:
16 // Returns the instance of the DeviceOAuth2TokenService singleton. 17 // Callback type used for Get() function.
17 // May return null during browser startup and shutdown. Do not hold 18 typedef base::Callback<void(DeviceOAuth2TokenService*)> GetCallback;
18 // the pointer returned by this method; call this method every time 19
19 // and check for null to handle the case where this instance is destroyed 20 // Returns the instance of the DeviceOAuth2TokenService singleton via the
20 // during shutdown. 21 // given callback. This function is asynchronous as initializing
21 static DeviceOAuth2TokenService* Get(); 22 // DeviceOAuth2TokenService involves asynchronous D-Bus method calls.
23 //
24 // May return NULL during browser startup and shutdown. May also return
25 // NULL if Initialize() is not called beforehand, which can happen in unit
26 // tests.
27 //
28 // Do not hold the pointer returned by this method; call this method every
29 // time and check for NULL to handle the case where this instance is
30 // destroyed during shutdown.
31 static void Get(const GetCallback& callback);
22 32
23 // Called by ChromeBrowserMainPartsChromeOS in order to bootstrap the 33 // Called by ChromeBrowserMainPartsChromeOS in order to bootstrap the
24 // DeviceOAuth2TokenService instance after the required global data is 34 // DeviceOAuth2TokenService instance after the required global data is
25 // available (local state and request context getter). 35 // available (local state and request context getter).
26 static void Initialize(); 36 static void Initialize();
27 37
28 // Called by ChromeBrowserMainPartsChromeOS in order to shutdown the 38 // Called by ChromeBrowserMainPartsChromeOS in order to shutdown the
29 // DeviceOAuth2TokenService instance and cancel all in-flight requests 39 // DeviceOAuth2TokenService instance and cancel all in-flight requests
30 // before the required global data is destroyed (local state and request 40 // before the required global data is destroyed (local state and request
31 // context getter). 41 // context getter).
32 static void Shutdown(); 42 static void Shutdown();
33 43
34 private: 44 private:
35 DeviceOAuth2TokenServiceFactory(); 45 DeviceOAuth2TokenServiceFactory();
46 ~DeviceOAuth2TokenServiceFactory();
47
48 DeviceOAuth2TokenService* token_service_;
36 49
37 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenServiceFactory); 50 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenServiceFactory);
38 }; 51 };
39 52
40 } // namespace chromeos 53 } // namespace chromeos
41 54
42 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_ H_ 55 #endif // CHROME_BROWSER_CHROMEOS_SETTINGS_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_ H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698