diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-12 20:16:40 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-12 20:16:40 +0000 |
commit | 36cdba010d3a68204c3e7a2a7656d1a1e1479055 (patch) | |
tree | bcfb103eef83e6aeeda6a0fad9f0485ebc349949 /chrome/browser/task_manager | |
parent | 60c3e91d2a375cb26f065be25380a1fb373e3894 (diff) | |
download | chromium_src-36cdba010d3a68204c3e7a2a7656d1a1e1479055.zip chromium_src-36cdba010d3a68204c3e7a2a7656d1a1e1479055.tar.gz chromium_src-36cdba010d3a68204c3e7a2a7656d1a1e1479055.tar.bz2 |
Consolidates lookup of task manager values.
BUG=none
TEST=none
R=estade@chromium.org,ben@chomium.org,dhollowa@chromium.org
Review URL: https://chromiumcodereview.appspot.com/11885005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176593 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/task_manager')
-rw-r--r-- | chrome/browser/task_manager/task_manager.cc | 78 | ||||
-rw-r--r-- | chrome/browser/task_manager/task_manager.h | 4 |
2 files changed, 82 insertions, 0 deletions
diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc index 0ad35fa..d6970d3 100644 --- a/chrome/browser/task_manager/task_manager.cc +++ b/chrome/browser/task_manager/task_manager.cc @@ -80,6 +80,25 @@ string16 FormatStatsSize(const WebKit::WebCache::ResourceTypeStat& stat) { ui::FormatBytesWithUnits(stat.liveSize, ui::DATA_UNITS_KIBIBYTE, false)); } +// Returns true if the specified id should use the first value in the group. +bool IsSharedByGroup(int col_id) { + switch (col_id) { + case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: + case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: + case IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN: + case IDS_TASK_MANAGER_CPU_COLUMN: + case IDS_TASK_MANAGER_PROCESS_ID_COLUMN: + case IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN: + case IDS_TASK_MANAGER_SQLITE_MEMORY_USED_COLUMN: + case IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN: + case IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN: + case IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN: + return true; + default: + return false; + } +} + } // namespace //////////////////////////////////////////////////////////////////////////////// @@ -149,6 +168,65 @@ int TaskManagerModel::GetResourceIndexByUniqueId(const int unique_id) const { return -1; } +string16 TaskManagerModel::GetResourceById(int index, int col_id) const { + if (IsSharedByGroup(col_id) && !IsResourceFirstInGroup(index)) + return string16(); + + switch (col_id) { + case IDS_TASK_MANAGER_TASK_COLUMN: + return GetResourceTitle(index); + + case IDS_TASK_MANAGER_PROFILE_NAME_COLUMN: + return GetResourceProfileName(index); + + case IDS_TASK_MANAGER_NET_COLUMN: + return GetResourceNetworkUsage(index); + + case IDS_TASK_MANAGER_CPU_COLUMN: + return GetResourceCPUUsage(index); + + case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: + return GetResourcePrivateMemory(index); + + case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: + return GetResourceSharedMemory(index); + + case IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN: + return GetResourcePhysicalMemory(index); + + case IDS_TASK_MANAGER_PROCESS_ID_COLUMN: + return GetResourceProcessId(index); + + case IDS_TASK_MANAGER_GOATS_TELEPORTED_COLUMN: + return GetResourceGoatsTeleported(index); + + case IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN: + return GetResourceWebCoreImageCacheSize(index); + + case IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN: + return GetResourceWebCoreScriptsCacheSize(index); + + case IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN: + return GetResourceWebCoreCSSCacheSize(index); + + case IDS_TASK_MANAGER_FPS_COLUMN: + return GetResourceFPS(index); + + case IDS_TASK_MANAGER_VIDEO_MEMORY_COLUMN: + return GetResourceVideoMemory(index); + + case IDS_TASK_MANAGER_SQLITE_MEMORY_USED_COLUMN: + return GetResourceSqliteMemoryUsed(index); + + case IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN: + return GetResourceV8MemoryAllocatedSize(index); + + default: + NOTREACHED(); + return string16(); + } +} + string16 TaskManagerModel::GetResourceTitle(int index) const { CHECK_LT(index, ResourceCount()); return resources_[index]->GetTitle(); diff --git a/chrome/browser/task_manager/task_manager.h b/chrome/browser/task_manager/task_manager.h index c1d3106..176c4f1 100644 --- a/chrome/browser/task_manager/task_manager.h +++ b/chrome/browser/task_manager/task_manager.h @@ -305,6 +305,10 @@ class TaskManagerModel : public base::RefCountedThreadSafe<TaskManagerModel> { // no resouce has the |unique_id|. int GetResourceIndexByUniqueId(const int unique_id) const; + // Catchall method that calls off to the appropriate GetResourceXXX method + // based on |col_id|. |col_id| is an IDS_ value used to identify the column. + string16 GetResourceById(int index, int col_id) const; + // Methods to return formatted resource information. string16 GetResourceTitle(int index) const; string16 GetResourceProfileName(int index) const; |