summaryrefslogtreecommitdiffstats
path: root/chrome/browser/task_manager
diff options
context:
space:
mode:
authorpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 16:28:59 +0000
committerpfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-28 16:28:59 +0000
commitef72ae07221215353b17c272db72573f316584e7 (patch)
tree6702e86577d5589f66126c6b330bc32ceb1b4fda /chrome/browser/task_manager
parentbb6434a07ca57d2293e7db65b16c6f3229befeeb (diff)
downloadchromium_src-ef72ae07221215353b17c272db72573f316584e7.zip
chromium_src-ef72ae07221215353b17c272db72573f316584e7.tar.gz
chromium_src-ef72ae07221215353b17c272db72573f316584e7.tar.bz2
TaskManager: allows referencing task resources from the web ui.
BUG=102075 Review URL: http://codereview.chromium.org/8343060 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107740 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/task_manager')
-rw-r--r--chrome/browser/task_manager/task_manager.cc13
-rw-r--r--chrome/browser/task_manager/task_manager.h16
2 files changed, 27 insertions, 2 deletions
diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc
index 9668132..fe26022 100644
--- a/chrome/browser/task_manager/task_manager.cc
+++ b/chrome/browser/task_manager/task_manager.cc
@@ -78,7 +78,8 @@ string16 FormatStatsSize(const WebKit::WebCache::ResourceTypeStat& stat) {
TaskManagerModel::TaskManagerModel(TaskManager* task_manager)
: update_requests_(0),
update_state_(IDLE),
- goat_salt_(rand()) {
+ goat_salt_(rand()),
+ last_unique_id_(0) {
AddResourceProvider(
new TaskManagerBrowserProcessResourceProvider(task_manager));
AddResourceProvider(
@@ -118,6 +119,11 @@ void TaskManagerModel::RemoveObserver(TaskManagerModelObserver* observer) {
observer_list_.RemoveObserver(observer);
}
+int TaskManagerModel::GetResourceUniqueId(int index) const {
+ CHECK_LT(index, ResourceCount());
+ return resources_[index]->get_unique_id();
+}
+
string16 TaskManagerModel::GetResourceTitle(int index) const {
CHECK_LT(index, ResourceCount());
return resources_[index]->GetTitle();
@@ -561,10 +567,12 @@ bool TaskManagerModel::GetV8Memory(int index, size_t* result) const {
}
bool TaskManagerModel::CanInspect(int index) const {
+ CHECK_LT(index, ResourceCount());
return resources_[index]->CanInspect();
}
void TaskManagerModel::Inspect(int index) const {
+ CHECK_LT(index, ResourceCount());
resources_[index]->Inspect();
}
@@ -642,6 +650,8 @@ void TaskManagerModel::AddResourceProvider(
}
void TaskManagerModel::AddResource(TaskManager::Resource* resource) {
+ resource->unique_id_ = ++last_unique_id_;
+
base::ProcessHandle process = resource->GetProcess();
ResourceList* group_entries = NULL;
@@ -767,6 +777,7 @@ void TaskManagerModel::Clear() {
FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_,
OnItemsRemoved(0, size));
}
+ last_unique_id_ = 0;
}
void TaskManagerModel::ModelChanged() {
diff --git a/chrome/browser/task_manager/task_manager.h b/chrome/browser/task_manager/task_manager.h
index f794533..27658b5 100644
--- a/chrome/browser/task_manager/task_manager.h
+++ b/chrome/browser/task_manager/task_manager.h
@@ -131,7 +131,17 @@ class TaskManager {
TASKMANAGER_RESOURCE_TYPE_LIST(TASKMANAGER_RESOURCE_TYPE_LIST_AS_STRING)
default: return "UNKNOWN";
}
- };
+ }
+
+ // Returns resource identifier that is unique within single task manager
+ // session (between StartUpdating and StopUpdating).
+ int get_unique_id() { return unique_id_; }
+ protected:
+ Resource() : unique_id_(0) {}
+
+ private:
+ friend class TaskManagerModel;
+ int unique_id_;
};
// ResourceProviders are responsible for adding/removing resources to the task
@@ -262,6 +272,7 @@ class TaskManagerModel : public base::RefCountedThreadSafe<TaskManagerModel> {
int64 GetNetworkUsage(int index) const;
double GetCPUUsage(int index) const;
int GetProcessId(int index) const;
+ int GetResourceUniqueId(int index) const;
// Methods to return formatted resource information.
string16 GetResourceTitle(int index) const;
@@ -515,6 +526,9 @@ class TaskManagerModel : public base::RefCountedThreadSafe<TaskManagerModel> {
// A salt lick for the goats.
int goat_salt_;
+ // Resource identifier that is unique within single session.
+ int last_unique_id_;
+
DISALLOW_COPY_AND_ASSIGN(TaskManagerModel);
};