| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/task_manager/task_manager.h" | 5 #include "chrome/browser/task_manager/task_manager.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/i18n/number_formatting.h" | 8 #include "base/i18n/number_formatting.h" |
| 9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/numerics/safe_conversions.h" | 11 #include "base/numerics/safe_conversions.h" |
| 12 #include "base/process/process_metrics.h" | 12 #include "base/process/process_metrics.h" |
| 13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
| 14 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
| 15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
| 16 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 17 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
| 18 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 19 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
| 20 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
| 22 #include "chrome/browser/private_working_set_snapshot.h" | 22 #include "chrome/browser/private_working_set_snapshot.h" |
| 23 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
| 24 #include "chrome/browser/profiles/profile_window.h" | 24 #include "chrome/browser/profiles/profile_window.h" |
| 25 #include "chrome/browser/task_management/task_manager_interface.h" |
| 25 #include "chrome/browser/task_manager/background_information.h" | 26 #include "chrome/browser/task_manager/background_information.h" |
| 26 #include "chrome/browser/task_manager/browser_process_resource_provider.h" | 27 #include "chrome/browser/task_manager/browser_process_resource_provider.h" |
| 27 #include "chrome/browser/task_manager/child_process_resource_provider.h" | 28 #include "chrome/browser/task_manager/child_process_resource_provider.h" |
| 28 #include "chrome/browser/task_manager/extension_information.h" | 29 #include "chrome/browser/task_manager/extension_information.h" |
| 29 #include "chrome/browser/task_manager/guest_information.h" | 30 #include "chrome/browser/task_manager/guest_information.h" |
| 30 #include "chrome/browser/task_manager/panel_information.h" | 31 #include "chrome/browser/task_manager/panel_information.h" |
| 31 #include "chrome/browser/task_manager/printing_information.h" | 32 #include "chrome/browser/task_manager/printing_information.h" |
| 32 #include "chrome/browser/task_manager/resource_provider.h" | 33 #include "chrome/browser/task_manager/resource_provider.h" |
| 33 #include "chrome/browser/task_manager/tab_contents_information.h" | 34 #include "chrome/browser/task_manager/tab_contents_information.h" |
| 34 #include "chrome/browser/task_manager/web_contents_resource_provider.h" | 35 #include "chrome/browser/task_manager/web_contents_resource_provider.h" |
| (...skipping 1462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 | 1498 |
| 1498 Resource* TaskManagerModel::GetResource(int index) const { | 1499 Resource* TaskManagerModel::GetResource(int index) const { |
| 1499 CHECK_GE(index, 0); | 1500 CHECK_GE(index, 0); |
| 1500 CHECK_LT(index, static_cast<int>(resources_.size())); | 1501 CHECK_LT(index, static_cast<int>(resources_.size())); |
| 1501 return resources_[index]; | 1502 return resources_[index]; |
| 1502 } | 1503 } |
| 1503 | 1504 |
| 1504 //////////////////////////////////////////////////////////////////////////////// | 1505 //////////////////////////////////////////////////////////////////////////////// |
| 1505 // TaskManager class | 1506 // TaskManager class |
| 1506 //////////////////////////////////////////////////////////////////////////////// | 1507 //////////////////////////////////////////////////////////////////////////////// |
| 1507 // static | |
| 1508 void TaskManager::RegisterPrefs(PrefRegistrySimple* registry) { | |
| 1509 registry->RegisterDictionaryPref(prefs::kTaskManagerWindowPlacement); | |
| 1510 registry->RegisterDictionaryPref(prefs::kTaskManagerColumnVisibility); | |
| 1511 registry->RegisterBooleanPref(prefs::kTaskManagerEndProcessEnabled, true); | |
| 1512 } | |
| 1513 | |
| 1514 // static | |
| 1515 bool TaskManager::IsEndProcessEnabled() { | |
| 1516 if (g_browser_process->local_state()) { | |
| 1517 return g_browser_process->local_state()->GetBoolean( | |
| 1518 prefs::kTaskManagerEndProcessEnabled); | |
| 1519 } | |
| 1520 return true; | |
| 1521 } | |
| 1522 | 1508 |
| 1523 bool TaskManager::IsBrowserProcess(int index) const { | 1509 bool TaskManager::IsBrowserProcess(int index) const { |
| 1524 // If some of the selection is out of bounds, ignore. This may happen when | 1510 // If some of the selection is out of bounds, ignore. This may happen when |
| 1525 // killing a process that manages several pages. | 1511 // killing a process that manages several pages. |
| 1526 return index < model_->ResourceCount() && | 1512 return index < model_->ResourceCount() && |
| 1527 model_->GetProcess(index) == base::GetCurrentProcessHandle(); | 1513 model_->GetProcess(index) == base::GetCurrentProcessHandle(); |
| 1528 } | 1514 } |
| 1529 | 1515 |
| 1530 void TaskManager::KillProcess(int index) { | 1516 void TaskManager::KillProcess(int index) { |
| 1531 base::ProcessHandle process_handle = model_->GetProcess(index); | 1517 base::ProcessHandle process_handle = model_->GetProcess(index); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1558 void TaskManager::OnWindowClosed() { | 1544 void TaskManager::OnWindowClosed() { |
| 1559 model_->StopUpdating(); | 1545 model_->StopUpdating(); |
| 1560 } | 1546 } |
| 1561 | 1547 |
| 1562 void TaskManager::ModelChanged() { | 1548 void TaskManager::ModelChanged() { |
| 1563 model_->ModelChanged(); | 1549 model_->ModelChanged(); |
| 1564 } | 1550 } |
| 1565 | 1551 |
| 1566 // static | 1552 // static |
| 1567 TaskManager* TaskManager::GetInstance() { | 1553 TaskManager* TaskManager::GetInstance() { |
| 1568 CHECK(!switches::NewTaskManagerEnabled()); | 1554 CHECK(!task_management::TaskManagerInterface::IsNewTaskManagerEnabled()); |
| 1569 return base::Singleton<TaskManager>::get(); | 1555 return base::Singleton<TaskManager>::get(); |
| 1570 } | 1556 } |
| 1571 | 1557 |
| 1572 TaskManager::TaskManager() | 1558 TaskManager::TaskManager() |
| 1573 : model_(new TaskManagerModel(this)) { | 1559 : model_(new TaskManagerModel(this)) { |
| 1574 } | 1560 } |
| 1575 | 1561 |
| 1576 TaskManager::~TaskManager() { | 1562 TaskManager::~TaskManager() { |
| 1577 } | 1563 } |
| OLD | NEW |