Roll src/third_party/WebKit d9c6159:8139f33 (svn 201974:201975)
[chromium-blink-merge.git] / chrome / browser / chromeos / settings / device_oauth2_token_service_factory.cc
blob5d6ae0bc38d6b4028b7181e15f55dc26343e1e35
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.
5 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h"
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
9 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_delegate.h"
10 #include "chrome/browser/chromeos/settings/token_encryptor.h"
11 #include "chromeos/cryptohome/system_salt_getter.h"
12 #include "content/public/browser/browser_thread.h"
14 namespace chromeos {
16 namespace {
18 static DeviceOAuth2TokenService* g_device_oauth2_token_service_ = NULL;
20 } // namespace
22 // static
23 DeviceOAuth2TokenService* DeviceOAuth2TokenServiceFactory::Get() {
24 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
25 return g_device_oauth2_token_service_;
28 // static
29 void DeviceOAuth2TokenServiceFactory::Initialize() {
30 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
31 DCHECK(!g_device_oauth2_token_service_);
32 g_device_oauth2_token_service_ =
33 new DeviceOAuth2TokenService(new DeviceOAuth2TokenServiceDelegate(
34 g_browser_process->system_request_context(),
35 g_browser_process->local_state()));
38 // static
39 void DeviceOAuth2TokenServiceFactory::Shutdown() {
40 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
41 if (g_device_oauth2_token_service_) {
42 delete g_device_oauth2_token_service_;
43 g_device_oauth2_token_service_ = NULL;
47 } // namespace chromeos