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

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: Fix mac build 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
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..a33d967617a7153a11a9295202afad86a749141f
--- /dev/null
+++ b/chrome/browser/sessions/session_service_factory.cc
@@ -0,0 +1,57 @@
+// 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();
+
sky 2011/04/27 15:58:28 nit: nuke this line.
+ return service;
+}

Powered by Google App Engine
This is Rietveld 408576698