summaryrefslogtreecommitdiffstats
path: root/chrome/browser/task_manager_resource_providers.h
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-06 08:19:49 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-06 08:19:49 +0000
commit8a17bd55d6f0336a3d8e3c66af61a0a3b074dfe9 (patch)
treec46ba5bfb499017b07cacdb6f8665070e77bbb3a /chrome/browser/task_manager_resource_providers.h
parent31e8a0105e34d04ec14a5387b907b90a776d82f5 (diff)
downloadchromium_src-8a17bd55d6f0336a3d8e3c66af61a0a3b074dfe9.zip
chromium_src-8a17bd55d6f0336a3d8e3c66af61a0a3b074dfe9.tar.gz
chromium_src-8a17bd55d6f0336a3d8e3c66af61a0a3b074dfe9.tar.bz2
Display extension processes in task manager.
This is the first part of the change. I will submit code to listen for new extension processes while task manager is open in following patch(es). TEST=Install an extension which renders to the extension shelf, like Buildbot Monitor from http://dev.chromium.org/developers/design-documents/extensions/samples. Open the task manager. You should see the extension process. http://crbug.com/12127 Review URL: http://codereview.chromium.org/115858 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17826 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/task_manager_resource_providers.h')
-rw-r--r--chrome/browser/task_manager_resource_providers.h70
1 files changed, 68 insertions, 2 deletions
diff --git a/chrome/browser/task_manager_resource_providers.h b/chrome/browser/task_manager_resource_providers.h
index 0d336a0..d0e9426 100644
--- a/chrome/browser/task_manager_resource_providers.h
+++ b/chrome/browser/task_manager_resource_providers.h
@@ -5,12 +5,17 @@
#ifndef CHROME_BROWSER_TASK_MANAGER_RESOURCE_PROVIDERS_H_
#define CHROME_BROWSER_TASK_MANAGER_RESOURCE_PROVIDERS_H_
+#include <map>
+#include <vector>
+
#include "base/basictypes.h"
#include "base/process_util.h"
#include "chrome/browser/task_manager.h"
#include "chrome/common/child_process_info.h"
#include "chrome/common/notification_observer.h"
+class Extension;
+class ExtensionHost;
class TabContents;
// These file contains the resource providers used in the task manager.
@@ -28,7 +33,7 @@ class TaskManagerTabContentsResource : public TaskManager::Resource {
// TabContents always provide the network usage.
bool SupportNetworkUsage() const { return true; }
- void SetSupportNetworkUsage() { };
+ void SetSupportNetworkUsage() { }
private:
TabContents* tab_contents_;
@@ -106,7 +111,7 @@ class TaskManagerChildProcessResource : public TaskManager::Resource {
bool network_usage_support_;
// The icon painted for the child processs.
- // TODO (jcampan): we should have plugin specific icons for well-known
+ // TODO(jcampan): we should have plugin specific icons for well-known
// plugins.
static SkBitmap* default_icon_;
@@ -168,6 +173,67 @@ class TaskManagerChildProcessResourceProvider
DISALLOW_COPY_AND_ASSIGN(TaskManagerChildProcessResourceProvider);
};
+class TaskManagerExtensionProcessResource : public TaskManager::Resource {
+ public:
+ explicit TaskManagerExtensionProcessResource(ExtensionHost* extension_host);
+ ~TaskManagerExtensionProcessResource();
+
+ // TaskManagerResource methods:
+ std::wstring GetTitle() const;
+ SkBitmap GetIcon() const;
+ base::ProcessHandle GetProcess() const;
+ bool SupportNetworkUsage() const { return true; }
+ void SetSupportNetworkUsage() { NOTREACHED(); }
+
+ // Returns the pid of the extension process.
+ int process_id() const { return pid_; }
+
+ private:
+ Extension* extension() const;
+
+ // The icon painted for the extension process.
+ static SkBitmap* default_icon_;
+
+ ExtensionHost* extension_host_;
+
+ // Cached data about the extension.
+ base::ProcessHandle process_handle_;
+ int pid_;
+ std::wstring title_;
+
+ DISALLOW_COPY_AND_ASSIGN(TaskManagerExtensionProcessResource);
+};
+
+class TaskManagerExtensionProcessResourceProvider
+ : public TaskManager::ResourceProvider {
+ public:
+ explicit TaskManagerExtensionProcessResourceProvider(
+ TaskManager* task_manager);
+ virtual ~TaskManagerExtensionProcessResourceProvider();
+
+ virtual TaskManager::Resource* GetResource(int origin_pid,
+ int render_process_host_id,
+ int routing_id);
+ virtual void StartUpdating();
+ virtual void StopUpdating();
+
+ private:
+ void AddToTaskManager(ExtensionHost* extension_host);
+
+ TaskManager* task_manager_;
+
+ // Maps the actual resources (ExtensionHost*) to the Task Manager resources.
+ std::map<ExtensionHost*, TaskManagerExtensionProcessResource*> resources_;
+
+ // Maps the pids to the resources (used for quick access to the resource on
+ // byte read notifications).
+ std::map<int, TaskManagerExtensionProcessResource*> pid_to_resources_;
+
+ bool updating_;
+
+ DISALLOW_COPY_AND_ASSIGN(TaskManagerExtensionProcessResourceProvider);
+};
+
class TaskManagerBrowserProcessResource : public TaskManager::Resource {
public:
TaskManagerBrowserProcessResource();