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

Unified Diff: chrome/browser/task_manager/task_manager.cc

Issue 338993004: [TaskManager] Check iterators' availabilities before manipulating them. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/task_manager/task_manager.cc
diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc
index 71e3bf842c6a52b7f09ae8f47f01ac137acd257e..3bed73082f1a81277bf02848be78b8883fedfd64 100644
--- a/chrome/browser/task_manager/task_manager.cc
+++ b/chrome/browser/task_manager/task_manager.cc
@@ -994,6 +994,8 @@ void TaskManagerModel::RemoveResource(Resource* resource) {
// Find the associated group.
GroupMap::iterator group_iter = group_map_.find(process);
DCHECK(group_iter != group_map_.end());
+ if (group_iter == group_map_.end())
+ return;
ResourceList& group_entries = group_iter->second;
// Remove the entry from the group map.
@@ -1001,7 +1003,8 @@ void TaskManagerModel::RemoveResource(Resource* resource) {
group_entries.end(),
resource);
DCHECK(iter != group_entries.end());
- group_entries.erase(iter);
+ if (iter != group_entries.end())
+ group_entries.erase(iter);
// If there are no more entries for that process, do the clean-up.
if (group_entries.empty()) {
@@ -1016,27 +1019,26 @@ void TaskManagerModel::RemoveResource(Resource* resource) {
}
}
- // Prepare to remove the entry from the model list.
+ // Remove the entry from the model list.
iter = std::find(resources_.begin(), resources_.end(), resource);
DCHECK(iter != resources_.end());
- int index = static_cast<int>(iter - resources_.begin());
-
- // Notify the observers that the contents will change.
- FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_,
- OnItemsToBeRemoved(index, 1));
-
- // Now actually remove the entry from the model list.
- resources_.erase(iter);
+ if (iter != resources_.end()) {
+ int index = static_cast<int>(iter - resources_.begin());
+ // Notify the observers that the contents will change.
+ FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_,
+ OnItemsToBeRemoved(index, 1));
+ // Now actually remove the entry from the model list.
+ resources_.erase(iter);
+ // Notify the table that the contents have changed.
+ FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_,
+ OnItemsRemoved(index, 1));
+ }
// Remove the entry from the network maps.
ResourceValueMap::iterator net_iter =
current_byte_count_map_.find(resource);
if (net_iter != current_byte_count_map_.end())
current_byte_count_map_.erase(net_iter);
-
- // Notify the table that the contents have changed.
- FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_,
- OnItemsRemoved(index, 1));
}
void TaskManagerModel::StartUpdating() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698