1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/extension_garbage_collector_factory.h"
7 #include "base/memory/singleton.h"
8 #include "chrome/browser/extensions/extension_garbage_collector.h"
9 #include "chrome/browser/extensions/extension_system_factory.h"
10 #include "chrome/browser/extensions/install_tracker_factory.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12 #include "extensions/browser/extensions_browser_client.h"
14 #if defined(OS_CHROMEOS)
15 #include "chrome/browser/extensions/extension_garbage_collector_chromeos.h"
18 namespace extensions
{
21 ExtensionGarbageCollector
*
22 ExtensionGarbageCollectorFactory::GetForBrowserContext(
23 content::BrowserContext
* context
) {
24 return static_cast<ExtensionGarbageCollector
*>(
25 GetInstance()->GetServiceForBrowserContext(context
, true));
29 ExtensionGarbageCollectorFactory
*
30 ExtensionGarbageCollectorFactory::GetInstance() {
31 return Singleton
<ExtensionGarbageCollectorFactory
>::get();
34 ExtensionGarbageCollectorFactory::ExtensionGarbageCollectorFactory()
35 : BrowserContextKeyedServiceFactory(
36 "ExtensionGarbageCollector",
37 BrowserContextDependencyManager::GetInstance()) {
38 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
39 DependsOn(InstallTrackerFactory::GetInstance());
42 ExtensionGarbageCollectorFactory::~ExtensionGarbageCollectorFactory() {}
45 scoped_ptr
<KeyedService
> ExtensionGarbageCollectorFactory::BuildInstanceFor(
46 content::BrowserContext
* context
) {
47 #if defined(OS_CHROMEOS)
48 return make_scoped_ptr(new ExtensionGarbageCollectorChromeOS(context
));
50 return make_scoped_ptr(new ExtensionGarbageCollector(context
));
54 KeyedService
* ExtensionGarbageCollectorFactory::BuildServiceInstanceFor(
55 content::BrowserContext
* context
) const {
56 return BuildInstanceFor(context
).release();
59 bool ExtensionGarbageCollectorFactory::ServiceIsCreatedWithBrowserContext()
64 bool ExtensionGarbageCollectorFactory::ServiceIsNULLWhileTesting() const {
68 } // namespace extensions