• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "chrome/browser/extensions/extension_garbage_collector_factory.h"
6 
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"
13 
14 #if defined(OS_CHROMEOS)
15 #include "chrome/browser/extensions/extension_garbage_collector_chromeos.h"
16 #endif
17 
18 namespace extensions {
19 
20 // static
21 ExtensionGarbageCollector*
GetForBrowserContext(content::BrowserContext * context)22 ExtensionGarbageCollectorFactory::GetForBrowserContext(
23     content::BrowserContext* context) {
24   return static_cast<ExtensionGarbageCollector*>(
25       GetInstance()->GetServiceForBrowserContext(context, true));
26 }
27 
28 // static
29 ExtensionGarbageCollectorFactory*
GetInstance()30 ExtensionGarbageCollectorFactory::GetInstance() {
31   return Singleton<ExtensionGarbageCollectorFactory>::get();
32 }
33 
ExtensionGarbageCollectorFactory()34 ExtensionGarbageCollectorFactory::ExtensionGarbageCollectorFactory()
35     : BrowserContextKeyedServiceFactory(
36           "ExtensionGarbageCollector",
37           BrowserContextDependencyManager::GetInstance()) {
38   DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
39   DependsOn(InstallTrackerFactory::GetInstance());
40 }
41 
~ExtensionGarbageCollectorFactory()42 ExtensionGarbageCollectorFactory::~ExtensionGarbageCollectorFactory() {}
43 
44 // static
BuildInstanceFor(content::BrowserContext * context)45 KeyedService* ExtensionGarbageCollectorFactory::BuildInstanceFor(
46     content::BrowserContext* context) {
47 #if defined(OS_CHROMEOS)
48   return new ExtensionGarbageCollectorChromeOS(context);
49 #else
50   return new ExtensionGarbageCollector(context);
51 #endif
52 }
53 
BuildServiceInstanceFor(content::BrowserContext * context) const54 KeyedService* ExtensionGarbageCollectorFactory::BuildServiceInstanceFor(
55     content::BrowserContext* context) const {
56   return BuildInstanceFor(context);
57 }
58 
ServiceIsCreatedWithBrowserContext() const59 bool ExtensionGarbageCollectorFactory::ServiceIsCreatedWithBrowserContext()
60     const {
61   return true;
62 }
63 
ServiceIsNULLWhileTesting() const64 bool ExtensionGarbageCollectorFactory::ServiceIsNULLWhileTesting() const {
65   return true;
66 }
67 
68 }  // namespace extensions
69