Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(454)

Side by Side Diff: chrome/browser/chromeos/settings/device_oauth2_token_service_factory.cc

Issue 12647008: Refactor OAuth2TokenService to have profile- and device-based implementations. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reverted g_browser_process integration and re-instated factory, with added initialize/shutdown. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 }
21
22 // static
23 DeviceOAuth2TokenService* DeviceOAuth2TokenServiceFactory::Get() {
24 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
25 DeviceOAuth2TokenServiceFactory factory =
26 g_device_oauth2_token_service_factory_.Get();
27
28 return factory.GetImpl();
Mattias Nissler (ping if slow) 2013/04/03 11:33:16 It seems like a simpler implementation could be to
David Roche 2013/04/03 16:34:09 Done.
29 }
30
31 DeviceOAuth2TokenService* DeviceOAuth2TokenServiceFactory::GetImpl() {
32 return device_oauth2_token_service_.get();
33 }
34
35 // static
36 void DeviceOAuth2TokenServiceFactory::Initialize() {
37 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
38 g_device_oauth2_token_service_factory_.Get().InitializeImpl();
39 }
40
41 void DeviceOAuth2TokenServiceFactory::InitializeImpl() {
42 DCHECK(!device_oauth2_token_service_);
43 device_oauth2_token_service_.reset(
44 new DeviceOAuth2TokenService(
45 g_browser_process->system_request_context(),
46 g_browser_process->local_state()));
47 }
48
49 // static
50 void DeviceOAuth2TokenServiceFactory::Shutdown() {
51 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
52 g_device_oauth2_token_service_factory_.Get().ShutdownImpl();
53 }
54
55 void DeviceOAuth2TokenServiceFactory::ShutdownImpl() {
56 if (device_oauth2_token_service_.get()) {
Mattias Nissler (ping if slow) 2013/04/03 11:33:16 nit: no need for curlies here.
David Roche 2013/04/03 16:34:09 Done.
57 device_oauth2_token_service_->Shutdown();
Mattias Nissler (ping if slow) 2013/04/03 11:33:16 Shouldn't we just destroy the object here?
David Roche 2013/04/03 16:34:09 Done.
58 }
59 }
60
61 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698