summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjuncai <juncai@chromium.org>2015-05-20 15:20:13 -0700
committerCommit bot <commit-bot@chromium.org>2015-05-20 22:20:17 +0000
commit07ea53870ed17c6f4f410c5ae0838cf4fceec1c3 (patch)
treec4f81ad24ce989b62095730e369c628677b5805c
parentfc092256287403e7326635e2a818a00d43269947 (diff)
downloadchromium_src-07ea53870ed17c6f4f410c5ae0838cf4fceec1c3.zip
chromium_src-07ea53870ed17c6f4f410c5ae0838cf4fceec1c3.tar.gz
chromium_src-07ea53870ed17c6f4f410c5ae0838cf4fceec1c3.tar.bz2
Extract LazyBackgroundTaskQueue from ExtensionSystem.
This patch removes lazy_background_task_queue accessor from ExtensionSystem. It can be its own browser context keyed service. It can be built by its new factory. Review URL: https://codereview.chromium.org/1129063011 Cr-Commit-Position: refs/heads/master@{#330815}
-rw-r--r--apps/launcher.cc4
-rw-r--r--chrome/browser/chromeos/file_manager/file_browser_handlers.cc4
-rw-r--r--chrome/browser/extensions/api/messaging/message_service.cc2
-rw-r--r--chrome/browser/extensions/devtools_util.cc4
-rw-r--r--chrome/browser/extensions/extension_system_impl.cc10
-rw-r--r--chrome/browser/extensions/extension_system_impl.h3
-rw-r--r--chrome/browser/extensions/test_extension_system.cc9
-rw-r--r--chrome/browser/extensions/test_extension_system.h6
-rw-r--r--chrome/browser/signin/easy_unlock_app_manager_unittest.cc1
-rw-r--r--extensions/browser/api/runtime/runtime_api.cc26
-rw-r--r--extensions/browser/event_router.cc7
-rw-r--r--extensions/browser/extension_system.h4
-rw-r--r--extensions/browser/guest_view/app_view/app_view_guest.cc2
-rw-r--r--extensions/browser/lazy_background_task_queue.cc7
-rw-r--r--extensions/browser/lazy_background_task_queue.h8
-rw-r--r--extensions/browser/lazy_background_task_queue_factory.cc50
-rw-r--r--extensions/browser/lazy_background_task_queue_factory.h39
-rw-r--r--extensions/browser/mock_extension_system.cc4
-rw-r--r--extensions/browser/mock_extension_system.h1
-rw-r--r--extensions/browser/process_manager.cc2
-rw-r--r--extensions/extensions.gypi2
-rw-r--r--extensions/shell/browser/shell_extension_system.cc7
-rw-r--r--extensions/shell/browser/shell_extension_system.h3
23 files changed, 126 insertions, 79 deletions
diff --git a/apps/launcher.cc b/apps/launcher.cc
index cda74ac..d5ca792 100644
--- a/apps/launcher.cc
+++ b/apps/launcher.cc
@@ -28,7 +28,6 @@
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
-#include "extensions/browser/extension_system.h"
#include "extensions/browser/granted_file_entry.h"
#include "extensions/browser/lazy_background_task_queue.h"
#include "extensions/browser/process_manager.h"
@@ -56,7 +55,6 @@ using extensions::app_file_handler_util::PrepareFilesForWritableApp;
using extensions::EventRouter;
using extensions::Extension;
using extensions::ExtensionHost;
-using extensions::ExtensionSystem;
using extensions::GrantedFileEntry;
namespace apps {
@@ -261,7 +259,7 @@ class PlatformAppPathLauncher
// the lazy background task queue is used to load the extension and then
// call back to us.
extensions::LazyBackgroundTaskQueue* const queue =
- ExtensionSystem::Get(profile_)->lazy_background_task_queue();
+ extensions::LazyBackgroundTaskQueue::Get(profile_);
if (queue->ShouldEnqueueTask(profile_, extension)) {
queue->AddPendingTask(
profile_, extension_id,
diff --git a/chrome/browser/chromeos/file_manager/file_browser_handlers.cc b/chrome/browser/chromeos/file_manager/file_browser_handlers.cc
index da0aebd..34828d5 100644
--- a/chrome/browser/chromeos/file_manager/file_browser_handlers.cc
+++ b/chrome/browser/chromeos/file_manager/file_browser_handlers.cc
@@ -32,7 +32,6 @@
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
-#include "extensions/browser/extension_system.h"
#include "extensions/browser/extension_util.h"
#include "extensions/browser/lazy_background_task_queue.h"
#include "extensions/common/extension_set.h"
@@ -349,8 +348,7 @@ void FileBrowserHandlerExecutor::ExecuteFileActionsOnUIThread(
} else {
// We have to wake the handler background page before we proceed.
extensions::LazyBackgroundTaskQueue* queue =
- extensions::ExtensionSystem::Get(profile_)->
- lazy_background_task_queue();
+ extensions::LazyBackgroundTaskQueue::Get(profile_);
if (!queue->ShouldEnqueueTask(profile_, extension_.get())) {
ExecuteDoneOnUIThread(false);
return;
diff --git a/chrome/browser/extensions/api/messaging/message_service.cc b/chrome/browser/extensions/api/messaging/message_service.cc
index 0372d63..c35b377 100644
--- a/chrome/browser/extensions/api/messaging/message_service.cc
+++ b/chrome/browser/extensions/api/messaging/message_service.cc
@@ -218,7 +218,7 @@ void MessageService::AllocatePortIdPair(int* port1, int* port2) {
MessageService::MessageService(BrowserContext* context)
: lazy_background_task_queue_(
- ExtensionSystem::Get(context)->lazy_background_task_queue()),
+ LazyBackgroundTaskQueue::Get(context)),
weak_factory_(this) {
registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_TERMINATED,
content::NotificationService::AllBrowserContextsAndSources());
diff --git a/chrome/browser/extensions/devtools_util.cc b/chrome/browser/extensions/devtools_util.cc
index 8f75ac7..722f8c0 100644
--- a/chrome/browser/extensions/devtools_util.cc
+++ b/chrome/browser/extensions/devtools_util.cc
@@ -7,7 +7,6 @@
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/profiles/profile.h"
#include "extensions/browser/extension_host.h"
-#include "extensions/browser/extension_system.h"
#include "extensions/browser/lazy_background_task_queue.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/extension.h"
@@ -27,13 +26,12 @@ void InspectExtensionHost(ExtensionHost* host) {
void InspectBackgroundPage(const Extension* extension, Profile* profile) {
DCHECK(extension);
- ExtensionSystem* system = ExtensionSystem::Get(profile);
ExtensionHost* host = ProcessManager::Get(profile)
->GetBackgroundHostForExtension(extension->id());
if (host) {
InspectExtensionHost(host);
} else {
- system->lazy_background_task_queue()->AddPendingTask(
+ LazyBackgroundTaskQueue::Get(profile)->AddPendingTask(
profile,
extension->id(),
base::Bind(&InspectExtensionHost));
diff --git a/chrome/browser/extensions/extension_system_impl.cc b/chrome/browser/extensions/extension_system_impl.cc
index acaaf97..667a693 100644
--- a/chrome/browser/extensions/extension_system_impl.cc
+++ b/chrome/browser/extensions/extension_system_impl.cc
@@ -99,7 +99,6 @@ ExtensionSystemImpl::Shared::~Shared() {
}
void ExtensionSystemImpl::Shared::InitPrefs() {
- lazy_background_task_queue_.reset(new LazyBackgroundTaskQueue(profile_));
event_router_.reset(new EventRouter(profile_, ExtensionPrefs::Get(profile_)));
// Two state stores. The latter, which contains declarative rules, must be
// loaded immediately so that the rules are ready before we issue network
@@ -431,11 +430,6 @@ InfoMap* ExtensionSystemImpl::Shared::info_map() {
return extension_info_map_.get();
}
-LazyBackgroundTaskQueue*
- ExtensionSystemImpl::Shared::lazy_background_task_queue() {
- return lazy_background_task_queue_.get();
-}
-
EventRouter* ExtensionSystemImpl::Shared::event_router() {
return event_router_.get();
}
@@ -504,10 +498,6 @@ StateStore* ExtensionSystemImpl::rules_store() {
InfoMap* ExtensionSystemImpl::info_map() { return shared_->info_map(); }
-LazyBackgroundTaskQueue* ExtensionSystemImpl::lazy_background_task_queue() {
- return shared_->lazy_background_task_queue();
-}
-
EventRouter* ExtensionSystemImpl::event_router() {
return shared_->event_router();
}
diff --git a/chrome/browser/extensions/extension_system_impl.h b/chrome/browser/extensions/extension_system_impl.h
index 151a8cb..f4b19c4 100644
--- a/chrome/browser/extensions/extension_system_impl.h
+++ b/chrome/browser/extensions/extension_system_impl.h
@@ -42,7 +42,6 @@ class ExtensionSystemImpl : public ExtensionSystem {
SharedUserScriptMaster* shared_user_script_master() override; // shared
StateStore* state_store() override; // shared
StateStore* rules_store() override; // shared
- LazyBackgroundTaskQueue* lazy_background_task_queue() override; // shared
InfoMap* info_map() override; // shared
EventRouter* event_router() override; // shared
QuotaService* quota_service() override; // shared
@@ -85,7 +84,6 @@ class ExtensionSystemImpl : public ExtensionSystem {
ManagementPolicy* management_policy();
SharedUserScriptMaster* shared_user_script_master();
InfoMap* info_map();
- LazyBackgroundTaskQueue* lazy_background_task_queue();
EventRouter* event_router();
QuotaService* quota_service();
const OneShotEvent& ready() const { return ready_; }
@@ -102,7 +100,6 @@ class ExtensionSystemImpl : public ExtensionSystem {
scoped_ptr<StateStore> rules_store_;
// LazyBackgroundTaskQueue is a dependency of
// MessageService and EventRouter.
- scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_;
scoped_ptr<EventRouter> event_router_;
scoped_ptr<NavigationObserver> navigation_observer_;
// Shared memory region manager for scripts statically declared in extension
diff --git a/chrome/browser/extensions/test_extension_system.cc b/chrome/browser/extensions/test_extension_system.cc
index fd81b7b..9b9ea70 100644
--- a/chrome/browser/extensions/test_extension_system.cc
+++ b/chrome/browser/extensions/test_extension_system.cc
@@ -48,10 +48,6 @@ void TestExtensionSystem::Shutdown() {
extension_service_->Shutdown();
}
-void TestExtensionSystem::CreateLazyBackgroundTaskQueue() {
- lazy_background_task_queue_.reset(new LazyBackgroundTaskQueue(profile_));
-}
-
ExtensionPrefs* TestExtensionSystem::CreateExtensionPrefs(
const base::CommandLine* command_line,
const base::FilePath& install_directory) {
@@ -134,11 +130,6 @@ StateStore* TestExtensionSystem::rules_store() {
InfoMap* TestExtensionSystem::info_map() { return info_map_.get(); }
-LazyBackgroundTaskQueue*
-TestExtensionSystem::lazy_background_task_queue() {
- return lazy_background_task_queue_.get();
-}
-
void TestExtensionSystem::SetEventRouter(scoped_ptr<EventRouter> event_router) {
event_router_.reset(event_router.release());
}
diff --git a/chrome/browser/extensions/test_extension_system.h b/chrome/browser/extensions/test_extension_system.h
index 62ee4d1..06a5761 100644
--- a/chrome/browser/extensions/test_extension_system.h
+++ b/chrome/browser/extensions/test_extension_system.h
@@ -53,10 +53,6 @@ class TestExtensionSystem : public ExtensionSystem {
void CreateSocketManager();
- // Creates a LazyBackgroundTaskQueue. If not invoked, the
- // LazyBackgroundTaskQueue is NULL.
- void CreateLazyBackgroundTaskQueue();
-
void InitForRegularProfile(bool extensions_enabled) override {}
void SetExtensionService(ExtensionService* service);
ExtensionService* extension_service() override;
@@ -67,7 +63,6 @@ class TestExtensionSystem : public ExtensionSystem {
StateStore* rules_store() override;
TestingValueStore* value_store() { return value_store_; }
InfoMap* info_map() override;
- LazyBackgroundTaskQueue* lazy_background_task_queue() override;
void SetEventRouter(scoped_ptr<EventRouter> event_router);
EventRouter* event_router() override;
QuotaService* quota_service() override;
@@ -94,7 +89,6 @@ class TestExtensionSystem : public ExtensionSystem {
scoped_ptr<RuntimeData> runtime_data_;
scoped_ptr<ExtensionService> extension_service_;
scoped_refptr<InfoMap> info_map_;
- scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_;
scoped_ptr<EventRouter> event_router_;
scoped_ptr<QuotaService> quota_service_;
OneShotEvent ready_;
diff --git a/chrome/browser/signin/easy_unlock_app_manager_unittest.cc b/chrome/browser/signin/easy_unlock_app_manager_unittest.cc
index 416c910..2f1631a 100644
--- a/chrome/browser/signin/easy_unlock_app_manager_unittest.cc
+++ b/chrome/browser/signin/easy_unlock_app_manager_unittest.cc
@@ -299,7 +299,6 @@ class EasyUnlockAppManagerTest : public testing::Test {
extension_service_ = test_extension_system->CreateExtensionService(
&command_line_, base::FilePath() /* install_directory */,
false /* autoupdate_enabled */);
- test_extension_system->CreateLazyBackgroundTaskQueue();
extensions::ProcessManagerFactory::GetInstance()->SetTestingFactory(
&profile_, &CreateTestProcessManager);
diff --git a/extensions/browser/api/runtime/runtime_api.cc b/extensions/browser/api/runtime/runtime_api.cc
index cc90d37..6e23721 100644
--- a/extensions/browser/api/runtime/runtime_api.cc
+++ b/extensions/browser/api/runtime/runtime_api.cc
@@ -95,13 +95,12 @@ void DispatchOnStartupEventImpl(BrowserContext* browser_context,
extension_id);
if (extension && BackgroundInfo::HasPersistentBackgroundPage(extension) &&
first_call &&
- system->lazy_background_task_queue()->ShouldEnqueueTask(browser_context,
- extension)) {
- system->lazy_background_task_queue()->AddPendingTask(
- browser_context,
- extension_id,
- base::Bind(
- &DispatchOnStartupEventImpl, browser_context, extension_id, false));
+ LazyBackgroundTaskQueue::Get(browser_context)
+ ->ShouldEnqueueTask(browser_context, extension)) {
+ LazyBackgroundTaskQueue::Get(browser_context)
+ ->AddPendingTask(browser_context, extension_id,
+ base::Bind(&DispatchOnStartupEventImpl,
+ browser_context, extension_id, false));
return;
}
@@ -404,15 +403,14 @@ void RuntimeEventRouter::OnExtensionUninstalled(
}
ExtensionFunction::ResponseAction RuntimeGetBackgroundPageFunction::Run() {
- ExtensionSystem* system = ExtensionSystem::Get(browser_context());
ExtensionHost* host = ProcessManager::Get(browser_context())
->GetBackgroundHostForExtension(extension_id());
- if (system->lazy_background_task_queue()->ShouldEnqueueTask(browser_context(),
- extension())) {
- system->lazy_background_task_queue()->AddPendingTask(
- browser_context(),
- extension_id(),
- base::Bind(&RuntimeGetBackgroundPageFunction::OnPageLoaded, this));
+ if (LazyBackgroundTaskQueue::Get(browser_context())
+ ->ShouldEnqueueTask(browser_context(), extension())) {
+ LazyBackgroundTaskQueue::Get(browser_context())
+ ->AddPendingTask(
+ browser_context(), extension_id(),
+ base::Bind(&RuntimeGetBackgroundPageFunction::OnPageLoaded, this));
} else if (host) {
OnPageLoaded(host);
} else {
diff --git a/extensions/browser/event_router.cc b/extensions/browser/event_router.cc
index afd92d03..02df56a 100644
--- a/extensions/browser/event_router.cc
+++ b/extensions/browser/event_router.cc
@@ -638,8 +638,7 @@ bool EventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent(
if (!CanDispatchEventToBrowserContext(context, extension, event))
return false;
- LazyBackgroundTaskQueue* queue = ExtensionSystem::Get(
- context)->lazy_background_task_queue();
+ LazyBackgroundTaskQueue* queue = LazyBackgroundTaskQueue::Get(context);
if (queue->ShouldEnqueueTask(context, extension)) {
linked_ptr<Event> dispatched_event(event);
@@ -752,8 +751,8 @@ void EventRouter::Observe(int type,
const Extension* extension =
content::Details<const Extension>(details).ptr();
if (BackgroundInfo::HasLazyBackgroundPage(extension)) {
- LazyBackgroundTaskQueue* queue = ExtensionSystem::Get(
- browser_context_)->lazy_background_task_queue();
+ LazyBackgroundTaskQueue* queue =
+ LazyBackgroundTaskQueue::Get(browser_context_);
queue->AddPendingTask(browser_context_, extension->id(),
base::Bind(&DoNothing));
}
diff --git a/extensions/browser/extension_system.h b/extensions/browser/extension_system.h
index ec4c716..600ac3a 100644
--- a/extensions/browser/extension_system.h
+++ b/extensions/browser/extension_system.h
@@ -34,7 +34,6 @@ class EventRouter;
class Extension;
class ExtensionSet;
class InfoMap;
-class LazyBackgroundTaskQueue;
class ManagementPolicy;
class OneShotEvent;
class QuotaService;
@@ -83,9 +82,6 @@ class ExtensionSystem : public KeyedService {
// Returns the IO-thread-accessible extension data.
virtual InfoMap* info_map() = 0;
- // The LazyBackgroundTaskQueue is created at startup.
- virtual LazyBackgroundTaskQueue* lazy_background_task_queue() = 0;
-
// The EventRouter is created at startup.
virtual EventRouter* event_router() = 0;
diff --git a/extensions/browser/guest_view/app_view/app_view_guest.cc b/extensions/browser/guest_view/app_view/app_view_guest.cc
index 66aa593..705274d 100644
--- a/extensions/browser/guest_view/app_view/app_view_guest.cc
+++ b/extensions/browser/guest_view/app_view/app_view_guest.cc
@@ -207,7 +207,7 @@ void AppViewGuest::CreateWebContents(
callback))));
LazyBackgroundTaskQueue* queue =
- ExtensionSystem::Get(browser_context())->lazy_background_task_queue();
+ LazyBackgroundTaskQueue::Get(browser_context());
if (queue->ShouldEnqueueTask(browser_context(), guest_extension)) {
queue->AddPendingTask(browser_context(),
guest_extension->id(),
diff --git a/extensions/browser/lazy_background_task_queue.cc b/extensions/browser/lazy_background_task_queue.cc
index b76b6d3..fcbde09 100644
--- a/extensions/browser/lazy_background_task_queue.cc
+++ b/extensions/browser/lazy_background_task_queue.cc
@@ -14,6 +14,7 @@
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extensions_browser_client.h"
+#include "extensions/browser/lazy_background_task_queue_factory.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/process_map.h"
@@ -39,6 +40,12 @@ LazyBackgroundTaskQueue::LazyBackgroundTaskQueue(
LazyBackgroundTaskQueue::~LazyBackgroundTaskQueue() {
}
+// static
+LazyBackgroundTaskQueue* LazyBackgroundTaskQueue::Get(
+ content::BrowserContext* browser_context) {
+ return LazyBackgroundTaskQueueFactory::GetForBrowserContext(browser_context);
+}
+
bool LazyBackgroundTaskQueue::ShouldEnqueueTask(
content::BrowserContext* browser_context,
const Extension* extension) {
diff --git a/extensions/browser/lazy_background_task_queue.h b/extensions/browser/lazy_background_task_queue.h
index 96b3c89..52cbd91 100644
--- a/extensions/browser/lazy_background_task_queue.h
+++ b/extensions/browser/lazy_background_task_queue.h
@@ -13,6 +13,7 @@
#include "base/gtest_prod_util.h"
#include "base/memory/linked_ptr.h"
#include "base/scoped_observer.h"
+#include "components/keyed_service/core/keyed_service.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/extension_registry_observer.h"
@@ -32,7 +33,8 @@ class ExtensionRegistry;
//
// It is the consumer's responsibility to use this class when appropriate, i.e.
// only with extensions that have not-yet-loaded lazy background pages.
-class LazyBackgroundTaskQueue : public content::NotificationObserver,
+class LazyBackgroundTaskQueue : public KeyedService,
+ public content::NotificationObserver,
public ExtensionRegistryObserver {
public:
typedef base::Callback<void(ExtensionHost*)> PendingTask;
@@ -40,6 +42,10 @@ class LazyBackgroundTaskQueue : public content::NotificationObserver,
explicit LazyBackgroundTaskQueue(content::BrowserContext* browser_context);
~LazyBackgroundTaskQueue() override;
+ // Convenience method to return the LazyBackgroundTaskQueue for a given
+ // |context|.
+ static LazyBackgroundTaskQueue* Get(content::BrowserContext* context);
+
// Returns the number of extensions having pending tasks.
size_t extensions_with_pending_tasks() { return pending_tasks_.size(); }
diff --git a/extensions/browser/lazy_background_task_queue_factory.cc b/extensions/browser/lazy_background_task_queue_factory.cc
new file mode 100644
index 0000000..be9d8c7
--- /dev/null
+++ b/extensions/browser/lazy_background_task_queue_factory.cc
@@ -0,0 +1,50 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "extensions/browser/lazy_background_task_queue_factory.h"
+
+//#include "chrome/browser/profiles/profile.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "extensions/browser/extension_registry_factory.h"
+#include "extensions/browser/extensions_browser_client.h"
+#include "extensions/browser/lazy_background_task_queue.h"
+
+using content::BrowserContext;
+
+namespace extensions {
+
+// static
+LazyBackgroundTaskQueue* LazyBackgroundTaskQueueFactory::GetForBrowserContext(
+ BrowserContext* context) {
+ return static_cast<LazyBackgroundTaskQueue*>(
+ GetInstance()->GetServiceForBrowserContext(context, true));
+}
+
+// static
+LazyBackgroundTaskQueueFactory* LazyBackgroundTaskQueueFactory::GetInstance() {
+ return Singleton<LazyBackgroundTaskQueueFactory>::get();
+}
+
+LazyBackgroundTaskQueueFactory::LazyBackgroundTaskQueueFactory()
+ : BrowserContextKeyedServiceFactory(
+ "LazyBackgroundTaskQueue",
+ BrowserContextDependencyManager::GetInstance()) {
+ DependsOn(ExtensionRegistryFactory::GetInstance());
+}
+
+LazyBackgroundTaskQueueFactory::~LazyBackgroundTaskQueueFactory() {
+}
+
+KeyedService* LazyBackgroundTaskQueueFactory::BuildServiceInstanceFor(
+ BrowserContext* context) const {
+ return new LazyBackgroundTaskQueue(context);
+}
+
+BrowserContext* LazyBackgroundTaskQueueFactory::GetBrowserContextToUse(
+ BrowserContext* context) const {
+ // Redirected in incognito.
+ return ExtensionsBrowserClient::Get()->GetOriginalContext(context);
+}
+
+} // namespace extensions
diff --git a/extensions/browser/lazy_background_task_queue_factory.h b/extensions/browser/lazy_background_task_queue_factory.h
new file mode 100644
index 0000000..98917c9
--- /dev/null
+++ b/extensions/browser/lazy_background_task_queue_factory.h
@@ -0,0 +1,39 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EXTENSIONS_BROWSER_LAZY_BACKGROUND_TASK_QUEUE_FACTORY_H_
+#define EXTENSIONS_BROWSER_LAZY_BACKGROUND_TASK_QUEUE_FACTORY_H_
+
+#include "base/memory/singleton.h"
+#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
+
+namespace extensions {
+
+class LazyBackgroundTaskQueue;
+
+class LazyBackgroundTaskQueueFactory
+ : public BrowserContextKeyedServiceFactory {
+ public:
+ static LazyBackgroundTaskQueue* GetForBrowserContext(
+ content::BrowserContext* context);
+ static LazyBackgroundTaskQueueFactory* GetInstance();
+
+ private:
+ friend struct DefaultSingletonTraits<LazyBackgroundTaskQueueFactory>;
+
+ LazyBackgroundTaskQueueFactory();
+ ~LazyBackgroundTaskQueueFactory() override;
+
+ // BrowserContextKeyedServiceFactory implementation
+ KeyedService* BuildServiceInstanceFor(
+ content::BrowserContext* context) const override;
+ content::BrowserContext* GetBrowserContextToUse(
+ content::BrowserContext* context) const override;
+
+ DISALLOW_COPY_AND_ASSIGN(LazyBackgroundTaskQueueFactory);
+};
+
+} // namespace extensions
+
+#endif // EXTENSIONS_BROWSER_LAZY_BACKGROUND_TASK_QUEUE_FACTORY_H_
diff --git a/extensions/browser/mock_extension_system.cc b/extensions/browser/mock_extension_system.cc
index 0bd01ff..8371c95 100644
--- a/extensions/browser/mock_extension_system.cc
+++ b/extensions/browser/mock_extension_system.cc
@@ -46,10 +46,6 @@ InfoMap* MockExtensionSystem::info_map() {
return nullptr;
}
-LazyBackgroundTaskQueue* MockExtensionSystem::lazy_background_task_queue() {
- return nullptr;
-}
-
EventRouter* MockExtensionSystem::event_router() {
return event_router_;
}
diff --git a/extensions/browser/mock_extension_system.h b/extensions/browser/mock_extension_system.h
index 7393f8c..c06b7bc 100644
--- a/extensions/browser/mock_extension_system.h
+++ b/extensions/browser/mock_extension_system.h
@@ -36,7 +36,6 @@ class MockExtensionSystem : public ExtensionSystem {
StateStore* state_store() override;
StateStore* rules_store() override;
InfoMap* info_map() override;
- LazyBackgroundTaskQueue* lazy_background_task_queue() override;
EventRouter* event_router() override;
QuotaService* quota_service() override;
const OneShotEvent& ready() const override;
diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc
index efe359d..7a28cad 100644
--- a/extensions/browser/process_manager.cc
+++ b/extensions/browser/process_manager.cc
@@ -436,7 +436,7 @@ bool ProcessManager::WakeEventPage(const std::string& extension_id,
return false;
}
LazyBackgroundTaskQueue* queue =
- ExtensionSystem::Get(browser_context_)->lazy_background_task_queue();
+ LazyBackgroundTaskQueue::Get(browser_context_);
queue->AddPendingTask(browser_context_, extension_id,
base::Bind(&PropagateExtensionWakeResult, callback));
return true;
diff --git a/extensions/extensions.gypi b/extensions/extensions.gypi
index 3f82eac..9bc6eb4 100644
--- a/extensions/extensions.gypi
+++ b/extensions/extensions.gypi
@@ -693,6 +693,8 @@
'browser/io_thread_extension_message_filter.h',
'browser/lazy_background_task_queue.cc',
'browser/lazy_background_task_queue.h',
+ 'browser/lazy_background_task_queue_factory.cc',
+ 'browser/lazy_background_task_queue_factory.h',
'browser/load_monitoring_extension_host_queue.cc',
'browser/load_monitoring_extension_host_queue.h',
'browser/management_policy.cc',
diff --git a/extensions/shell/browser/shell_extension_system.cc b/extensions/shell/browser/shell_extension_system.cc
index b4512df..e5cabb7 100644
--- a/extensions/shell/browser/shell_extension_system.cc
+++ b/extensions/shell/browser/shell_extension_system.cc
@@ -18,7 +18,6 @@
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/info_map.h"
-#include "extensions/browser/lazy_background_task_queue.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/quota_service.h"
#include "extensions/browser/runtime_data.h"
@@ -98,8 +97,6 @@ void ShellExtensionSystem::Shutdown() {
void ShellExtensionSystem::InitForRegularProfile(bool extensions_enabled) {
runtime_data_.reset(
new RuntimeData(ExtensionRegistry::Get(browser_context_)));
- lazy_background_task_queue_.reset(
- new LazyBackgroundTaskQueue(browser_context_));
event_router_.reset(
new EventRouter(browser_context_, ExtensionPrefs::Get(browser_context_)));
quota_service_.reset(new QuotaService);
@@ -135,10 +132,6 @@ InfoMap* ShellExtensionSystem::info_map() {
return info_map_.get();
}
-LazyBackgroundTaskQueue* ShellExtensionSystem::lazy_background_task_queue() {
- return lazy_background_task_queue_.get();
-}
-
EventRouter* ShellExtensionSystem::event_router() {
return event_router_.get();
}
diff --git a/extensions/shell/browser/shell_extension_system.h b/extensions/shell/browser/shell_extension_system.h
index 93898c4..d4db30c 100644
--- a/extensions/shell/browser/shell_extension_system.h
+++ b/extensions/shell/browser/shell_extension_system.h
@@ -26,7 +26,6 @@ namespace extensions {
class DeclarativeUserScriptManager;
class EventRouter;
class InfoMap;
-class LazyBackgroundTaskQueue;
class ProcessManager;
class RendererStartupHelper;
class SharedUserScriptMaster;
@@ -60,7 +59,6 @@ class ShellExtensionSystem : public ExtensionSystem {
StateStore* state_store() override;
StateStore* rules_store() override;
InfoMap* info_map() override;
- LazyBackgroundTaskQueue* lazy_background_task_queue() override;
EventRouter* event_router() override;
QuotaService* quota_service() override;
void RegisterExtensionWithRequestContexts(
@@ -80,7 +78,6 @@ class ShellExtensionSystem : public ExtensionSystem {
scoped_refptr<InfoMap> info_map_;
scoped_ptr<RuntimeData> runtime_data_;
- scoped_ptr<LazyBackgroundTaskQueue> lazy_background_task_queue_;
scoped_ptr<EventRouter> event_router_;
scoped_ptr<QuotaService> quota_service_;