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

Unified Diff: chrome/browser/task_manager/task_manager_resource_providers.cc

Issue 10113005: Remove EPM:all_hosts_ and use all_extension_views_ instead. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments addressed Created 8 years, 8 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/task_manager/task_manager_resource_providers.cc
diff --git a/chrome/browser/task_manager/task_manager_resource_providers.cc b/chrome/browser/task_manager/task_manager_resource_providers.cc
index 6a511b33596e10303f250f9690b515f9291f5d4c..327ea9a265b8c75771baac224f8a3b9b0e90cf7c 100644
--- a/chrome/browser/task_manager/task_manager_resource_providers.cc
+++ b/chrome/browser/task_manager/task_manager_resource_providers.cc
@@ -24,6 +24,7 @@
#include "chrome/browser/extensions/extension_host.h"
#include "chrome/browser/extensions/extension_process_manager.h"
#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/favicon/favicon_tab_helper.h"
#include "chrome/browser/instant/instant_controller.h"
#include "chrome/browser/prerender/prerender_manager.h"
@@ -47,8 +48,10 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/render_view_host_delegate.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/process_type.h"
+#include "content/public/common/view_type.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
#include "grit/theme_resources_standard.h"
@@ -1117,20 +1120,22 @@ void TaskManagerChildProcessResourceProvider::ChildProcessDataRetreived(
SkBitmap* TaskManagerExtensionProcessResource::default_icon_ = NULL;
TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource(
- ExtensionHost* extension_host)
- : extension_host_(extension_host) {
+ content::RenderViewHost* render_view_host)
+ : render_view_host_(render_view_host) {
if (!default_icon_) {
ResourceBundle& rb = ResourceBundle::GetSharedInstance();
default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN);
}
- process_handle_ = extension_host_->render_process_host()->GetHandle();
- unique_process_id_ = extension_host_->render_process_host()->GetID();
+ process_handle_ = render_view_host_->GetProcess()->GetHandle();
+ unique_process_id_ = render_view_host->GetProcess()->GetID();
pid_ = base::GetProcId(process_handle_);
string16 extension_name = UTF8ToUTF16(GetExtension()->name());
DCHECK(!extension_name.empty());
+ Profile* profile = Profile::FromBrowserContext(
+ render_view_host->GetProcess()->GetBrowserContext());
int message_id = GetMessagePrefixID(GetExtension()->is_app(), true,
- extension_host_->profile()->IsOffTheRecord(), false, false);
+ profile->IsOffTheRecord(), false, false);
title_ = l10n_util::GetStringFUTF16(message_id, extension_name);
}
@@ -1144,7 +1149,9 @@ string16 TaskManagerExtensionProcessResource::GetTitle() const {
string16 TaskManagerExtensionProcessResource::GetProfileName() const {
ProfileInfoCache& cache =
g_browser_process->profile_manager()->GetProfileInfoCache();
- Profile* profile = extension_host_->profile()->GetOriginalProfile();
+ Profile* profile = Profile::FromBrowserContext(
+ render_view_host_->GetProcess()->GetBrowserContext());
+ profile = profile->GetOriginalProfile();
size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
if (index == std::string::npos)
return string16();
@@ -1174,7 +1181,7 @@ bool TaskManagerExtensionProcessResource::CanInspect() const {
}
void TaskManagerExtensionProcessResource::Inspect() const {
- DevToolsWindow::OpenDevToolsWindow(extension_host_->render_view_host());
+ DevToolsWindow::OpenDevToolsWindow(render_view_host_);
}
bool TaskManagerExtensionProcessResource::SupportNetworkUsage() const {
@@ -1186,11 +1193,15 @@ void TaskManagerExtensionProcessResource::SetSupportNetworkUsage() {
}
const Extension* TaskManagerExtensionProcessResource::GetExtension() const {
- return extension_host_->extension();
+ Profile* profile = Profile::FromBrowserContext(
+ render_view_host_->GetProcess()->GetBrowserContext());
+ ExtensionProcessManager* process_manager =
+ ExtensionSystem::Get(profile)->process_manager();
+ return process_manager->GetExtensionForRenderViewHost(render_view_host_);
}
bool TaskManagerExtensionProcessResource::IsBackground() const {
- return extension_host_->extension_host_type() ==
+ return render_view_host_->GetDelegate()->GetRenderViewType() ==
chrome::VIEW_TYPE_EXTENSION_BACKGROUND_PAGE;
}
@@ -1224,8 +1235,8 @@ void TaskManagerExtensionProcessResourceProvider::StartUpdating() {
DCHECK(!updating_);
updating_ = true;
- // Add all the existing ExtensionHosts from all Profiles, including those from
- // incognito split mode.
+ // Add all the existing extension views from all Profiles, including those
+ // from incognito split mode.
ProfileManager* profile_manager = g_browser_process->profile_manager();
std::vector<Profile*> profiles(profile_manager->GetLoadedProfiles());
size_t num_default_profiles = profiles.size();
@@ -1234,15 +1245,32 @@ void TaskManagerExtensionProcessResourceProvider::StartUpdating() {
profiles.push_back(profiles[i]->GetOffTheRecordProfile());
}
}
+
for (size_t i = 0; i < profiles.size(); ++i) {
ExtensionProcessManager* process_manager =
profiles[i]->GetExtensionProcessManager();
if (process_manager) {
- ExtensionProcessManager::const_iterator jt;
- for (jt = process_manager->begin(); jt != process_manager->end(); ++jt) {
+ const ExtensionProcessManager::ViewSet all_views =
+ process_manager->GetAllViews();
+ ExtensionProcessManager::ViewSet::const_iterator jt = all_views.begin();
+ for (; jt != all_views.end(); ++jt) {
+ content::RenderViewHost* rvh = *jt;
// Don't add dead extension processes.
- if ((*jt)->IsRenderViewLive())
- AddToTaskManager(*jt);
+ if (!rvh->IsRenderViewLive())
+ continue;
+
+ // Don't add WebContents (those are handled by
+ // TaskManagerTabContentsResourceProvider) or background contents
+ // (handled by TaskManagerBackgroundResourceProvider).
+ // TODO(benwells): create specific chrome::VIEW_TYPE_TAB_CONTENTS for
+ // tab contents, as VIEW_TYPE_WEB_CONTENTS is the default.
+ content::ViewType view_type = rvh->GetDelegate()->GetRenderViewType();
+ if (view_type == content::VIEW_TYPE_WEB_CONTENTS ||
+ view_type == chrome::VIEW_TYPE_BACKGROUND_CONTENTS) {
+ continue;
+ }
+
+ AddToTaskManager(rvh);
}
}
}
@@ -1284,11 +1312,13 @@ void TaskManagerExtensionProcessResourceProvider::Observe(
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_EXTENSION_HOST_CREATED:
- AddToTaskManager(content::Details<ExtensionHost>(details).ptr());
+ AddToTaskManager(
+ content::Details<ExtensionHost>(details).ptr()->render_view_host());
break;
case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED:
case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED:
- RemoveFromTaskManager(content::Details<ExtensionHost>(details).ptr());
+ RemoveFromTaskManager(
+ content::Details<ExtensionHost>(details).ptr()->render_view_host());
break;
default:
NOTREACHED() << "Unexpected notification.";
@@ -1297,21 +1327,21 @@ void TaskManagerExtensionProcessResourceProvider::Observe(
}
void TaskManagerExtensionProcessResourceProvider::AddToTaskManager(
- ExtensionHost* extension_host) {
+ content::RenderViewHost* render_view_host) {
TaskManagerExtensionProcessResource* resource =
- new TaskManagerExtensionProcessResource(extension_host);
- DCHECK(resources_.find(extension_host) == resources_.end());
- resources_[extension_host] = resource;
+ new TaskManagerExtensionProcessResource(render_view_host);
+ DCHECK(resources_.find(render_view_host) == resources_.end());
+ resources_[render_view_host] = resource;
pid_to_resources_[resource->process_id()] = resource;
task_manager_->AddResource(resource);
}
void TaskManagerExtensionProcessResourceProvider::RemoveFromTaskManager(
- ExtensionHost* extension_host) {
+ content::RenderViewHost* render_view_host) {
if (!updating_)
return;
- std::map<ExtensionHost*, TaskManagerExtensionProcessResource*>
- ::iterator iter = resources_.find(extension_host);
+ std::map<content::RenderViewHost*, TaskManagerExtensionProcessResource*>
+ ::iterator iter = resources_.find(render_view_host);
if (iter == resources_.end())
return;

Powered by Google App Engine
This is Rietveld 408576698