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

Side by Side Diff: chrome/browser/sessions/session_service_factory.cc

Issue 15517005: Remove references to Profile from browser_context_keyed_service. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase & style Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
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/sessions/session_service_factory.h" 5 #include "chrome/browser/sessions/session_service_factory.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/sessions/session_service.h" 8 #include "chrome/browser/sessions/session_service.h"
9 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 9 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
10 10
11 // static 11 // static
12 SessionService* SessionServiceFactory::GetForProfile(Profile* profile) { 12 SessionService* SessionServiceFactory::GetForProfile(Profile* profile) {
13 #if defined(OS_ANDROID) 13 #if defined(OS_ANDROID)
14 // For Android we do not store sessions in the SessionService. 14 // For Android we do not store sessions in the SessionService.
15 return NULL; 15 return NULL;
16 #else 16 #else
17 return static_cast<SessionService*>( 17 return static_cast<SessionService*>(
18 GetInstance()->GetServiceForProfile(profile, true)); 18 GetInstance()->GetServiceForBrowserContext(profile, true));
19 #endif 19 #endif
20 } 20 }
21 21
22 // static 22 // static
23 SessionService* SessionServiceFactory::GetForProfileIfExisting( 23 SessionService* SessionServiceFactory::GetForProfileIfExisting(
24 Profile* profile) { 24 Profile* profile) {
25 #if defined(OS_ANDROID) 25 #if defined(OS_ANDROID)
26 // For Android we do not store sessions in the SessionService. 26 // For Android we do not store sessions in the SessionService.
27 return NULL; 27 return NULL;
28 #else 28 #else
29 return static_cast<SessionService*>( 29 return static_cast<SessionService*>(
30 GetInstance()->GetServiceForProfile(profile, false)); 30 GetInstance()->GetServiceForBrowserContext(profile, false));
31 #endif 31 #endif
32 } 32 }
33 33
34 // static 34 // static
35 void SessionServiceFactory::ShutdownForProfile(Profile* profile) { 35 void SessionServiceFactory::ShutdownForProfile(Profile* profile) {
36 // We're about to exit, force creation of the session service if it hasn't 36 // We're about to exit, force creation of the session service if it hasn't
37 // been created yet. We do this to ensure session state matches the point in 37 // been created yet. We do this to ensure session state matches the point in
38 // time the user exited. 38 // time the user exited.
39 SessionServiceFactory* factory = GetInstance(); 39 SessionServiceFactory* factory = GetInstance();
40 factory->GetServiceForProfile(profile, true); 40 factory->GetServiceForBrowserContext(profile, true);
41 41
42 // Shut down and remove the reference to the session service, and replace it 42 // Shut down and remove the reference to the session service, and replace it
43 // with an explicit NULL to prevent it being recreated on the next access. 43 // with an explicit NULL to prevent it being recreated on the next access.
44 factory->ProfileShutdown(profile); 44 factory->BrowserContextShutdown(profile);
45 factory->ProfileDestroyed(profile); 45 factory->BrowserContextDestroyed(profile);
46 factory->Associate(profile, NULL); 46 factory->Associate(profile, NULL);
47 } 47 }
48 48
49 SessionServiceFactory* SessionServiceFactory::GetInstance() { 49 SessionServiceFactory* SessionServiceFactory::GetInstance() {
50 return Singleton<SessionServiceFactory>::get(); 50 return Singleton<SessionServiceFactory>::get();
51 } 51 }
52 52
53 SessionServiceFactory::SessionServiceFactory() 53 SessionServiceFactory::SessionServiceFactory()
54 : ProfileKeyedServiceFactory("SessionService", 54 : BrowserContextKeyedServiceFactory(
55 ProfileDependencyManager::GetInstance()) { 55 "SessionService",
56 BrowserContextDependencyManager::GetInstance()) {
56 } 57 }
57 58
58 SessionServiceFactory::~SessionServiceFactory() { 59 SessionServiceFactory::~SessionServiceFactory() {
59 } 60 }
60 61
61 ProfileKeyedService* SessionServiceFactory::BuildServiceInstanceFor( 62 BrowserContextKeyedService* SessionServiceFactory::BuildServiceInstanceFor(
62 content::BrowserContext* profile) const { 63 content::BrowserContext* profile) const {
63 SessionService* service = NULL; 64 SessionService* service = NULL;
64 service = new SessionService(static_cast<Profile*>(profile)); 65 service = new SessionService(static_cast<Profile*>(profile));
65 service->ResetFromCurrentBrowsers(); 66 service->ResetFromCurrentBrowsers();
66 return service; 67 return service;
67 } 68 }
68 69
69 bool SessionServiceFactory::ServiceIsCreatedWithProfile() const { 70 bool SessionServiceFactory::ServiceIsCreatedWithBrowserContext() const {
70 return true; 71 return true;
71 } 72 }
72 73
73 bool SessionServiceFactory::ServiceIsNULLWhileTesting() const { 74 bool SessionServiceFactory::ServiceIsNULLWhileTesting() const {
74 return true; 75 return true;
75 } 76 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698