OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h " | |
6 | |
7 #include "base/lazy_instance.h" | |
8 #include "chrome/browser/browser_process.h" | |
9 #include "content/public/browser/browser_thread.h" | |
10 | |
11 namespace chromeos { | |
12 | |
13 static base::LazyInstance<DeviceOAuth2TokenServiceFactory> | |
14 g_device_oauth2_token_service_factory_ = LAZY_INSTANCE_INITIALIZER; | |
15 | |
16 DeviceOAuth2TokenServiceFactory::DeviceOAuth2TokenServiceFactory() { | |
17 } | |
18 | |
19 DeviceOAuth2TokenServiceFactory::~DeviceOAuth2TokenServiceFactory() { | |
20 // The OAuth2TokenService destructor will cancel all pending fetchers. | |
21 } | |
22 | |
23 // static | |
24 DeviceOAuth2TokenService* DeviceOAuth2TokenServiceFactory::Get() { | |
25 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
26 DeviceOAuth2TokenServiceFactory factory = | |
27 g_device_oauth2_token_service_factory_.Get(); | |
28 | |
29 return factory.GetImpl(); | |
30 } | |
31 | |
32 DeviceOAuth2TokenService* DeviceOAuth2TokenServiceFactory::GetImpl() { | |
33 if (!device_oauth2_token_service_) { | |
34 device_oauth2_token_service_.reset( | |
35 new DeviceOAuth2TokenService( | |
36 g_browser_process->system_request_context())); | |
Mattias Nissler (ping if slow)
2013/03/21 06:59:15
Ha, so the factory design is broken here after all
David Roche
2013/03/21 20:36:31
The factory singleton doesn't have an external dep
| |
37 } | |
38 return device_oauth2_token_service_.get(); | |
39 } | |
40 | |
41 } // namespace chromeos | |
OLD | NEW |