device_oauth2_token_service_factory.cc revision c2e0dbddbe15c98d52c4786dac06cb8952a8ae6d
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 "chrome/browser/browser_process.h"
8#include "chrome/browser/chromeos/settings/device_oauth2_token_service.h"
9#include "content/public/browser/browser_thread.h"
10
11namespace chromeos {
12
13static DeviceOAuth2TokenService* g_device_oauth2_token_service_ = NULL;
14
15DeviceOAuth2TokenServiceFactory::DeviceOAuth2TokenServiceFactory() {
16}
17
18// static
19DeviceOAuth2TokenService* DeviceOAuth2TokenServiceFactory::Get() {
20  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
21  return g_device_oauth2_token_service_;
22}
23
24// static
25void DeviceOAuth2TokenServiceFactory::Initialize() {
26  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
27  DCHECK(!g_device_oauth2_token_service_);
28  g_device_oauth2_token_service_ = new DeviceOAuth2TokenService(
29      g_browser_process->system_request_context(),
30      g_browser_process->local_state());
31}
32
33// static
34void DeviceOAuth2TokenServiceFactory::Shutdown() {
35  DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
36  if (g_device_oauth2_token_service_) {
37    delete g_device_oauth2_token_service_;
38    g_device_oauth2_token_service_ = NULL;
39  }
40}
41
42}  // namespace chromeos
43