| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" | 5 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_factory.h
" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 7 #include "chrome/browser/browser_process.h" | 8 #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.h" |
| 9 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_delegate.
h" | 10 #include "chrome/browser/chromeos/settings/device_oauth2_token_service_delegate.
h" |
| 10 #include "chrome/browser/chromeos/settings/token_encryptor.h" | 11 #include "chrome/browser/chromeos/settings/token_encryptor.h" |
| 11 #include "chromeos/cryptohome/system_salt_getter.h" | 12 #include "chromeos/cryptohome/system_salt_getter.h" |
| 12 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 13 | 14 |
| 14 namespace chromeos { | 15 namespace chromeos { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 static DeviceOAuth2TokenService* g_device_oauth2_token_service_ = NULL; | 19 static DeviceOAuth2TokenService* g_device_oauth2_token_service_ = NULL; |
| 19 | 20 |
| 20 } // namespace | 21 } // namespace |
| 21 | 22 |
| 22 // static | 23 // static |
| 23 DeviceOAuth2TokenService* DeviceOAuth2TokenServiceFactory::Get() { | 24 DeviceOAuth2TokenService* DeviceOAuth2TokenServiceFactory::Get() { |
| 24 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 25 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 25 return g_device_oauth2_token_service_; | 26 return g_device_oauth2_token_service_; |
| 26 } | 27 } |
| 27 | 28 |
| 28 // static | 29 // static |
| 29 void DeviceOAuth2TokenServiceFactory::Initialize() { | 30 void DeviceOAuth2TokenServiceFactory::Initialize() { |
| 30 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 31 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 31 DCHECK(!g_device_oauth2_token_service_); | 32 DCHECK(!g_device_oauth2_token_service_); |
| 32 g_device_oauth2_token_service_ = | 33 g_device_oauth2_token_service_ = new DeviceOAuth2TokenService( |
| 33 new DeviceOAuth2TokenService(new DeviceOAuth2TokenServiceDelegate( | 34 base::MakeUnique<DeviceOAuth2TokenServiceDelegate>( |
| 34 g_browser_process->system_request_context(), | 35 g_browser_process->system_request_context(), |
| 35 g_browser_process->local_state())); | 36 g_browser_process->local_state())); |
| 36 } | 37 } |
| 37 | 38 |
| 38 // static | 39 // static |
| 39 void DeviceOAuth2TokenServiceFactory::Shutdown() { | 40 void DeviceOAuth2TokenServiceFactory::Shutdown() { |
| 40 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 41 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 41 if (g_device_oauth2_token_service_) { | 42 if (g_device_oauth2_token_service_) { |
| 42 delete g_device_oauth2_token_service_; | 43 delete g_device_oauth2_token_service_; |
| 43 g_device_oauth2_token_service_ = NULL; | 44 g_device_oauth2_token_service_ = NULL; |
| 44 } | 45 } |
| 45 } | 46 } |
| 46 | 47 |
| 47 } // namespace chromeos | 48 } // namespace chromeos |
| OLD | NEW |