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

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

Issue 9565041: Cleanup: Typedef std::pairs in TaskManager code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 9 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.cc ('k') | chrome/browser/ui/gtk/task_manager_gtk.cc » ('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) 2011 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/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/bundle_locations.h" 10 #include "base/mac/bundle_locations.h"
11 #include "base/mac/mac_util.h" 11 #include "base/mac/mac_util.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 }; 62 };
63 63
64 class SortHelper { 64 class SortHelper {
65 public: 65 public:
66 SortHelper(TaskManagerModel* model, NSSortDescriptor* column) 66 SortHelper(TaskManagerModel* model, NSSortDescriptor* column)
67 : sort_column_([[column key] intValue]), 67 : sort_column_([[column key] intValue]),
68 ascending_([column ascending]), 68 ascending_([column ascending]),
69 model_(model) {} 69 model_(model) {}
70 70
71 bool operator()(int a, int b) { 71 bool operator()(int a, int b) {
72 std::pair<int, int> group_range1 = model_->GetGroupRangeForResource(a); 72 TaskManagerModel::GroupRange group_range1 =
73 std::pair<int, int> group_range2 = model_->GetGroupRangeForResource(b); 73 model_->GetGroupRangeForResource(a);
74 TaskManagerModel::GroupRange group_range2 =
75 model_->GetGroupRangeForResource(b);
74 if (group_range1 == group_range2) { 76 if (group_range1 == group_range2) {
75 // The two rows are in the same group, sort so that items in the same 77 // The two rows are in the same group, sort so that items in the same
76 // group always appear in the same order. |ascending_| is intentionally 78 // group always appear in the same order. |ascending_| is intentionally
77 // ignored. 79 // ignored.
78 return a < b; 80 return a < b;
79 } 81 }
80 // Sort by the first entry of each of the groups. 82 // Sort by the first entry of each of the groups.
81 int cmp_result = model_->CompareValues( 83 int cmp_result = model_->CompareValues(
82 group_range1.first, group_range2.first, sort_column_); 84 group_range1.first, group_range2.first, sort_column_);
83 if (!ascending_) 85 if (!ascending_)
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 // are selected as well. Also, check if the selection contains the browser 354 // are selected as well. Also, check if the selection contains the browser
353 // process. 355 // process.
354 NSIndexSet* selection = [tableView_ selectedRowIndexes]; 356 NSIndexSet* selection = [tableView_ selectedRowIndexes];
355 for (NSUInteger i = [selection lastIndex]; 357 for (NSUInteger i = [selection lastIndex];
356 i != NSNotFound; 358 i != NSNotFound;
357 i = [selection indexLessThanIndex:i]) { 359 i = [selection indexLessThanIndex:i]) {
358 int modelIndex = viewToModelMap_[i]; 360 int modelIndex = viewToModelMap_[i];
359 if (taskManager_->IsBrowserProcess(modelIndex)) 361 if (taskManager_->IsBrowserProcess(modelIndex))
360 selectionContainsBrowserProcess = true; 362 selectionContainsBrowserProcess = true;
361 363
362 std::pair<int, int> rangePair = 364 TaskManagerModel::GroupRange rangePair =
363 model_->GetGroupRangeForResource(modelIndex); 365 model_->GetGroupRangeForResource(modelIndex);
364 NSMutableIndexSet* indexSet = [NSMutableIndexSet indexSet]; 366 NSMutableIndexSet* indexSet = [NSMutableIndexSet indexSet];
365 for (int j = 0; j < rangePair.second; ++j) 367 for (int j = 0; j < rangePair.second; ++j)
366 [indexSet addIndex:modelToViewMap_[rangePair.first + j]]; 368 [indexSet addIndex:modelToViewMap_[rangePair.first + j]];
367 [tableView_ selectRowIndexes:indexSet byExtendingSelection:YES]; 369 [tableView_ selectRowIndexes:indexSet byExtendingSelection:YES];
368 } 370 }
369 371
370 bool enabled = [selection count] > 0 && !selectionContainsBrowserProcess; 372 bool enabled = [selection count] > 0 && !selectionContainsBrowserProcess;
371 [endProcessButton_ setEnabled:enabled]; 373 [endProcessButton_ setEnabled:enabled];
372 } 374 }
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 // "Task Manager" so close the existing window and fall through to 646 // "Task Manager" so close the existing window and fall through to
645 // open a new one. 647 // open a new one.
646 [[instance_->window_controller_ window] close]; 648 [[instance_->window_controller_ window] close];
647 } 649 }
648 } 650 }
649 // Create a new instance. 651 // Create a new instance.
650 instance_ = new TaskManagerMac(TaskManager::GetInstance(), 652 instance_ = new TaskManagerMac(TaskManager::GetInstance(),
651 highlight_background_resources); 653 highlight_background_resources);
652 instance_->model_->StartUpdating(); 654 instance_->model_->StartUpdating();
653 } 655 }
OLDNEW
« no previous file with comments | « chrome/browser/task_manager/task_manager.cc ('k') | chrome/browser/ui/gtk/task_manager_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698