Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 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/sessions/session_service_factory.h" | |
| 6 | |
| 7 #include "chrome/browser/profiles/profile_dependency_manager.h" | |
| 8 #include "chrome/browser/sessions/session_service.h" | |
| 9 | |
| 10 // static | |
| 11 SessionService* SessionServiceFactory::GetForProfile(Profile* profile) { | |
| 12 return static_cast<SessionService*>( | |
| 13 GetInstance()->GetServiceForProfile(profile, true)); | |
| 14 } | |
| 15 | |
| 16 // static | |
| 17 SessionService* SessionServiceFactory::GetForProfileIfExisting( | |
| 18 Profile* profile) { | |
| 19 return static_cast<SessionService*>( | |
| 20 GetInstance()->GetServiceForProfile(profile, false)); | |
| 21 } | |
| 22 | |
| 23 // static | |
| 24 void SessionServiceFactory::ShutdownForProfile(Profile* profile) { | |
| 25 // We're about to exit, force creation of the session service if it hasn't | |
| 26 // been created yet. We do this to ensure session state matches the point in | |
| 27 // time the user exited. | |
| 28 SessionServiceFactory* factory = GetInstance(); | |
| 29 factory->GetServiceForProfile(profile, true); | |
| 30 | |
| 31 // Shut down and remove the reference to the session service, and replace it | |
| 32 // with an explicit NULL to prevent it being recreated on the next access. | |
| 33 factory->ProfileShutdown(profile); | |
| 34 factory->ProfileDestroyed(profile); | |
| 35 factory->Associate(profile, NULL); | |
| 36 } | |
| 37 | |
| 38 SessionServiceFactory* SessionServiceFactory::GetInstance() { | |
| 39 return Singleton<SessionServiceFactory>::get(); | |
| 40 } | |
| 41 | |
| 42 SessionServiceFactory::SessionServiceFactory() | |
| 43 : ProfileKeyedServiceFactory( | |
| 44 ProfileDependencyManager::GetInstance()) { | |
| 45 } | |
| 46 | |
| 47 SessionServiceFactory::~SessionServiceFactory() { | |
| 48 } | |
| 49 | |
| 50 ProfileKeyedService* SessionServiceFactory::BuildServiceInstanceFor( | |
| 51 Profile* profile) const { | |
| 52 SessionService* service = NULL; | |
| 53 service = new SessionService(profile); | |
| 54 service->ResetFromCurrentBrowsers(); | |
| 55 | |
|
sky
2011/04/27 15:58:28
nit: nuke this line.
| |
| 56 return service; | |
| 57 } | |
| OLD | NEW |