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

Unified Diff: chrome/browser/extensions/chrome_process_manager_delegate.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: chrome/browser/extensions/chrome_process_manager_delegate.cc
diff --git a/chrome/browser/extensions/chrome_process_manager_delegate.cc b/chrome/browser/extensions/chrome_process_manager_delegate.cc
index 2ec923025600307e7ec5081838de763d184db070..a155b77b81192fc6f068cf8021fcbad5edc65ac7 100644
--- a/chrome/browser/extensions/chrome_process_manager_delegate.cc
+++ b/chrome/browser/extensions/chrome_process_manager_delegate.cc
@@ -16,6 +16,7 @@
#include "content/public/browser/notification_service.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
+#include "extensions/browser/process_manager_factory.h"
#include "extensions/common/one_shot_event.h"
namespace extensions {
@@ -102,9 +103,8 @@ void ChromeProcessManagerDelegate::OnBrowserWindowReady(Browser* browser) {
// Inform the process manager for this profile that the window is ready.
// We continue to observe the notification in case browser windows open for
// a related incognito profile or other regular profiles.
- ProcessManager* manager = system->process_manager();
- if (!manager) // Tests may not have a process manager.
- return;
+ ProcessManager* manager = ProcessManager::Get(profile);
+ DCHECK(manager);
DCHECK_EQ(profile, manager->GetBrowserContext());
manager->MaybeCreateStartupBackgroundHosts();
@@ -114,8 +114,7 @@ void ChromeProcessManagerDelegate::OnBrowserWindowReady(Browser* browser) {
// non-incognito window opened.
if (profile->IsOffTheRecord()) {
Profile* original_profile = profile->GetOriginalProfile();
- ProcessManager* original_manager =
- ExtensionSystem::Get(original_profile)->process_manager();
+ ProcessManager* original_manager = ProcessManager::Get(original_profile);
DCHECK(original_manager);
DCHECK_EQ(original_profile, original_manager->GetBrowserContext());
original_manager->MaybeCreateStartupBackgroundHosts();
@@ -128,14 +127,13 @@ void ChromeProcessManagerDelegate::OnProfileCreated(Profile* profile) {
return;
// The profile can be created before the extension system is ready.
- ProcessManager* manager = ExtensionSystem::Get(profile)->process_manager();
- if (!manager)
+ if (!ExtensionSystem::Get(profile)->ready().is_signaled())
return;
// The profile might have been initialized asynchronously (in parallel with
// extension system startup). Now that initialization is complete the
// ProcessManager can load deferred background pages.
- manager->MaybeCreateStartupBackgroundHosts();
+ ProcessManager::Get(profile)->MaybeCreateStartupBackgroundHosts();
}
void ChromeProcessManagerDelegate::OnProfileDestroyed(Profile* profile) {
@@ -143,19 +141,22 @@ void ChromeProcessManagerDelegate::OnProfileDestroyed(Profile* profile) {
// have time to shutdown various objects on different threads. The
// ProfileManager destructor is called too late in the shutdown sequence.
// http://crbug.com/15708
- ProcessManager* manager = ExtensionSystem::Get(profile)->process_manager();
- if (manager)
+ ProcessManager* manager =
+ ProcessManagerFactory::GetForBrowserContextIfExists(profile);
+ if (manager) {
manager->CloseBackgroundHosts();
+ }
// If this profile owns an incognito profile, but it is destroyed before the
// incognito profile is destroyed, then close the incognito background hosts
// as well. This happens in a few tests. http://crbug.com/138843
if (!profile->IsOffTheRecord() && profile->HasOffTheRecordProfile()) {
ProcessManager* incognito_manager =
- ExtensionSystem::Get(profile->GetOffTheRecordProfile())
- ->process_manager();
- if (incognito_manager)
+ ProcessManagerFactory::GetForBrowserContextIfExists(
+ profile->GetOffTheRecordProfile());
+ if (incognito_manager) {
incognito_manager->CloseBackgroundHosts();
+ }
}
}
« no previous file with comments | « chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc ('k') | chrome/browser/extensions/devtools_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698