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

Side by Side Diff: chrome/browser/task_manager/task_manager.cc

Issue 11885005: Consolidates lookup of task manager values. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: garden path Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/task_manager/task_manager.h ('k') | chrome/browser/ui/cocoa/task_manager_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/task_manager/task_manager.h" 5 #include "chrome/browser/task_manager/task_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/i18n/number_formatting.h" 9 #include "base/i18n/number_formatting.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return 0; 73 return 0;
74 return 1; 74 return 1;
75 } 75 }
76 76
77 string16 FormatStatsSize(const WebKit::WebCache::ResourceTypeStat& stat) { 77 string16 FormatStatsSize(const WebKit::WebCache::ResourceTypeStat& stat) {
78 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_CACHE_SIZE_CELL_TEXT, 78 return l10n_util::GetStringFUTF16(IDS_TASK_MANAGER_CACHE_SIZE_CELL_TEXT,
79 ui::FormatBytesWithUnits(stat.size, ui::DATA_UNITS_KIBIBYTE, false), 79 ui::FormatBytesWithUnits(stat.size, ui::DATA_UNITS_KIBIBYTE, false),
80 ui::FormatBytesWithUnits(stat.liveSize, ui::DATA_UNITS_KIBIBYTE, false)); 80 ui::FormatBytesWithUnits(stat.liveSize, ui::DATA_UNITS_KIBIBYTE, false));
81 } 81 }
82 82
83 // Returns true if the specified id should use the first value in the group.
84 bool IsSharedByGroup(int col_id) {
85 switch (col_id) {
86 case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN:
87 case IDS_TASK_MANAGER_SHARED_MEM_COLUMN:
88 case IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN:
89 case IDS_TASK_MANAGER_CPU_COLUMN:
90 case IDS_TASK_MANAGER_PROCESS_ID_COLUMN:
91 case IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN:
92 case IDS_TASK_MANAGER_SQLITE_MEMORY_USED_COLUMN:
93 case IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN:
94 case IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN:
95 case IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN:
96 return true;
97 default:
98 return false;
99 }
100 }
101
83 } // namespace 102 } // namespace
84 103
85 //////////////////////////////////////////////////////////////////////////////// 104 ////////////////////////////////////////////////////////////////////////////////
86 // TaskManagerModel class 105 // TaskManagerModel class
87 //////////////////////////////////////////////////////////////////////////////// 106 ////////////////////////////////////////////////////////////////////////////////
88 107
89 TaskManagerModel::TaskManagerModel(TaskManager* task_manager) 108 TaskManagerModel::TaskManagerModel(TaskManager* task_manager)
90 : pending_video_memory_usage_stats_update_(false), 109 : pending_video_memory_usage_stats_update_(false),
91 update_requests_(0), 110 update_requests_(0),
92 listen_requests_(0), 111 listen_requests_(0),
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 161
143 int TaskManagerModel::GetResourceIndexByUniqueId(const int unique_id) const { 162 int TaskManagerModel::GetResourceIndexByUniqueId(const int unique_id) const {
144 for (int resource_index = 0; resource_index < ResourceCount(); 163 for (int resource_index = 0; resource_index < ResourceCount();
145 ++resource_index) { 164 ++resource_index) {
146 if (GetResourceUniqueId(resource_index) == unique_id) 165 if (GetResourceUniqueId(resource_index) == unique_id)
147 return resource_index; 166 return resource_index;
148 } 167 }
149 return -1; 168 return -1;
150 } 169 }
151 170
171 string16 TaskManagerModel::GetResourceById(int index, int col_id) const {
172 if (IsSharedByGroup(col_id) && !IsResourceFirstInGroup(index))
173 return string16();
174
175 switch (col_id) {
176 case IDS_TASK_MANAGER_TASK_COLUMN:
177 return GetResourceTitle(index);
178
179 case IDS_TASK_MANAGER_PROFILE_NAME_COLUMN:
180 return GetResourceProfileName(index);
181
182 case IDS_TASK_MANAGER_NET_COLUMN:
183 return GetResourceNetworkUsage(index);
184
185 case IDS_TASK_MANAGER_CPU_COLUMN:
186 return GetResourceCPUUsage(index);
187
188 case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN:
189 return GetResourcePrivateMemory(index);
190
191 case IDS_TASK_MANAGER_SHARED_MEM_COLUMN:
192 return GetResourceSharedMemory(index);
193
194 case IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN:
195 return GetResourcePhysicalMemory(index);
196
197 case IDS_TASK_MANAGER_PROCESS_ID_COLUMN:
198 return GetResourceProcessId(index);
199
200 case IDS_TASK_MANAGER_GOATS_TELEPORTED_COLUMN:
201 return GetResourceGoatsTeleported(index);
202
203 case IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN:
204 return GetResourceWebCoreImageCacheSize(index);
205
206 case IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN:
207 return GetResourceWebCoreScriptsCacheSize(index);
208
209 case IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN:
210 return GetResourceWebCoreCSSCacheSize(index);
211
212 case IDS_TASK_MANAGER_FPS_COLUMN:
213 return GetResourceFPS(index);
214
215 case IDS_TASK_MANAGER_VIDEO_MEMORY_COLUMN:
216 return GetResourceVideoMemory(index);
217
218 case IDS_TASK_MANAGER_SQLITE_MEMORY_USED_COLUMN:
219 return GetResourceSqliteMemoryUsed(index);
220
221 case IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN:
222 return GetResourceV8MemoryAllocatedSize(index);
223
224 default:
225 NOTREACHED();
226 return string16();
227 }
228 }
229
152 string16 TaskManagerModel::GetResourceTitle(int index) const { 230 string16 TaskManagerModel::GetResourceTitle(int index) const {
153 CHECK_LT(index, ResourceCount()); 231 CHECK_LT(index, ResourceCount());
154 return resources_[index]->GetTitle(); 232 return resources_[index]->GetTitle();
155 } 233 }
156 234
157 string16 TaskManagerModel::GetResourceProfileName(int index) const { 235 string16 TaskManagerModel::GetResourceProfileName(int index) const {
158 CHECK_LT(index, ResourceCount()); 236 CHECK_LT(index, ResourceCount());
159 return resources_[index]->GetProfileName(); 237 return resources_[index]->GetProfileName();
160 } 238 }
161 239
(...skipping 1181 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 // Count the number of extensions with background pages (including 1421 // Count the number of extensions with background pages (including
1344 // incognito). 1422 // incognito).
1345 count += CountExtensionBackgroundPagesForProfile(profile); 1423 count += CountExtensionBackgroundPagesForProfile(profile);
1346 if (profile->HasOffTheRecordProfile()) { 1424 if (profile->HasOffTheRecordProfile()) {
1347 count += CountExtensionBackgroundPagesForProfile( 1425 count += CountExtensionBackgroundPagesForProfile(
1348 profile->GetOffTheRecordProfile()); 1426 profile->GetOffTheRecordProfile());
1349 } 1427 }
1350 } 1428 }
1351 return count; 1429 return count;
1352 } 1430 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager.h ('k') | chrome/browser/ui/cocoa/task_manager_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698