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

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

Issue 8932003: WebUI Task manager: prevent to kill the wrong process or none (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years 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
« no previous file with comments | « chrome/browser/ui/webui/task_manager_handler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 std::vector<int>::iterator it_last = it_first + length - 1; 300 std::vector<int>::iterator it_last = it_first + length - 1;
301 resource_to_group_table_.erase(it_first, it_last); 301 resource_to_group_table_.erase(it_first, it_last);
302 302
303 OnGroupRemoved(group_start, group_end - group_start + 1); 303 OnGroupRemoved(group_start, group_end - group_start + 1);
304 } 304 }
305 305
306 void TaskManagerHandler::Init() { 306 void TaskManagerHandler::Init() {
307 } 307 }
308 308
309 void TaskManagerHandler::RegisterMessages() { 309 void TaskManagerHandler::RegisterMessages() {
310 web_ui_->RegisterMessageCallback("killProcess", 310 web_ui_->RegisterMessageCallback("killProcesses",
311 base::Bind(&TaskManagerHandler::HandleKillProcess, 311 base::Bind(&TaskManagerHandler::HandleKillProcesses,
312 base::Unretained(this))); 312 base::Unretained(this)));
313 web_ui_->RegisterMessageCallback("inspect", 313 web_ui_->RegisterMessageCallback("inspect",
314 base::Bind(&TaskManagerHandler::HandleInspect, 314 base::Bind(&TaskManagerHandler::HandleInspect,
315 base::Unretained(this))); 315 base::Unretained(this)));
316 web_ui_->RegisterMessageCallback("activatePage", 316 web_ui_->RegisterMessageCallback("activatePage",
317 base::Bind(&TaskManagerHandler::HandleActivatePage, 317 base::Bind(&TaskManagerHandler::HandleActivatePage,
318 base::Unretained(this))); 318 base::Unretained(this)));
319 web_ui_->RegisterMessageCallback("openAboutMemory", 319 web_ui_->RegisterMessageCallback("openAboutMemory",
320 base::Bind(&TaskManagerHandler::OpenAboutMemory, 320 base::Bind(&TaskManagerHandler::OpenAboutMemory,
321 base::Unretained(this))); 321 base::Unretained(this)));
(...skipping 12 matching lines...) Expand all
334 if (value->GetAsString(&string16_index)) { 334 if (value->GetAsString(&string16_index)) {
335 base::StringToInt(string16_index, &index); 335 base::StringToInt(string16_index, &index);
336 } else if (value->GetAsDouble(&double_index)) { 336 } else if (value->GetAsDouble(&double_index)) {
337 index = static_cast<int>(double_index); 337 index = static_cast<int>(double_index);
338 } else { 338 } else {
339 value->GetAsInteger(&index); 339 value->GetAsInteger(&index);
340 } 340 }
341 return index; 341 return index;
342 } 342 }
343 343
344 void TaskManagerHandler::HandleKillProcess(const ListValue* indexes) { 344 void TaskManagerHandler::HandleKillProcesses(const ListValue* indexes) {
345 for (ListValue::const_iterator i = indexes->begin(); 345 for (int resource_index = 0; resource_index < model_->ResourceCount();
James Hawkins 2011/12/13 17:44:22 Is there not a better way to do this? It seems li
yoshiki 2011/12/14 09:06:47 I changed to use unique_id to determine the proces
346 i != indexes->end(); i++) { 346 ++resource_index) {
347 int index = parseIndex(*i); 347 int resource_pid = model_->GetProcessId(resource_index);
348 if (index == -1)
349 continue;
350 348
351 int resource_index = model_->GetResourceIndexForGroup(index, 0); 349 for (ListValue::const_iterator i = indexes->begin(); i != indexes->end();
352 if (resource_index == -1) 350 ++i) {
353 continue; 351 int pid = parseIndex(*i);
352 if (pid == -1)
353 continue;
354 354
355 LOG(INFO) << "kill PID:" << model_->GetResourceProcessId(resource_index); 355 if (resource_pid == pid) {
356 task_manager_->KillProcess(resource_index); 356 LOG(INFO) << "kill PID:" << pid;
James Hawkins 2011/12/13 17:44:22 Remove log spam.
yoshiki 2011/12/14 09:06:47 Done.
357 task_manager_->KillProcess(resource_index);
358 break;
359 }
360 }
357 } 361 }
358 } 362 }
359 363
360 void TaskManagerHandler::HandleActivatePage(const ListValue* resource_index) { 364 void TaskManagerHandler::HandleActivatePage(const ListValue* resource_index) {
361 for (ListValue::const_iterator i = resource_index->begin(); 365 for (ListValue::const_iterator i = resource_index->begin();
362 i != resource_index->end(); ++i) { 366 i != resource_index->end(); ++i) {
363 int unique_id = parseIndex(*i); 367 int unique_id = parseIndex(*i);
364 if (unique_id == -1) 368 if (unique_id == -1)
365 continue; 369 continue;
366 370
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 } 487 }
484 } 488 }
485 489
486 void TaskManagerHandler::OnGroupRemoved(const int group_start, 490 void TaskManagerHandler::OnGroupRemoved(const int group_start,
487 const int group_length) { 491 const int group_length) {
488 base::FundamentalValue start_value(group_start); 492 base::FundamentalValue start_value(group_start);
489 base::FundamentalValue length_value(group_length); 493 base::FundamentalValue length_value(group_length);
490 if (is_enabled_ && is_alive()) 494 if (is_enabled_ && is_alive())
491 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value); 495 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value);
492 } 496 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/task_manager_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698