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 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_DEVICE_IDENTITY_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_H_ 6 #define CHROME_BROWSER_DEVICE_IDENTITY_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_H_ 7 8 #include <queue> 9 #include <string> 10 11 #include "base/macros.h" 12 #include "base/memory/ref_counted.h" 13 14 class PrefService; 15 16 namespace network { 17 class SharedURLLoaderFactory; 18 } 19 20 class DeviceOAuth2TokenService; 21 22 class DeviceOAuth2TokenServiceFactory { 23 public: 24 // Returns the instance of the DeviceOAuth2TokenService singleton. May return 25 // nullptr during browser startup and shutdown. When calling Get(), either 26 // make sure that your code executes after browser startup and before shutdown 27 // or be careful to call Get() every time (instead of holding a pointer) and 28 // check for nullptr to handle cases where you might access 29 // DeviceOAuth2TokenService during startup or shutdown. 30 static DeviceOAuth2TokenService* Get(); 31 32 // Called by ChromeBrowserMainPartsChromeOS in order to bootstrap the 33 // DeviceOAuth2TokenService instance after the required global data is 34 // available (local state, url loader and CrosSettings). 35 static void Initialize( 36 scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory, 37 PrefService* local_state); 38 39 // Called by ChromeBrowserMainPartsChromeOS in order to shutdown the 40 // DeviceOAuth2TokenService instance and cancel all in-flight requests before 41 // the required global data is destroyed (local state, request context getter 42 // and CrosSettings). 43 static void Shutdown(); 44 45 private: 46 DeviceOAuth2TokenServiceFactory(); 47 ~DeviceOAuth2TokenServiceFactory(); 48 49 DISALLOW_COPY_AND_ASSIGN(DeviceOAuth2TokenServiceFactory); 50 }; 51 52 #endif // CHROME_BROWSER_DEVICE_IDENTITY_DEVICE_OAUTH2_TOKEN_SERVICE_FACTORY_H_ 53