Chromium Code Reviews| Index: chrome/browser/ui/webui/task_manager_handler.cc |
| diff --git a/chrome/browser/ui/webui/task_manager_handler.cc b/chrome/browser/ui/webui/task_manager_handler.cc |
| index 1ac7463d706467134b632bdad11700e027577e7e..c57d6d650bcd0c95abfa551b252f5c99117a4d89 100644 |
| --- a/chrome/browser/ui/webui/task_manager_handler.cc |
| +++ b/chrome/browser/ui/webui/task_manager_handler.cc |
| @@ -26,6 +26,8 @@ namespace { |
| static Value* CreateColumnValue(const TaskManagerModel* tm, |
| const std::string column_name, |
| const int i) { |
| + if (column_name == "resourceIndex") |
| + return Value::CreateIntegerValue(i); |
| if (column_name == "processId") |
| return Value::CreateStringValue(tm->GetResourceProcessId(i)); |
| if (column_name == "processIdValue") |
| @@ -112,6 +114,8 @@ static Value* CreateColumnValue(const TaskManagerModel* tm, |
| tm->GetV8Memory(i, &v8_memory); |
| return Value::CreateDoubleValue(v8_memory); |
| } |
| + if (column_name == "canInspect") |
| + return Value::CreateBooleanValue(tm->CanInspect(i)); |
| NOTREACHED(); |
| return NULL; |
| @@ -143,11 +147,6 @@ static DictionaryValue* CreateTaskGroupValue(const TaskManagerModel* tm, |
| int length = group_range.second; |
| val->SetInteger("index", index); |
| - val->SetInteger("group_range_start", group_range.first); |
| - val->SetInteger("group_range_length", group_range.second); |
| - val->SetInteger("index_in_group", index - group_range.first); |
| - val->SetBoolean("is_resource_first_in_group", |
| - tm->IsResourceFirstInGroup(index)); |
| val->SetBoolean("isBackgroundResource", |
| tm->IsBackgroundResource(index)); |
| @@ -174,6 +173,7 @@ static DictionaryValue* CreateTaskGroupValue(const TaskManagerModel* tm, |
| CreateGroupColumnList(tm, "v8MemoryAllocatedSizeValue", index, 1, val); |
| // Columns which have some data in each group. |
| + CreateGroupColumnList(tm, "resourceIndex", index, length, val); |
| CreateGroupColumnList(tm, "icon", index, length, val); |
| CreateGroupColumnList(tm, "title", index, length, val); |
| CreateGroupColumnList(tm, "profileName", index, length, val); |
| @@ -183,6 +183,7 @@ static DictionaryValue* CreateTaskGroupValue(const TaskManagerModel* tm, |
| CreateGroupColumnList(tm, "fpsValue", index, length, val); |
| CreateGroupColumnList(tm, "goatsTeleported", index, length, val); |
| CreateGroupColumnList(tm, "goatsTeleportedValue", index, length, val); |
| + CreateGroupColumnList(tm, "canInspect", index, length, val); |
| return val; |
| } |
| @@ -301,6 +302,9 @@ void TaskManagerHandler::RegisterMessages() { |
| web_ui_->RegisterMessageCallback("killProcess", |
| base::Bind(&TaskManagerHandler::HandleKillProcess, |
| base::Unretained(this))); |
| + web_ui_->RegisterMessageCallback("inspect", |
| + base::Bind(&TaskManagerHandler::HandleInspect, |
| + base::Unretained(this))); |
| web_ui_->RegisterMessageCallback("openAboutMemory", |
| base::Bind(&TaskManagerHandler::OpenAboutMemory, |
| base::Unretained(this))); |
| @@ -312,19 +316,24 @@ void TaskManagerHandler::RegisterMessages() { |
| base::Unretained(this))); |
| } |
| +static int parseIndex(const Value* value) { |
| + int index = -1; |
| + string16 string16_index; |
| + double double_index; |
| + if (value->GetAsString(&string16_index)) { |
| + base::StringToInt(string16_index, &index); |
| + } else if (value->GetAsDouble(&double_index)) { |
| + index = static_cast<int>(double_index); |
| + } else { |
| + value->GetAsInteger(&index); |
| + } |
| + return index; |
| +} |
| + |
| void TaskManagerHandler::HandleKillProcess(const ListValue* indexes) { |
| for (ListValue::const_iterator i = indexes->begin(); |
| i != indexes->end(); i++) { |
| - int index = -1; |
| - string16 string16_index; |
| - double double_index; |
| - if ((*i)->GetAsString(&string16_index)) { |
| - base::StringToInt(string16_index, &index); |
| - } else if ((*i)->GetAsDouble(&double_index)) { |
| - index = static_cast<int>(double_index); |
| - } else { |
| - (*i)->GetAsInteger(&index); |
| - } |
| + int index = parseIndex(*i); |
| if (index == -1) |
| continue; |
| @@ -337,6 +346,18 @@ void TaskManagerHandler::HandleKillProcess(const ListValue* indexes) { |
| } |
| } |
| +void TaskManagerHandler::HandleInspect(const ListValue* resource_index) { |
| + for (ListValue::const_iterator i = resource_index->begin(); |
| + i != resource_index->end(); i++) { |
|
yurys
2011/10/26 14:33:44
++i
|
| + int resource_index = parseIndex(*i); |
| + if (resource_index == -1) |
| + continue; |
| + if (model_->CanInspect(resource_index)) |
| + model_->Inspect(resource_index); |
| + break; |
| + } |
| +} |
| + |
| void TaskManagerHandler::DisableTaskManager(const ListValue* indexes) { |
| if (!is_enabled_) |
| return; |