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

Side by Side Diff: chrome/browser/ui/cocoa/task_manager_mac.mm

Issue 7831003: Add Profile data to the Task Manager on OS Mac. Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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_resource_providers.cc ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/cocoa/task_manager_mac.h" 5 #include "chrome/browser/ui/cocoa/task_manager_mac.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/mac/mac_util.h" 10 #include "base/mac/mac_util.h"
(...skipping 13 matching lines...) Expand all
24 // Some of the strings below have spaces at the end or are missing letters, to 24 // Some of the strings below have spaces at the end or are missing letters, to
25 // make the columns look nicer, and to take potentially longer localized strings 25 // make the columns look nicer, and to take potentially longer localized strings
26 // into account. 26 // into account.
27 const struct ColumnWidth { 27 const struct ColumnWidth {
28 int columnId; 28 int columnId;
29 int minWidth; 29 int minWidth;
30 int maxWidth; // If this is -1, 1.5*minColumWidth is used as max width. 30 int maxWidth; // If this is -1, 1.5*minColumWidth is used as max width.
31 } columnWidths[] = { 31 } columnWidths[] = {
32 // Note that arraysize includes the trailing \0. That's intended. 32 // Note that arraysize includes the trailing \0. That's intended.
33 { IDS_TASK_MANAGER_PAGE_COLUMN, 120, 600 }, 33 { IDS_TASK_MANAGER_PAGE_COLUMN, 120, 600 },
34 { IDS_TASK_MANAGER_PROFILE_NAME_COLUMN, 60, 200 },
34 { IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN, 35 { IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN,
35 arraysize("800 MiB") * kCharWidth, -1 }, 36 arraysize("800 MiB") * kCharWidth, -1 },
36 { IDS_TASK_MANAGER_SHARED_MEM_COLUMN, 37 { IDS_TASK_MANAGER_SHARED_MEM_COLUMN,
37 arraysize("800 MiB") * kCharWidth, -1 }, 38 arraysize("800 MiB") * kCharWidth, -1 },
38 { IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN, 39 { IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN,
39 arraysize("800 MiB") * kCharWidth, -1 }, 40 arraysize("800 MiB") * kCharWidth, -1 },
40 { IDS_TASK_MANAGER_CPU_COLUMN, 41 { IDS_TASK_MANAGER_CPU_COLUMN,
41 arraysize("99.9") * kCharWidth, -1 }, 42 arraysize("99.9") * kCharWidth, -1 },
42 { IDS_TASK_MANAGER_NET_COLUMN, 43 { IDS_TASK_MANAGER_NET_COLUMN,
43 arraysize("150 kiB/s") * kCharWidth, -1 }, 44 arraysize("150 kiB/s") * kCharWidth, -1 },
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 [tableView_ setDataSource:nil]; 214 [tableView_ setDataSource:nil];
214 [super dealloc]; 215 [super dealloc];
215 } 216 }
216 217
217 // Adds a column which has the given string id as title. |isVisible| specifies 218 // Adds a column which has the given string id as title. |isVisible| specifies
218 // if the column is initially visible. 219 // if the column is initially visible.
219 - (NSTableColumn*)addColumnWithId:(int)columnId visible:(BOOL)isVisible { 220 - (NSTableColumn*)addColumnWithId:(int)columnId visible:(BOOL)isVisible {
220 scoped_nsobject<NSTableColumn> column([[NSTableColumn alloc] 221 scoped_nsobject<NSTableColumn> column([[NSTableColumn alloc]
221 initWithIdentifier:[NSNumber numberWithInt:columnId]]); 222 initWithIdentifier:[NSNumber numberWithInt:columnId]]);
222 223
223 NSTextAlignment textAlignment = columnId == IDS_TASK_MANAGER_PAGE_COLUMN ? 224 NSTextAlignment textAlignment =
224 NSLeftTextAlignment : NSRightTextAlignment; 225 (columnId == IDS_TASK_MANAGER_PAGE_COLUMN ||
226 columnId == IDS_TASK_MANAGER_PROFILE_NAME_COLUMN) ?
227 NSLeftTextAlignment : NSRightTextAlignment;
225 228
226 [[column.get() headerCell] 229 [[column.get() headerCell]
227 setStringValue:l10n_util::GetNSStringWithFixup(columnId)]; 230 setStringValue:l10n_util::GetNSStringWithFixup(columnId)];
228 [[column.get() headerCell] setAlignment:textAlignment]; 231 [[column.get() headerCell] setAlignment:textAlignment];
229 [[column.get() dataCell] setAlignment:textAlignment]; 232 [[column.get() dataCell] setAlignment:textAlignment];
230 233
231 NSFont* font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; 234 NSFont* font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
232 [[column.get() dataCell] setFont:font]; 235 [[column.get() dataCell] setFont:font];
233 236
234 [column.get() setHidden:!isVisible]; 237 [column.get() setHidden:!isVisible];
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 [[NSButtonCell alloc] initTextCell:@""]); 281 [[NSButtonCell alloc] initTextCell:@""]);
279 [nameCell.get() setImagePosition:NSImageLeft]; 282 [nameCell.get() setImagePosition:NSImageLeft];
280 [nameCell.get() setButtonType:NSSwitchButton]; 283 [nameCell.get() setButtonType:NSSwitchButton];
281 [nameCell.get() setAlignment:[[nameColumn dataCell] alignment]]; 284 [nameCell.get() setAlignment:[[nameColumn dataCell] alignment]];
282 [nameCell.get() setFont:[[nameColumn dataCell] font]]; 285 [nameCell.get() setFont:[[nameColumn dataCell] font]];
283 [nameColumn setDataCell:nameCell.get()]; 286 [nameColumn setDataCell:nameCell.get()];
284 287
285 // Initially, sort on the tab name. 288 // Initially, sort on the tab name.
286 [tableView_ setSortDescriptors: 289 [tableView_ setSortDescriptors:
287 [NSArray arrayWithObject:[nameColumn sortDescriptorPrototype]]]; 290 [NSArray arrayWithObject:[nameColumn sortDescriptorPrototype]]];
288 291 [self addColumnWithId:IDS_TASK_MANAGER_PROFILE_NAME_COLUMN visible:NO];
289 [self addColumnWithId:IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN visible:YES]; 292 [self addColumnWithId:IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN visible:YES];
290 [self addColumnWithId:IDS_TASK_MANAGER_SHARED_MEM_COLUMN visible:NO]; 293 [self addColumnWithId:IDS_TASK_MANAGER_SHARED_MEM_COLUMN visible:NO];
291 [self addColumnWithId:IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN visible:NO]; 294 [self addColumnWithId:IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN visible:NO];
292 [self addColumnWithId:IDS_TASK_MANAGER_CPU_COLUMN visible:YES]; 295 [self addColumnWithId:IDS_TASK_MANAGER_CPU_COLUMN visible:YES];
293 [self addColumnWithId:IDS_TASK_MANAGER_NET_COLUMN visible:YES]; 296 [self addColumnWithId:IDS_TASK_MANAGER_NET_COLUMN visible:YES];
294 [self addColumnWithId:IDS_TASK_MANAGER_PROCESS_ID_COLUMN visible:NO]; 297 [self addColumnWithId:IDS_TASK_MANAGER_PROCESS_ID_COLUMN visible:NO];
295 [self addColumnWithId:IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN 298 [self addColumnWithId:IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN
296 visible:NO]; 299 visible:NO];
297 [self addColumnWithId:IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN 300 [self addColumnWithId:IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN
298 visible:NO]; 301 visible:NO];
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 return model_->ResourceCount(); 425 return model_->ResourceCount();
423 } 426 }
424 427
425 - (NSString*)modelTextForRow:(int)row column:(int)columnId { 428 - (NSString*)modelTextForRow:(int)row column:(int)columnId {
426 DCHECK_LT(static_cast<size_t>(row), viewToModelMap_.size()); 429 DCHECK_LT(static_cast<size_t>(row), viewToModelMap_.size());
427 row = viewToModelMap_[row]; 430 row = viewToModelMap_[row];
428 switch (columnId) { 431 switch (columnId) {
429 case IDS_TASK_MANAGER_PAGE_COLUMN: // Process 432 case IDS_TASK_MANAGER_PAGE_COLUMN: // Process
430 return base::SysUTF16ToNSString(model_->GetResourceTitle(row)); 433 return base::SysUTF16ToNSString(model_->GetResourceTitle(row));
431 434
435 case IDS_TASK_MANAGER_PROFILE_NAME_COLUMN: // Profile Name
436 return base::SysUTF16ToNSString(model_->GetResourceProfileName(row));
437
432 case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: // Memory 438 case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: // Memory
433 if (!model_->IsResourceFirstInGroup(row)) 439 if (!model_->IsResourceFirstInGroup(row))
434 return @""; 440 return @"";
435 return base::SysUTF16ToNSString(model_->GetResourcePrivateMemory(row)); 441 return base::SysUTF16ToNSString(model_->GetResourcePrivateMemory(row));
436 442
437 case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: // Memory 443 case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: // Memory
438 if (!model_->IsResourceFirstInGroup(row)) 444 if (!model_->IsResourceFirstInGroup(row))
439 return @""; 445 return @"";
440 return base::SysUTF16ToNSString(model_->GetResourceSharedMemory(row)); 446 return base::SysUTF16ToNSString(model_->GetResourceSharedMemory(row));
441 447
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 // "Task Manager" so close the existing window and fall through to 643 // "Task Manager" so close the existing window and fall through to
638 // open a new one. 644 // open a new one.
639 [[instance_->window_controller_ window] close]; 645 [[instance_->window_controller_ window] close];
640 } 646 }
641 } 647 }
642 // Create a new instance. 648 // Create a new instance.
643 instance_ = new TaskManagerMac(TaskManager::GetInstance(), 649 instance_ = new TaskManagerMac(TaskManager::GetInstance(),
644 highlight_background_resources); 650 highlight_background_resources);
645 instance_->model_->StartUpdating(); 651 instance_->model_->StartUpdating();
646 } 652 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager_resource_providers.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698