| 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_HISTORY_SHORTCUTS_BACKEND_FACTORY_H_ | 5 #ifndef CHROME_BROWSER_HISTORY_SHORTCUTS_BACKEND_FACTORY_H_ |
| 6 #define CHROME_BROWSER_HISTORY_SHORTCUTS_BACKEND_FACTORY_H_ | 6 #define CHROME_BROWSER_HISTORY_SHORTCUTS_BACKEND_FACTORY_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
| 10 #include "components/browser_context_keyed_service/refcounted_browser_context_ke
yed_service_factory.h" | 10 #include "components/browser_context_keyed_service/refcounted_browser_context_ke
yed_service_factory.h" |
| 11 | 11 |
| 12 class Profile; | 12 class Profile; |
| 13 | 13 |
| 14 namespace history { | 14 namespace history { |
| 15 class ShortcutsBackend; | 15 class ShortcutsBackend; |
| 16 } // namespace history | 16 } // namespace history |
| 17 | 17 |
| 18 // Singleton that owns all instances of ShortcutsBackend and associates them | 18 // Singleton that owns all instances of ShortcutsBackend and associates them |
| 19 // with Profiles. | 19 // with Profiles. |
| 20 class ShortcutsBackendFactory : public RefcountedProfileKeyedServiceFactory { | 20 class ShortcutsBackendFactory |
| 21 : public RefcountedBrowserContextKeyedServiceFactory { |
| 21 public: | 22 public: |
| 22 static scoped_refptr<history::ShortcutsBackend> GetForProfile( | 23 static scoped_refptr<history::ShortcutsBackend> GetForProfile( |
| 23 Profile* profile); | 24 Profile* profile); |
| 24 | 25 |
| 25 static scoped_refptr<history::ShortcutsBackend> GetForProfileIfExists( | 26 static scoped_refptr<history::ShortcutsBackend> GetForProfileIfExists( |
| 26 Profile* profile); | 27 Profile* profile); |
| 27 | 28 |
| 28 static ShortcutsBackendFactory* GetInstance(); | 29 static ShortcutsBackendFactory* GetInstance(); |
| 29 | 30 |
| 30 // Creates and returns a backend for testing purposes. | 31 // Creates and returns a backend for testing purposes. |
| 31 static scoped_refptr<RefcountedProfileKeyedService> | 32 static scoped_refptr<RefcountedBrowserContextKeyedService> |
| 32 BuildProfileForTesting(content::BrowserContext* profile); | 33 BuildProfileForTesting(content::BrowserContext* profile); |
| 33 | 34 |
| 34 // Creates and returns a backend but without creating its persistent database | 35 // Creates and returns a backend but without creating its persistent database |
| 35 // for testing purposes. | 36 // for testing purposes. |
| 36 static scoped_refptr<RefcountedProfileKeyedService> | 37 static scoped_refptr<RefcountedBrowserContextKeyedService> |
| 37 BuildProfileNoDatabaseForTesting(content::BrowserContext* profile); | 38 BuildProfileNoDatabaseForTesting(content::BrowserContext* profile); |
| 38 | 39 |
| 39 private: | 40 private: |
| 40 friend struct DefaultSingletonTraits<ShortcutsBackendFactory>; | 41 friend struct DefaultSingletonTraits<ShortcutsBackendFactory>; |
| 41 | 42 |
| 42 ShortcutsBackendFactory(); | 43 ShortcutsBackendFactory(); |
| 43 virtual ~ShortcutsBackendFactory(); | 44 virtual ~ShortcutsBackendFactory(); |
| 44 | 45 |
| 45 // ProfileKeyedServiceFactory: | 46 // BrowserContextKeyedServiceFactory: |
| 46 virtual scoped_refptr<RefcountedProfileKeyedService> BuildServiceInstanceFor( | 47 virtual scoped_refptr<RefcountedBrowserContextKeyedService> |
| 47 content::BrowserContext* profile) const OVERRIDE; | 48 BuildServiceInstanceFor(content::BrowserContext* profile) const OVERRIDE; |
| 48 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE; | 49 virtual bool ServiceIsNULLWhileTesting() const OVERRIDE; |
| 49 }; | 50 }; |
| 50 | 51 |
| 51 #endif // CHROME_BROWSER_HISTORY_SHORTCUTS_BACKEND_FACTORY_H_ | 52 #endif // CHROME_BROWSER_HISTORY_SHORTCUTS_BACKEND_FACTORY_H_ |
| OLD | NEW |