OLD | NEW |
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 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 | 579 |
580 bool TaskManagerModel::GetV8Memory(int index, size_t* result) const { | 580 bool TaskManagerModel::GetV8Memory(int index, size_t* result) const { |
581 *result = 0; | 581 *result = 0; |
582 if (!resources_[index]->ReportsV8MemoryStats()) | 582 if (!resources_[index]->ReportsV8MemoryStats()) |
583 return false; | 583 return false; |
584 | 584 |
585 *result = resources_[index]->GetV8MemoryAllocated(); | 585 *result = resources_[index]->GetV8MemoryAllocated(); |
586 return true; | 586 return true; |
587 } | 587 } |
588 | 588 |
| 589 bool TaskManagerModel::GetV8MemoryUsed(int index, size_t* result) const { |
| 590 *result = 0; |
| 591 if (!resources_[index]->ReportsV8MemoryStats()) |
| 592 return false; |
| 593 |
| 594 *result = resources_[index]->GetV8MemoryUsed(); |
| 595 return true; |
| 596 } |
| 597 |
589 bool TaskManagerModel::CanActivate(int index) const { | 598 bool TaskManagerModel::CanActivate(int index) const { |
590 CHECK_LT(index, ResourceCount()); | 599 CHECK_LT(index, ResourceCount()); |
591 return GetResourceTabContents(index) != NULL; | 600 return GetResourceTabContents(index) != NULL; |
592 } | 601 } |
593 | 602 |
594 bool TaskManagerModel::CanInspect(int index) const { | 603 bool TaskManagerModel::CanInspect(int index) const { |
595 CHECK_LT(index, ResourceCount()); | 604 CHECK_LT(index, ResourceCount()); |
596 return resources_[index]->CanInspect(); | 605 return resources_[index]->CanInspect(); |
597 } | 606 } |
598 | 607 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 if (pm_iter != metrics_map_.end()) { | 760 if (pm_iter != metrics_map_.end()) { |
752 delete pm_iter->second; | 761 delete pm_iter->second; |
753 metrics_map_.erase(process); | 762 metrics_map_.erase(process); |
754 } | 763 } |
755 // And we don't need the CPU usage anymore either. | 764 // And we don't need the CPU usage anymore either. |
756 CPUUsageMap::iterator cpu_iter = cpu_usage_map_.find(process); | 765 CPUUsageMap::iterator cpu_iter = cpu_usage_map_.find(process); |
757 if (cpu_iter != cpu_usage_map_.end()) | 766 if (cpu_iter != cpu_usage_map_.end()) |
758 cpu_usage_map_.erase(cpu_iter); | 767 cpu_usage_map_.erase(cpu_iter); |
759 } | 768 } |
760 | 769 |
761 // Remove the entry from the model list. | 770 // Prepare to remove the entry from the model list. |
762 iter = std::find(resources_.begin(), resources_.end(), resource); | 771 iter = std::find(resources_.begin(), resources_.end(), resource); |
763 DCHECK(iter != resources_.end()); | 772 DCHECK(iter != resources_.end()); |
764 int index = static_cast<int>(iter - resources_.begin()); | 773 int index = static_cast<int>(iter - resources_.begin()); |
| 774 |
| 775 // Notify the observers that the contents will change. |
| 776 FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_, |
| 777 OnItemsToBeRemoved(index, 1)); |
| 778 |
| 779 // Now actually remove the entry from the model list. |
765 resources_.erase(iter); | 780 resources_.erase(iter); |
766 | 781 |
767 // Remove the entry from the network maps. | 782 // Remove the entry from the network maps. |
768 ResourceValueMap::iterator net_iter = | 783 ResourceValueMap::iterator net_iter = |
769 current_byte_count_map_.find(resource); | 784 current_byte_count_map_.find(resource); |
770 if (net_iter != current_byte_count_map_.end()) | 785 if (net_iter != current_byte_count_map_.end()) |
771 current_byte_count_map_.erase(net_iter); | 786 current_byte_count_map_.erase(net_iter); |
772 net_iter = displayed_network_usage_map_.find(resource); | 787 net_iter = displayed_network_usage_map_.find(resource); |
773 if (net_iter != displayed_network_usage_map_.end()) | 788 if (net_iter != displayed_network_usage_map_.end()) |
774 displayed_network_usage_map_.erase(net_iter); | 789 displayed_network_usage_map_.erase(net_iter); |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 // Count the number of extensions with background pages (including | 1181 // Count the number of extensions with background pages (including |
1167 // incognito). | 1182 // incognito). |
1168 count += CountExtensionBackgroundPagesForProfile(profile); | 1183 count += CountExtensionBackgroundPagesForProfile(profile); |
1169 if (profile->HasOffTheRecordProfile()) { | 1184 if (profile->HasOffTheRecordProfile()) { |
1170 count += CountExtensionBackgroundPagesForProfile( | 1185 count += CountExtensionBackgroundPagesForProfile( |
1171 profile->GetOffTheRecordProfile()); | 1186 profile->GetOffTheRecordProfile()); |
1172 } | 1187 } |
1173 } | 1188 } |
1174 return count; | 1189 return count; |
1175 } | 1190 } |
OLD | NEW |