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