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

Unified Diff: chrome/browser/sessions/session_service_factory.cc

Issue 6901031: Profile shouldn't own Session/TabRestore services. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase again and hope upload works this time Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sessions/session_service_factory.h ('k') | chrome/browser/sessions/tab_restore_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sessions/session_service_factory.cc
diff --git a/chrome/browser/sessions/session_service_factory.cc b/chrome/browser/sessions/session_service_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3a93dfb5fd08a6a52faa7da08c1e2736d97aad18
--- /dev/null
+++ b/chrome/browser/sessions/session_service_factory.cc
@@ -0,0 +1,56 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/sessions/session_service_factory.h"
+
+#include "chrome/browser/profiles/profile_dependency_manager.h"
+#include "chrome/browser/sessions/session_service.h"
+
+// static
+SessionService* SessionServiceFactory::GetForProfile(Profile* profile) {
+ return static_cast<SessionService*>(
+ GetInstance()->GetServiceForProfile(profile, true));
+}
+
+// static
+SessionService* SessionServiceFactory::GetForProfileIfExisting(
+ Profile* profile) {
+ return static_cast<SessionService*>(
+ GetInstance()->GetServiceForProfile(profile, false));
+}
+
+// static
+void SessionServiceFactory::ShutdownForProfile(Profile* profile) {
+ // We're about to exit, force creation of the session service if it hasn't
+ // been created yet. We do this to ensure session state matches the point in
+ // time the user exited.
+ SessionServiceFactory* factory = GetInstance();
+ factory->GetServiceForProfile(profile, true);
+
+ // Shut down and remove the reference to the session service, and replace it
+ // with an explicit NULL to prevent it being recreated on the next access.
+ factory->ProfileShutdown(profile);
+ factory->ProfileDestroyed(profile);
+ factory->Associate(profile, NULL);
+}
+
+SessionServiceFactory* SessionServiceFactory::GetInstance() {
+ return Singleton<SessionServiceFactory>::get();
+}
+
+SessionServiceFactory::SessionServiceFactory()
+ : ProfileKeyedServiceFactory(
+ ProfileDependencyManager::GetInstance()) {
+}
+
+SessionServiceFactory::~SessionServiceFactory() {
+}
+
+ProfileKeyedService* SessionServiceFactory::BuildServiceInstanceFor(
+ Profile* profile) const {
+ SessionService* service = NULL;
+ service = new SessionService(profile);
+ service->ResetFromCurrentBrowsers();
+ return service;
+}
« no previous file with comments | « chrome/browser/sessions/session_service_factory.h ('k') | chrome/browser/sessions/tab_restore_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698