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

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

Issue 1992623002: Task Manager: Preserve selection when rows are added (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes from sky Created 4 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/new_task_manager_view_browsertest.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/task_manager/task_manager_table_model.h" 5 #include "chrome/browser/ui/task_manager/task_manager_table_model.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/i18n/number_formatting.h" 10 #include "base/i18n/number_formatting.h"
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 } 576 }
577 577
578 void TaskManagerTableModel::OnTaskAdded(TaskId id) { 578 void TaskManagerTableModel::OnTaskAdded(TaskId id) {
579 // For the table view scrollbar to behave correctly we must inform it that 579 // For the table view scrollbar to behave correctly we must inform it that
580 // a new task has been added. 580 // a new task has been added.
581 581
582 // We will get a newly sorted list from the task manager as opposed to just 582 // We will get a newly sorted list from the task manager as opposed to just
583 // adding |id| to |tasks_| because we want to keep |tasks_| sorted by proc IDs 583 // adding |id| to |tasks_| because we want to keep |tasks_| sorted by proc IDs
584 // and then by Task IDs. 584 // and then by Task IDs.
585 tasks_ = observed_task_manager()->GetTaskIdsList(); 585 tasks_ = observed_task_manager()->GetTaskIdsList();
586 if (table_model_observer_) 586
587 table_model_observer_->OnItemsAdded(RowCount() - 1, 1); 587 if (table_model_observer_) {
588 std::vector<TaskId>::difference_type index =
589 std::find(tasks_.begin(), tasks_.end(), id) - tasks_.begin();
590 table_model_observer_->OnItemsAdded(static_cast<int>(index), 1);
591 }
588 } 592 }
589 593
590 void TaskManagerTableModel::OnTaskToBeRemoved(TaskId id) { 594 void TaskManagerTableModel::OnTaskToBeRemoved(TaskId id) {
591 auto index = std::find(tasks_.begin(), tasks_.end(), id); 595 auto index = std::find(tasks_.begin(), tasks_.end(), id);
592 if (index == tasks_.end()) 596 if (index == tasks_.end())
593 return; 597 return;
594 auto removed_index = index - tasks_.begin(); 598 auto removed_index = index - tasks_.begin();
595 tasks_.erase(index); 599 tasks_.erase(index);
596 if (table_model_observer_) 600 if (table_model_observer_)
597 table_model_observer_->OnItemsRemoved(removed_index, 1); 601 table_model_observer_->OnItemsRemoved(removed_index, 1);
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 bool TaskManagerTableModel::IsTaskFirstInGroup(int row_index) const { 833 bool TaskManagerTableModel::IsTaskFirstInGroup(int row_index) const {
830 if (row_index == 0) 834 if (row_index == 0)
831 return true; 835 return true;
832 836
833 return observed_task_manager()->GetProcessId(tasks_[row_index - 1]) != 837 return observed_task_manager()->GetProcessId(tasks_[row_index - 1]) !=
834 observed_task_manager()->GetProcessId(tasks_[row_index]); 838 observed_task_manager()->GetProcessId(tasks_[row_index]);
835 } 839 }
836 840
837 841
838 } // namespace task_management 842 } // namespace task_management
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/new_task_manager_view_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698