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 #ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_SERVICE_FACTORY_H_ |
6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_FACTORY_H_ | 6 #define CHROME_BROWSER_SESSIONS_SESSION_SERVICE_FACTORY_H_ |
7 | 7 |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/sessions/session_service.h" | 10 #include "chrome/browser/sessions/session_service.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 static SessionService* GetForProfileForSessionRestore(Profile* profile); | 37 static SessionService* GetForProfileForSessionRestore(Profile* profile); |
38 | 38 |
39 // If |profile| has a session service, it is shut down. To properly record the | 39 // If |profile| has a session service, it is shut down. To properly record the |
40 // current state this forces creation of the session service, then shuts it | 40 // current state this forces creation of the session service, then shuts it |
41 // down. | 41 // down. |
42 static void ShutdownForProfile(Profile* profile); | 42 static void ShutdownForProfile(Profile* profile); |
43 | 43 |
44 #if defined(UNIT_TEST) | 44 #if defined(UNIT_TEST) |
45 // For test use: force setting of the session service for a given profile. | 45 // For test use: force setting of the session service for a given profile. |
46 // This will delete a previous session service for this profile if it exists. | 46 // This will delete a previous session service for this profile if it exists. |
47 static void SetForTestProfile(Profile* profile, SessionService* service) { | 47 static void SetForTestProfile(Profile* profile, |
| 48 scoped_ptr<SessionService> service) { |
48 GetInstance()->BrowserContextShutdown(profile); | 49 GetInstance()->BrowserContextShutdown(profile); |
49 GetInstance()->BrowserContextDestroyed(profile); | 50 GetInstance()->BrowserContextDestroyed(profile); |
50 GetInstance()->Associate(profile, service); | 51 GetInstance()->Associate(profile, service.Pass()); |
51 } | 52 } |
52 #endif | 53 #endif |
53 | 54 |
54 static SessionServiceFactory* GetInstance(); | 55 static SessionServiceFactory* GetInstance(); |
55 | 56 |
56 private: | 57 private: |
57 friend struct DefaultSingletonTraits<SessionServiceFactory>; | 58 friend struct DefaultSingletonTraits<SessionServiceFactory>; |
58 FRIEND_TEST_ALL_PREFIXES(SessionCrashedInfoBarDelegateUnitTest, | 59 FRIEND_TEST_ALL_PREFIXES(SessionCrashedInfoBarDelegateUnitTest, |
59 DetachingTabWithCrashedInfoBar); | 60 DetachingTabWithCrashedInfoBar); |
60 | 61 |
61 SessionServiceFactory(); | 62 SessionServiceFactory(); |
62 ~SessionServiceFactory() override; | 63 ~SessionServiceFactory() override; |
63 | 64 |
64 // BrowserContextKeyedServiceFactory: | 65 // BrowserContextKeyedServiceFactory: |
65 KeyedService* BuildServiceInstanceFor( | 66 KeyedService* BuildServiceInstanceFor( |
66 content::BrowserContext* profile) const override; | 67 content::BrowserContext* profile) const override; |
67 bool ServiceIsCreatedWithBrowserContext() const override; | 68 bool ServiceIsCreatedWithBrowserContext() const override; |
68 bool ServiceIsNULLWhileTesting() const override; | 69 bool ServiceIsNULLWhileTesting() const override; |
69 }; | 70 }; |
70 | 71 |
71 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_FACTORY_H_ | 72 #endif // CHROME_BROWSER_SESSIONS_SESSION_SERVICE_FACTORY_H_ |
OLD | NEW |