summaryrefslogtreecommitdiffstats
path: root/chrome/browser/task_manager/task_manager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/task_manager/task_manager.cc')
-rw-r--r--chrome/browser/task_manager/task_manager.cc54
1 files changed, 36 insertions, 18 deletions
diff --git a/chrome/browser/task_manager/task_manager.cc b/chrome/browser/task_manager/task_manager.cc
index 2711925..c6500fa 100644
--- a/chrome/browser/task_manager/task_manager.cc
+++ b/chrome/browser/task_manager/task_manager.cc
@@ -78,6 +78,10 @@ TaskManagerModel::TaskManagerModel(TaskManager* task_manager)
new TaskManagerBrowserProcessResourceProvider(task_manager);
browser_provider->AddRef();
providers_.push_back(browser_provider);
+ TaskManagerBackgroundContentsResourceProvider* bc_provider =
+ new TaskManagerBackgroundContentsResourceProvider(task_manager);
+ bc_provider->AddRef();
+ providers_.push_back(bc_provider);
TaskManagerTabContentsResourceProvider* wc_provider =
new TaskManagerTabContentsResourceProvider(task_manager);
wc_provider->AddRef();
@@ -116,12 +120,12 @@ void TaskManagerModel::RemoveObserver(TaskManagerModelObserver* observer) {
}
string16 TaskManagerModel::GetResourceTitle(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
return WideToUTF16Hack(resources_[index]->GetTitle());
}
int64 TaskManagerModel::GetNetworkUsage(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
return GetNetworkUsage(resources_[index]);
}
@@ -138,12 +142,12 @@ string16 TaskManagerModel::GetResourceNetworkUsage(int index) const {
}
double TaskManagerModel::GetCPUUsage(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
return GetCPUUsage(resources_[index]);
}
string16 TaskManagerModel::GetResourceCPUUsage(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
return WideToUTF16Hack(StringPrintf(
#if defined(OS_MACOSX)
// Activity Monitor shows %cpu with one decimal digit -- be
@@ -176,7 +180,7 @@ string16 TaskManagerModel::GetResourcePhysicalMemory(int index) const {
}
int TaskManagerModel::GetProcessId(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
return base::GetProcId(resources_[index]->GetProcess());
}
@@ -185,13 +189,13 @@ string16 TaskManagerModel::GetResourceProcessId(int index) const {
}
string16 TaskManagerModel::GetResourceGoatsTeleported(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
return base::FormatNumber(GetGoatsTeleported(index));
}
string16 TaskManagerModel::GetResourceWebCoreImageCacheSize(
int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
if (!resources_[index]->ReportsCacheStats())
return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT);
const WebKit::WebCache::ResourceTypeStats stats(
@@ -201,7 +205,7 @@ string16 TaskManagerModel::GetResourceWebCoreImageCacheSize(
string16 TaskManagerModel::GetResourceWebCoreScriptsCacheSize(
int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
if (!resources_[index]->ReportsCacheStats())
return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT);
const WebKit::WebCache::ResourceTypeStats stats(
@@ -211,7 +215,7 @@ string16 TaskManagerModel::GetResourceWebCoreScriptsCacheSize(
string16 TaskManagerModel::GetResourceWebCoreCSSCacheSize(
int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
if (!resources_[index]->ReportsCacheStats())
return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT);
const WebKit::WebCache::ResourceTypeStats stats(
@@ -220,7 +224,7 @@ string16 TaskManagerModel::GetResourceWebCoreCSSCacheSize(
}
string16 TaskManagerModel::GetResourceSqliteMemoryUsed(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
if (!resources_[index]->ReportsSqliteMemoryUsed())
return l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT);
return GetMemCellText(resources_[index]->SqliteMemoryUsedBytes());
@@ -240,7 +244,7 @@ string16 TaskManagerModel::GetResourceV8MemoryAllocatedSize(
}
bool TaskManagerModel::IsResourceFirstInGroup(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
TaskManager::Resource* resource = resources_[index];
GroupMap::const_iterator iter = group_map_.find(resource->GetProcess());
DCHECK(iter != group_map_.end());
@@ -248,8 +252,13 @@ bool TaskManagerModel::IsResourceFirstInGroup(int index) const {
return ((*group)[0] == resource);
}
+bool TaskManagerModel::IsBackgroundResource(int index) const {
+ CHECK_LT(index, ResourceCount());
+ return resources_[index]->IsBackground();
+}
+
SkBitmap TaskManagerModel::GetResourceIcon(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
SkBitmap icon = resources_[index]->GetIcon();
if (!icon.isNull())
return icon;
@@ -261,7 +270,7 @@ SkBitmap TaskManagerModel::GetResourceIcon(int index) const {
std::pair<int, int> TaskManagerModel::GetGroupRangeForResource(int index)
const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
TaskManager::Resource* resource = resources_[index];
GroupMap::const_iterator group_iter =
group_map_.find(resource->GetProcess());
@@ -388,22 +397,22 @@ int TaskManagerModel::CompareValues(int row1, int row2, int col_id) const {
base::ProcessHandle TaskManagerModel::GetResourceProcessHandle(int index)
const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
return resources_[index]->GetProcess();
}
TaskManager::Resource::Type TaskManagerModel::GetResourceType(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
return resources_[index]->GetType();
}
TabContents* TaskManagerModel::GetResourceTabContents(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
return resources_[index]->GetTabContents();
}
const Extension* TaskManagerModel::GetResourceExtension(int index) const {
- CHECK(index < ResourceCount());
+ CHECK_LT(index, ResourceCount());
return resources_[index]->GetExtension();
}
@@ -607,7 +616,7 @@ void TaskManagerModel::AddResource(TaskManager::Resource* resource) {
resources_.end(),
(*group_entries)[group_entries->size() - 2]);
DCHECK(iter != resources_.end());
- new_entry_index = static_cast<int>(iter - resources_.begin());
+ new_entry_index = static_cast<int>(iter - resources_.begin()) + 1;
resources_.insert(++iter, resource);
}
@@ -711,6 +720,11 @@ void TaskManagerModel::Clear() {
}
}
+void TaskManagerModel::ModelChanged() {
+ // Notify the table that the contents have changed for it to redraw.
+ FOR_EACH_OBSERVER(TaskManagerModelObserver, observer_list_, OnModelChanged());
+}
+
void TaskManagerModel::NotifyResourceTypeStats(
base::ProcessId renderer_id,
const WebKit::WebCache::ResourceTypeStats& stats) {
@@ -962,6 +976,10 @@ void TaskManager::OnWindowClosed() {
model_->StopUpdating();
}
+void TaskManager::ModelChanged() {
+ model_->ModelChanged();
+}
+
// static
TaskManager* TaskManager::GetInstance() {
return Singleton<TaskManager>::get();