| OLD | NEW |
| 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_data_deleter.h" |
| 8 #include "chrome/browser/sessions/session_service.h" | 9 #include "chrome/browser/sessions/session_service.h" |
| 9 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 10 | 11 |
| 11 // static | 12 // static |
| 12 SessionService* SessionServiceFactory::GetForProfile(Profile* profile) { | 13 SessionService* SessionServiceFactory::GetForProfile(Profile* profile) { |
| 13 #if defined(OS_ANDROID) | 14 #if defined(OS_ANDROID) |
| 14 // For Android we do not store sessions in the SessionService. | 15 // For Android we do not store sessions in the SessionService. |
| 15 return NULL; | 16 return NULL; |
| 16 #else | 17 #else |
| 17 return static_cast<SessionService*>( | 18 return static_cast<SessionService*>( |
| 18 GetInstance()->GetServiceForBrowserContext(profile, true)); | 19 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 19 #endif | 20 #endif |
| 20 } | 21 } |
| 21 | 22 |
| 22 // static | 23 // static |
| 23 SessionService* SessionServiceFactory::GetForProfileIfExisting( | 24 SessionService* SessionServiceFactory::GetForProfileIfExisting( |
| 24 Profile* profile) { | 25 Profile* profile) { |
| 25 #if defined(OS_ANDROID) | 26 #if defined(OS_ANDROID) |
| 26 // For Android we do not store sessions in the SessionService. | 27 // For Android we do not store sessions in the SessionService. |
| 27 return NULL; | 28 return NULL; |
| 28 #else | 29 #else |
| 29 return static_cast<SessionService*>( | 30 return static_cast<SessionService*>( |
| 30 GetInstance()->GetServiceForBrowserContext(profile, false)); | 31 GetInstance()->GetServiceForBrowserContext(profile, false)); |
| 31 #endif | 32 #endif |
| 32 } | 33 } |
| 33 | 34 |
| 34 // static | 35 // static |
| 35 void SessionServiceFactory::ShutdownForProfile(Profile* profile) { | 36 void SessionServiceFactory::ShutdownForProfile(Profile* profile) { |
| 37 DeleteSessionOnlyData(profile); |
| 38 |
| 36 // We're about to exit, force creation of the session service if it hasn't | 39 // 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 | 40 // been created yet. We do this to ensure session state matches the point in |
| 38 // time the user exited. | 41 // time the user exited. |
| 39 SessionServiceFactory* factory = GetInstance(); | 42 SessionServiceFactory* factory = GetInstance(); |
| 40 factory->GetServiceForBrowserContext(profile, true); | 43 factory->GetServiceForBrowserContext(profile, true); |
| 41 | 44 |
| 42 // Shut down and remove the reference to the session service, and replace it | 45 // 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. | 46 // with an explicit NULL to prevent it being recreated on the next access. |
| 44 factory->BrowserContextShutdown(profile); | 47 factory->BrowserContextShutdown(profile); |
| 45 factory->BrowserContextDestroyed(profile); | 48 factory->BrowserContextDestroyed(profile); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 67 return service; | 70 return service; |
| 68 } | 71 } |
| 69 | 72 |
| 70 bool SessionServiceFactory::ServiceIsCreatedWithBrowserContext() const { | 73 bool SessionServiceFactory::ServiceIsCreatedWithBrowserContext() const { |
| 71 return true; | 74 return true; |
| 72 } | 75 } |
| 73 | 76 |
| 74 bool SessionServiceFactory::ServiceIsNULLWhileTesting() const { | 77 bool SessionServiceFactory::ServiceIsNULLWhileTesting() const { |
| 75 return true; | 78 return true; |
| 76 } | 79 } |
| OLD | NEW |