Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(573)

Unified Diff: extensions/browser/api/runtime/runtime_api.cc

Issue 671763002: Extract ProcessManager from ExtensionSystem. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/runtime/runtime_api.cc
diff --git a/extensions/browser/api/runtime/runtime_api.cc b/extensions/browser/api/runtime/runtime_api.cc
index 8764d8c1e87664412b9559cb50ccadecf820121d..51e8ec9bcf771dfcd5fe4e89eeaa52edff2d2108 100644
--- a/extensions/browser/api/runtime/runtime_api.cc
+++ b/extensions/browser/api/runtime/runtime_api.cc
@@ -27,7 +27,7 @@
#include "extensions/browser/extensions_browser_client.h"
#include "extensions/browser/lazy_background_task_queue.h"
#include "extensions/browser/notification_types.h"
-#include "extensions/browser/process_manager.h"
+#include "extensions/browser/process_manager_factory.h"
#include "extensions/common/api/runtime.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
@@ -136,14 +136,25 @@ BrowserContextKeyedAPIFactory<RuntimeAPI>* RuntimeAPI::GetFactoryInstance() {
return g_factory.Pointer();
}
+template <>
+void BrowserContextKeyedAPIFactory<RuntimeAPI>::DeclareFactoryDependencies() {
+ DependsOn(ProcessManagerFactory::GetInstance());
+}
+
RuntimeAPI::RuntimeAPI(content::BrowserContext* context)
: browser_context_(context),
dispatch_chrome_updated_event_(false),
- extension_registry_observer_(this) {
+ extension_registry_observer_(this),
+ process_manager_observer_(this) {
+ // RuntimeAPI is redirected in incognito, so |browser_context_| is never
+ // incognito.
+ DCHECK(!browser_context_->IsOffTheRecord());
+
registrar_.Add(this,
extensions::NOTIFICATION_EXTENSIONS_READY_DEPRECATED,
content::Source<BrowserContext>(context));
extension_registry_observer_.Add(ExtensionRegistry::Get(browser_context_));
+ process_manager_observer_.Add(ProcessManager::Get(browser_context_));
delegate_ = ExtensionsBrowserClient::Get()->CreateRuntimeAPIDelegate(
browser_context_);
@@ -155,7 +166,6 @@ RuntimeAPI::RuntimeAPI(content::BrowserContext* context)
}
RuntimeAPI::~RuntimeAPI() {
- delegate_->RemoveUpdateObserver(this);
}
void RuntimeAPI::Observe(int type,
@@ -166,15 +176,6 @@ void RuntimeAPI::Observe(int type,
dispatch_chrome_updated_event_ = false;
delegate_->AddUpdateObserver(this);
-
- // RuntimeAPI is redirected in incognito, so |browser_context_| is never
- // incognito. We don't observe incognito ProcessManagers but that is OK
- // because we don't send onStartup events to incognito browser contexts.
- DCHECK(!browser_context_->IsOffTheRecord());
- // Some tests use partially constructed Profiles without a process manager.
- ExtensionSystem* extension_system = ExtensionSystem::Get(browser_context_);
- if (extension_system->process_manager())
- extension_system->process_manager()->AddObserver(this);
}
void RuntimeAPI::OnExtensionLoaded(content::BrowserContext* browser_context,
@@ -229,13 +230,7 @@ void RuntimeAPI::OnExtensionUninstalled(
}
void RuntimeAPI::Shutdown() {
- // ExtensionSystem deletes its ProcessManager during the Shutdown() phase, so
- // the observer must be removed here and not in the RuntimeAPI destructor.
- ProcessManager* process_manager =
- ExtensionSystem::Get(browser_context_)->process_manager();
- // Some tests use partially constructed Profiles without a process manager.
- if (process_manager)
- process_manager->RemoveObserver(this);
+ delegate_->RemoveUpdateObserver(this);
}
void RuntimeAPI::OnAppUpdateAvailable(const Extension* extension) {
@@ -405,8 +400,8 @@ void RuntimeEventRouter::OnExtensionUninstalled(
ExtensionFunction::ResponseAction RuntimeGetBackgroundPageFunction::Run() {
ExtensionSystem* system = ExtensionSystem::Get(browser_context());
- ExtensionHost* host =
- system->process_manager()->GetBackgroundHostForExtension(extension_id());
+ 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(
« no previous file with comments | « extensions/browser/api/runtime/runtime_api.h ('k') | extensions/browser/browser_context_keyed_service_factories.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698