OLD | NEW |
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" |
| 10 #include "base/bind_helpers.h" |
9 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
10 #include "base/values.h" | 12 #include "base/values.h" |
11 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/task_manager/task_manager.h" | 14 #include "chrome/browser/task_manager/task_manager.h" |
13 #include "chrome/browser/ui/webui/web_ui_util.h" | 15 #include "chrome/browser/ui/webui/web_ui_util.h" |
14 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
15 #include "content/browser/renderer_host/render_view_host.h" | 17 #include "content/browser/renderer_host/render_view_host.h" |
16 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
17 #include "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
18 #include "content/common/notification_source.h" | 20 #include "content/common/notification_source.h" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 resource_to_group_table_.erase(it_first, it_last); | 292 resource_to_group_table_.erase(it_first, it_last); |
291 | 293 |
292 OnGroupRemoved(group_start, group_end - group_start + 1); | 294 OnGroupRemoved(group_start, group_end - group_start + 1); |
293 } | 295 } |
294 | 296 |
295 void TaskManagerHandler::Init() { | 297 void TaskManagerHandler::Init() { |
296 } | 298 } |
297 | 299 |
298 void TaskManagerHandler::RegisterMessages() { | 300 void TaskManagerHandler::RegisterMessages() { |
299 web_ui_->RegisterMessageCallback("killProcess", | 301 web_ui_->RegisterMessageCallback("killProcess", |
300 NewCallback(this, &TaskManagerHandler::HandleKillProcess)); | 302 base::Bind(&TaskManagerHandler::HandleKillProcess, |
| 303 base::Unretained(this))); |
301 web_ui_->RegisterMessageCallback("openAboutMemory", | 304 web_ui_->RegisterMessageCallback("openAboutMemory", |
302 NewCallback(this, &TaskManagerHandler::OpenAboutMemory)); | 305 base::Bind(&TaskManagerHandler::OpenAboutMemory, |
| 306 base::Unretained(this))); |
303 web_ui_->RegisterMessageCallback("enableTaskManager", | 307 web_ui_->RegisterMessageCallback("enableTaskManager", |
304 NewCallback(this, &TaskManagerHandler::EnableTaskManager)); | 308 base::Bind(&TaskManagerHandler::EnableTaskManager, |
| 309 base::Unretained(this))); |
305 web_ui_->RegisterMessageCallback("disableTaskManager", | 310 web_ui_->RegisterMessageCallback("disableTaskManager", |
306 NewCallback(this, &TaskManagerHandler::DisableTaskManager)); | 311 base::Bind(&TaskManagerHandler::DisableTaskManager, |
| 312 base::Unretained(this))); |
307 } | 313 } |
308 | 314 |
309 void TaskManagerHandler::HandleKillProcess(const ListValue* indexes) { | 315 void TaskManagerHandler::HandleKillProcess(const ListValue* indexes) { |
310 for (ListValue::const_iterator i = indexes->begin(); | 316 for (ListValue::const_iterator i = indexes->begin(); |
311 i != indexes->end(); i++) { | 317 i != indexes->end(); i++) { |
312 int index = -1; | 318 int index = -1; |
313 string16 string16_index; | 319 string16 string16_index; |
314 double double_index; | 320 double double_index; |
315 if ((*i)->GetAsString(&string16_index)) { | 321 if ((*i)->GetAsString(&string16_index)) { |
316 base::StringToInt(string16_index, &index); | 322 base::StringToInt(string16_index, &index); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 } | 420 } |
415 } | 421 } |
416 | 422 |
417 void TaskManagerHandler::OnGroupRemoved(const int group_start, | 423 void TaskManagerHandler::OnGroupRemoved(const int group_start, |
418 const int group_length) { | 424 const int group_length) { |
419 base::FundamentalValue start_value(group_start); | 425 base::FundamentalValue start_value(group_start); |
420 base::FundamentalValue length_value(group_length); | 426 base::FundamentalValue length_value(group_length); |
421 if (is_enabled_) | 427 if (is_enabled_) |
422 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value); | 428 web_ui_->CallJavascriptFunction("taskRemoved", start_value, length_value); |
423 } | 429 } |
OLD | NEW |