Skip to content

Commit

Permalink
Extract ProcessManager from ExtensionSystem.
Browse files Browse the repository at this point in the history
This change removes ProcessManager's //chrome dependency because while
ProcessManager and ExtensionSystem are in //extensions the
ExtensionSystemFactory is in //chrome. This allows a service in
//extensions to declare a dependency on the ProcessManager's factory
directly.

Most of this patch is changing,
extensions::ExtensionSystem::Get(profile_)->process_manager() to, extensions::ProcessManager::Get(profile_).

BUG=
TBR=erikwright@chromium.org

Review URL: https://codereview.chromium.org/671763002

Cr-Commit-Position: refs/heads/master@{#301636}
  • Loading branch information
reillyeon authored and Commit bot committed Oct 28, 2014
1 parent ecfca46 commit 0ea3fa9
Show file tree
Hide file tree
Showing 84 changed files with 301 additions and 391 deletions.
2 changes: 1 addition & 1 deletion apps/launcher.cc
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class PlatformAppPathLauncher
}

extensions::ProcessManager* const process_manager =
ExtensionSystem::Get(profile_)->process_manager();
extensions::ProcessManager::Get(profile_);
ExtensionHost* const host =
process_manager->GetBackgroundHostForExtension(extension_->id());
DCHECK(host);
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/apps/ephemeral_app_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ class EphemeralAppBrowserTest : public EphemeralAppTestBase {

// Verify that the event page of the app has not been loaded.
void VerifyAppNotLoaded(const std::string& app_id) {
EXPECT_FALSE(ExtensionSystem::Get(profile())->
process_manager()->GetBackgroundHostForExtension(app_id));
EXPECT_FALSE(extensions::ProcessManager::Get(profile())
->GetBackgroundHostForExtension(app_id));
}

// Verify properties of ephemeral apps.
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/apps/window_controls_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class WindowControlsTest : public extensions::PlatformAppBrowserTest {
content::WebContents* WindowControlsTest::GetWebContentsForExtensionWindow(
const extensions::Extension* extension) {
extensions::ProcessManager* process_manager =
extensions::ExtensionSystem::Get(profile())->process_manager();
extensions::ProcessManager::Get(profile());

// Lookup render view host for background page.
const extensions::ExtensionHost* extension_host =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ class KeywordExtensionsDelegateImplTest : public ExtensionServiceTestBase {
void KeywordExtensionsDelegateImplTest::SetUp() {
ExtensionServiceTestBase::SetUp();
InitializeExtensionService(CreateDefaultInitParams());
InitializeProcessManager();
}

void KeywordExtensionsDelegateImplTest::RunTest(bool incognito) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ class LoggedInSpokenFeedbackTest : public InProcessBrowserTest {

void RunJavaScriptInChromeVoxBackgroundPage(const std::string& script) {
extensions::ExtensionHost* host =
extensions::ExtensionSystem::Get(browser()->profile())->
process_manager()->GetBackgroundHostForExtension(
extension_misc::kChromeVoxExtensionId);
extensions::ProcessManager::Get(browser()->profile())
->GetBackgroundHostForExtension(
extension_misc::kChromeVoxExtensionId);
CHECK(content::ExecuteScript(host->host_contents(), script));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
#include "extensions/browser/event_router.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_system.h"
#include "storage/common/fileapi/file_system_types.h"
#include "storage/common/fileapi/file_system_util.h"

Expand Down Expand Up @@ -271,13 +270,9 @@ std::string FileErrorToErrorName(base::File::Error error_code) {

void GrantAccessForAddedProfileToRunningInstance(Profile* added_profile,
Profile* running_profile) {
extensions::ProcessManager* const process_manager =
extensions::ExtensionSystem::Get(running_profile)->process_manager();
if (!process_manager)
return;

extensions::ExtensionHost* const extension_host =
process_manager->GetBackgroundHostForExtension(kFileManagerAppId);
extensions::ProcessManager::Get(running_profile)
->GetBackgroundHostForExtension(kFileManagerAppId);
if (!extension_host || !extension_host->render_process_host())
return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int ExtractProcessFromExtensionId(Profile* profile,
GURL extension_url =
Extension::GetBaseURLFromExtensionId(extension_id);
extensions::ProcessManager* manager =
extensions::ExtensionSystem::Get(profile)->process_manager();
extensions::ProcessManager::Get(profile);

SiteInstance* site_instance = manager->GetSiteInstanceForURL(extension_url);
if (!site_instance || !site_instance->HasProcess())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,7 @@ IN_PROC_BROWSER_TEST_P(InputMethodEngineBrowserTest,
ASSERT_TRUE(engine_handler);

extensions::ExtensionHost* host =
extensions::ExtensionSystem::Get(profile())
->process_manager()
extensions::ProcessManager::Get(profile())
->GetBackgroundHostForExtension(extension_->id());
ASSERT_TRUE(host);

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/chromeos/login/signin/oauth2_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ class MergeSessionTest : public OAuth2Test {

const GURL& GetBackGroundPageUrl(const std::string& extension_id) {
extensions::ProcessManager* manager =
extensions::ExtensionSystem::Get(profile())->process_manager();
extensions::ProcessManager::Get(profile());
extensions::ExtensionHost* host =
manager->GetBackgroundHostForExtension(extension_id);
return host->host_contents()->GetURL();
Expand All @@ -669,7 +669,7 @@ class MergeSessionTest : public OAuth2Test {
void JsExpectOnBackgroundPage(const std::string& extension_id,
const std::string& expression) {
extensions::ProcessManager* manager =
extensions::ExtensionSystem::Get(profile())->process_manager();
extensions::ProcessManager::Get(profile());
extensions::ExtensionHost* host =
manager->GetBackgroundHostForExtension(extension_id);
if (host == NULL) {
Expand Down
3 changes: 1 addition & 2 deletions chrome/browser/devtools/devtools_sanity_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ class DevToolsExtensionTest : public DevToolsSanityTest,
FROM_HERE, timeout.callback(), TestTimeouts::action_timeout());

extensions::ProcessManager* manager =
extensions::ExtensionSystem::Get(browser()->profile())->
process_manager();
extensions::ProcessManager::Get(browser()->profile());
extensions::ProcessManager::ViewSet all_views = manager->GetAllViews();
for (extensions::ProcessManager::ViewSet::const_iterator iter =
all_views.begin();
Expand Down
7 changes: 2 additions & 5 deletions chrome/browser/devtools/devtools_target_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "content/public/browser/web_contents.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/guest_view/guest_view_base.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/constants.h"
Expand Down Expand Up @@ -107,12 +106,10 @@ WebContentsTarget::WebContentsTarget(WebContents* web_contents, bool is_tab)
Profile::FromBrowserContext(web_contents->GetBrowserContext());
if (!profile)
return;
extensions::ExtensionSystem* extension_system =
extensions::ExtensionSystem::Get(profile);
set_title(extension->name());
extensions::ExtensionHost* extension_host =
extension_system->process_manager()->GetBackgroundHostForExtension(
extension->id());
extensions::ProcessManager::Get(profile)
->GetBackgroundHostForExtension(extension->id());
if (extension_host &&
extension_host->host_contents() == web_contents) {
set_type(kTargetTypeBackgroundPage);
Expand Down
5 changes: 2 additions & 3 deletions chrome/browser/extensions/alert_apitest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "components/app_modal_dialogs/app_modal_dialog.h"
#include "content/public/browser/render_frame_host.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/extension.h"

Expand All @@ -19,8 +18,8 @@ IN_PROC_BROWSER_TEST_F(ExtensionApiTest, AlertBasic) {

const extensions::Extension* extension = GetSingleLoadedExtension();
extensions::ExtensionHost* host =
extensions::ExtensionSystem::Get(browser()->profile())->
process_manager()->GetBackgroundHostForExtension(extension->id());
extensions::ProcessManager::Get(browser()->profile())
->GetBackgroundHostForExtension(extension->id());
ASSERT_TRUE(host);
host->host_contents()->GetMainFrame()->ExecuteJavaScript(
base::ASCIIToUTF16("alert('This should not crash.');"));
Expand Down
4 changes: 1 addition & 3 deletions chrome/browser/extensions/api/debugger/debugger_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_registry_observer.h"
#include "extensions/browser/extension_system.h"
#include "extensions/common/constants.h"
#include "extensions/common/error_utils.h"
#include "extensions/common/extension.h"
Expand Down Expand Up @@ -516,8 +515,7 @@ bool DebuggerFunction::InitAgentHost() {
}
} else if (debuggee_.extension_id) {
ExtensionHost* extension_host =
ExtensionSystem::Get(GetProfile())
->process_manager()
ProcessManager::Get(GetProfile())
->GetBackgroundHostForExtension(*debuggee_.extension_id);
if (extension_host) {
if (PermissionsData::IsRestrictedUrl(extension_host->GetURL(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,8 +563,7 @@ ItemInspectViewList DeveloperPrivateGetItemsInfoFunction::
bool extension_is_enabled) {
ItemInspectViewList result;
// Get the extension process's active views.
ProcessManager* process_manager =
ExtensionSystem::Get(GetProfile())->process_manager();
ProcessManager* process_manager = ProcessManager::Get(GetProfile());
GetInspectablePagesForExtensionProcess(
extension,
process_manager->GetRenderViewHostsForExtension(extension->id()),
Expand All @@ -590,8 +589,8 @@ ItemInspectViewList DeveloperPrivateGetItemsInfoFunction::
// app windows for incognito process.
if (service->profile()->HasOffTheRecordProfile() &&
IncognitoInfo::IsSplitMode(extension)) {
process_manager = ExtensionSystem::Get(
service->profile()->GetOffTheRecordProfile())->process_manager();
process_manager =
ProcessManager::Get(service->profile()->GetOffTheRecordProfile());
GetInspectablePagesForExtensionProcess(
extension,
process_manager->GetRenderViewHostsForExtension(extension->id()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "chrome/browser/extensions/extension_action_icon_factory.h"
#include "chrome/browser/extensions/extension_action_manager.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/browser/extensions/extension_toolbar_model.h"
#include "chrome/browser/extensions/extension_util.h"
Expand All @@ -26,6 +25,7 @@
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/notification_types.h"
#include "extensions/browser/process_manager.h"
#include "extensions/browser/test_extension_registry_observer.h"
#include "extensions/common/feature_switch.h"
#include "extensions/test/result_catcher.h"
Expand Down Expand Up @@ -542,7 +542,7 @@ IN_PROC_BROWSER_TEST_F(BrowserActionApiTest, DISABLED_CloseBackgroundPage) {

// There is a background page and a browser action with no badge text.
extensions::ProcessManager* manager =
extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
extensions::ProcessManager::Get(browser()->profile());
ASSERT_TRUE(manager->GetBackgroundHostForExtension(extension->id()));
ExtensionAction* action = GetBrowserAction(*extension);
ASSERT_EQ("", action->GetBadgeText(ExtensionAction::kDefaultTabId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class ExtensionManagementApiBrowserTest : public ExtensionBrowserTest {
protected:
bool CrashEnabledExtension(const std::string& extension_id) {
ExtensionHost* background_host =
ExtensionSystem::Get(browser()->profile())->
process_manager()->GetBackgroundHostForExtension(extension_id);
ProcessManager::Get(browser()->profile())
->GetBackgroundHostForExtension(extension_id);
if (!background_host)
return false;
content::CrashTab(background_host->host_contents());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ class ExtensionManagementTest : public ExtensionBrowserTest {
// background page is correct. This is to ensure that the processes are in
// sync with the Extension.
extensions::ProcessManager* manager =
extensions::ExtensionSystem::Get(browser()->profile())->
process_manager();
extensions::ProcessManager::Get(browser()->profile());
extensions::ExtensionHost* ext_host =
manager->GetBackgroundHostForExtension(extension->id());
EXPECT_TRUE(ext_host);
Expand Down Expand Up @@ -177,7 +176,7 @@ IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, MAYBE_InstallRequiresConfirm) {
// Tests that disabling and re-enabling an extension works.
IN_PROC_BROWSER_TEST_F(ExtensionManagementTest, DisableEnable) {
extensions::ProcessManager* manager =
extensions::ExtensionSystem::Get(browser()->profile())->process_manager();
extensions::ProcessManager::Get(browser()->profile());
ExtensionRegistry* registry = ExtensionRegistry::Get(browser()->profile());
const size_t size_before = registry->enabled_extensions().size();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/media_galleries/media_file_system_registry.h"
#include "chrome/browser/media_galleries/media_galleries_preferences.h"
#include "chrome/browser/media_galleries/media_galleries_test_util.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/extension.h"
#include "extensions/common/switches.h"
#include "extensions/test/extension_test_message_listener.h"
Expand Down Expand Up @@ -138,9 +137,7 @@ class MediaGalleriesGalleryWatchApiTest : public ExtensionApiTest {
private:
void GetBackgroundHostForTestExtension() {
ASSERT_TRUE(extension_);
extensions::ExtensionSystem* extension_system =
extensions::ExtensionSystem::Get(browser()->profile());
background_host_ = extension_system->process_manager()
background_host_ = extensions::ProcessManager::Get(browser()->profile())
->GetBackgroundHostForExtension(extension_->id())
->render_view_host();
ASSERT_TRUE(background_host_);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/media_galleries/media_file_system_registry.h"
#include "chrome/browser/media_galleries/media_galleries_preferences.h"
#include "chrome/browser/media_galleries/media_galleries_test_util.h"
#include "chrome/common/chrome_paths.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_view_host.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/extension.h"
#include "extensions/common/switches.h"
#include "extensions/test/extension_test_message_listener.h"
Expand Down Expand Up @@ -134,11 +133,9 @@ class MediaGalleriesPrivateGalleryWatchApiTest : public ExtensionApiTest {
private:
void GetBackgroundHostForTestExtension() {
ASSERT_TRUE(extension_);
extensions::ExtensionSystem* extension_system =
extensions::ExtensionSystem::Get(browser()->profile());
background_host_ =
extension_system->process_manager()->GetBackgroundHostForExtension(
extension_->id())->render_view_host();
background_host_ = extensions::ProcessManager::Get(browser()->profile())
->GetBackgroundHostForExtension(extension_->id())
->render_view_host();
ASSERT_TRUE(background_host_);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/render_process_host.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/extension_messages.h"
#include "extensions/common/manifest_handlers/background_info.h"
Expand Down Expand Up @@ -56,8 +55,7 @@ void ExtensionMessagePort::DispatchOnMessage(const Message& message,
void ExtensionMessagePort::IncrementLazyKeepaliveCount() {
Profile* profile =
Profile::FromBrowserContext(process_->GetBrowserContext());
extensions::ProcessManager* pm =
ExtensionSystem::Get(profile)->process_manager();
extensions::ProcessManager* pm = ProcessManager::Get(profile);
ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_);
if (host && BackgroundInfo::HasLazyBackgroundPage(host->extension()))
pm->IncrementLazyKeepaliveCount(host->extension());
Expand All @@ -70,8 +68,7 @@ void ExtensionMessagePort::IncrementLazyKeepaliveCount() {
void ExtensionMessagePort::DecrementLazyKeepaliveCount() {
Profile* profile =
Profile::FromBrowserContext(process_->GetBrowserContext());
extensions::ProcessManager* pm =
ExtensionSystem::Get(profile)->process_manager();
extensions::ProcessManager* pm = ProcessManager::Get(profile);
ExtensionHost* host = pm->GetBackgroundHostForExtension(extension_id_);
if (host && host == background_host_ptr_)
pm->DecrementLazyKeepaliveCount(host->extension());
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/api/messaging/message_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static content::RenderProcessHost* GetExtensionProcess(
BrowserContext* context,
const std::string& extension_id) {
SiteInstance* site_instance =
ExtensionSystem::Get(context)->process_manager()->GetSiteInstanceForURL(
ProcessManager::Get(context)->GetSiteInstanceForURL(
Extension::GetBaseURLFromExtensionId(extension_id));
return site_instance->HasProcess() ? site_instance->GetProcess() : NULL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/extensions/lazy_background_page_test_util.h"
#include "chrome/browser/ui/browser.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/extension.h"
#include "extensions/test/result_catcher.h"
Expand Down Expand Up @@ -58,8 +57,7 @@ IN_PROC_BROWSER_TEST_F(SystemIndicatorApiTest, SystemIndicator) {
ASSERT_TRUE(extension) << message_;

// Lazy Background Page has been shut down.
extensions::ProcessManager* pm =
extensions::ExtensionSystem::Get(profile())->process_manager();
extensions::ProcessManager* pm = extensions::ProcessManager::Get(profile());
EXPECT_FALSE(pm->GetBackgroundHostForExtension(last_loaded_extension_id()));

EXPECT_TRUE(manager->SendClickEventToExtensionForTest(extension->id()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "content/public/browser/render_view_host.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/api/system_storage/storage_info_provider.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/process_manager.h"
#include "extensions/common/extension.h"
#include "extensions/test/extension_test_message_listener.h"
Expand Down Expand Up @@ -44,9 +43,9 @@ class SystemStorageEjectApiTest : public ExtensionApiTest {
content::RenderViewHost* GetHost() {
const extensions::Extension* extension =
LoadExtension(test_data_dir_.AppendASCII("system/storage_eject"));
return extensions::ExtensionSystem::Get(browser()->profile())->
process_manager()->GetBackgroundHostForExtension(extension->id())->
render_view_host();
return extensions::ProcessManager::Get(browser()->profile())
->GetBackgroundHostForExtension(extension->id())
->render_view_host();
}

void ExecuteCmdAndCheckReply(content::RenderViewHost* host,
Expand Down
Loading

0 comments on commit 0ea3fa9

Please sign in to comment.