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

Side by Side Diff: chrome/browser/ui/webui/task_manager_handler.cc

Issue 8343060: TaskManager: allows referencing task resources from the web ui. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/webui/task_manager_handler.h" 5 #include "chrome/browser/ui/webui/task_manager_handler.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <functional> 8 #include <functional>
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/string_number_conversions.h" 11 #include "base/string_number_conversions.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/task_manager/task_manager.h" 14 #include "chrome/browser/task_manager/task_manager.h"
15 #include "chrome/browser/ui/webui/web_ui_util.h" 15 #include "chrome/browser/ui/webui/web_ui_util.h"
16 #include "chrome/common/chrome_notification_types.h" 16 #include "chrome/common/chrome_notification_types.h"
17 #include "content/browser/renderer_host/render_view_host.h" 17 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/browser/tab_contents/tab_contents.h" 18 #include "content/browser/tab_contents/tab_contents.h"
19 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
21 #include "third_party/skia/include/core/SkBitmap.h" 21 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "webkit/glue/webpreferences.h" 22 #include "webkit/glue/webpreferences.h"
23 23
24 namespace { 24 namespace {
25 25
26 static Value* CreateColumnValue(const TaskManagerModel* tm, 26 static Value* CreateColumnValue(const TaskManagerModel* tm,
27 const std::string column_name, 27 const std::string column_name,
28 const int i) { 28 const int i) {
29 if (column_name == "resourceIndex") 29 if (column_name == "uniqueId")
30 return Value::CreateIntegerValue(i); 30 return Value::CreateIntegerValue(tm->GetResourceUniqueId(i));
31 if (column_name == "type") 31 if (column_name == "type")
32 return Value::CreateStringValue( 32 return Value::CreateStringValue(
33 TaskManager::Resource::GetResourceTypeAsString( 33 TaskManager::Resource::GetResourceTypeAsString(
34 tm->GetResourceType(i))); 34 tm->GetResourceType(i)));
35 if (column_name == "processId") 35 if (column_name == "processId")
36 return Value::CreateStringValue(tm->GetResourceProcessId(i)); 36 return Value::CreateStringValue(tm->GetResourceProcessId(i));
37 if (column_name == "processIdValue") 37 if (column_name == "processIdValue")
38 return Value::CreateIntegerValue(tm->GetProcessId(i)); 38 return Value::CreateIntegerValue(tm->GetProcessId(i));
39 if (column_name == "cpuUsage") 39 if (column_name == "cpuUsage")
40 return Value::CreateStringValue(tm->GetResourceCPUUsage(i)); 40 return Value::CreateStringValue(tm->GetResourceCPUUsage(i));
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 CreateGroupColumnList(tm, "webCoreScriptsCacheSize", index, 1, val); 171 CreateGroupColumnList(tm, "webCoreScriptsCacheSize", index, 1, val);
172 CreateGroupColumnList(tm, "webCoreScriptsCacheSizeValue", index, 1, val); 172 CreateGroupColumnList(tm, "webCoreScriptsCacheSizeValue", index, 1, val);
173 CreateGroupColumnList(tm, "webCoreCSSCacheSize", index, 1, val); 173 CreateGroupColumnList(tm, "webCoreCSSCacheSize", index, 1, val);
174 CreateGroupColumnList(tm, "webCoreCSSCacheSizeValue", index, 1, val); 174 CreateGroupColumnList(tm, "webCoreCSSCacheSizeValue", index, 1, val);
175 CreateGroupColumnList(tm, "sqliteMemoryUsed", index, 1, val); 175 CreateGroupColumnList(tm, "sqliteMemoryUsed", index, 1, val);
176 CreateGroupColumnList(tm, "sqliteMemoryUsedValue", index, 1, val); 176 CreateGroupColumnList(tm, "sqliteMemoryUsedValue", index, 1, val);
177 CreateGroupColumnList(tm, "v8MemoryAllocatedSize", index, 1, val); 177 CreateGroupColumnList(tm, "v8MemoryAllocatedSize", index, 1, val);
178 CreateGroupColumnList(tm, "v8MemoryAllocatedSizeValue", index, 1, val); 178 CreateGroupColumnList(tm, "v8MemoryAllocatedSizeValue", index, 1, val);
179 179
180 // Columns which have some data in each group. 180 // Columns which have some data in each group.
181 CreateGroupColumnList(tm, "resourceIndex", index, length, val); 181 CreateGroupColumnList(tm, "uniqueId", index, length, val);
182 CreateGroupColumnList(tm, "icon", index, length, val); 182 CreateGroupColumnList(tm, "icon", index, length, val);
183 CreateGroupColumnList(tm, "title", index, length, val); 183 CreateGroupColumnList(tm, "title", index, length, val);
184 CreateGroupColumnList(tm, "profileName", index, length, val); 184 CreateGroupColumnList(tm, "profileName", index, length, val);
185 CreateGroupColumnList(tm, "networkUsage", index, length, val); 185 CreateGroupColumnList(tm, "networkUsage", index, length, val);
186 CreateGroupColumnList(tm, "networkUsageValue", index, length, val); 186 CreateGroupColumnList(tm, "networkUsageValue", index, length, val);
187 CreateGroupColumnList(tm, "fps", index, length, val); 187 CreateGroupColumnList(tm, "fps", index, length, val);
188 CreateGroupColumnList(tm, "fpsValue", index, length, val); 188 CreateGroupColumnList(tm, "fpsValue", index, length, val);
189 CreateGroupColumnList(tm, "goatsTeleported", index, length, val); 189 CreateGroupColumnList(tm, "goatsTeleported", index, length, val);
190 CreateGroupColumnList(tm, "goatsTeleportedValue", index, length, val); 190 CreateGroupColumnList(tm, "goatsTeleportedValue", index, length, val);
191 CreateGroupColumnList(tm, "canInspect", index, length, val); 191 CreateGroupColumnList(tm, "canInspect", index, length, val);
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 continue; 347 continue;
348 348
349 LOG(INFO) << "kill PID:" << model_->GetResourceProcessId(resource_index); 349 LOG(INFO) << "kill PID:" << model_->GetResourceProcessId(resource_index);
350 task_manager_->KillProcess(resource_index); 350 task_manager_->KillProcess(resource_index);
351 } 351 }
352 } 352 }
353 353
354 void TaskManagerHandler::HandleInspect(const ListValue* resource_index) { 354 void TaskManagerHandler::HandleInspect(const ListValue* resource_index) {
355 for (ListValue::const_iterator i = resource_index->begin(); 355 for (ListValue::const_iterator i = resource_index->begin();
356 i != resource_index->end(); ++i) { 356 i != resource_index->end(); ++i) {
357 int resource_index = parseIndex(*i); 357 int unique_id = parseIndex(*i);
358 if (resource_index == -1) 358 if (unique_id == -1)
359 continue; 359 continue;
360 if (model_->CanInspect(resource_index)) 360
361 model_->Inspect(resource_index); 361 for (int resource_index = 0; resource_index < model_->ResourceCount();
362 ++resource_index) {
363 if (model_->GetResourceUniqueId(resource_index) == unique_id) {
364 if (model_->CanInspect(resource_index))
365 model_->Inspect(resource_index);
366 break;
367 }
368 }
369
362 break; 370 break;
363 } 371 }
364 } 372 }
365 373
366 void TaskManagerHandler::DisableTaskManager(const ListValue* indexes) { 374 void TaskManagerHandler::DisableTaskManager(const ListValue* indexes) {
367 if (!is_enabled_) 375 if (!is_enabled_)
368 return; 376 return;
369 377
370 is_enabled_ = false; 378 is_enabled_ = false;
371 model_->StopUpdating(); 379 model_->StopUpdating();
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 458 }
451 } 459 }
452 460
453 void TaskManagerHandler::OnGroupRemoved(const int group_start, 461 void TaskManagerHandler::OnGroupRemoved(const int group_start,
454 const int group_length) { 462 const int group_length) {
455 base::FundamentalValue start_value(group_start); 463 base::FundamentalValue start_value(group_start);
456 base::FundamentalValue length_value(group_length); 464 base::FundamentalValue length_value(group_length);
457 if (is_enabled_ && is_alive()) 465 if (is_enabled_ && is_alive())
458 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value); 466 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value);
459 } 467 }
OLDNEW
« chrome/browser/task_manager/task_manager.h ('K') | « chrome/browser/task_manager/task_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698