| 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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/i18n/number_formatting.h" | 9 #include "base/i18n/number_formatting.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/process_util.h" | 11 #include "base/process_util.h" |
| 12 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
| 14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/background/background_contents_service.h" | 17 #include "chrome/browser/background/background_contents_service.h" |
| 18 #include "chrome/browser/background/background_contents_service_factory.h" | 18 #include "chrome/browser/background/background_contents_service_factory.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/extensions/extension_host.h" | 20 #include "chrome/browser/extensions/extension_host.h" |
| 21 #include "chrome/browser/extensions/extension_process_manager.h" | 21 #include "chrome/browser/extensions/extension_process_manager.h" |
| 22 #include "chrome/browser/prefs/pref_service.h" | 22 #include "chrome/browser/prefs/pref_service.h" |
| 23 #include "chrome/browser/profiles/profile_manager.h" | 23 #include "chrome/browser/profiles/profile_manager.h" |
| 24 #include "chrome/browser/task_manager/task_manager_resource_providers.h" | 24 #include "chrome/browser/task_manager/task_manager_resource_providers.h" |
| 25 #include "chrome/browser/task_manager/task_manager_worker_resource_provider.h" | 25 #include "chrome/browser/task_manager/task_manager_worker_resource_provider.h" |
| 26 #include "chrome/browser/ui/browser_list.h" | 26 #include "chrome/browser/ui/browser_list.h" |
| 27 #include "chrome/browser/ui/browser_navigator.h" | 27 #include "chrome/browser/ui/browser_navigator.h" |
| 28 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 28 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 29 #include "chrome/common/pref_names.h" | 29 #include "chrome/common/pref_names.h" |
| 30 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
| 31 #include "chrome/common/view_type.h" | 31 #include "chrome/common/view_type.h" |
| 32 #include "content/public/browser/browser_child_process_host.h" | 32 #include "content/public/browser/browser_child_process_host.h" |
| 33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 34 #include "content/public/browser/render_view_host.h" | 34 #include "content/public/browser/render_view_host.h" |
| 35 #include "content/public/browser/resource_request_info.h" | 35 #include "content/public/browser/resource_request_info.h" |
| 36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| 37 #include "content/public/browser/web_contents_delegate.h" | 37 #include "content/public/browser/web_contents_delegate.h" |
| 38 #include "content/public/common/result_codes.h" | 38 #include "content/public/common/result_codes.h" |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 int TaskManagerModel::GetUniqueChildProcessId(int index) const { | 474 int TaskManagerModel::GetUniqueChildProcessId(int index) const { |
| 475 CHECK_LT(index, ResourceCount()); | 475 CHECK_LT(index, ResourceCount()); |
| 476 return resources_[index]->GetUniqueChildProcessId(); | 476 return resources_[index]->GetUniqueChildProcessId(); |
| 477 } | 477 } |
| 478 | 478 |
| 479 TaskManager::Resource::Type TaskManagerModel::GetResourceType(int index) const { | 479 TaskManager::Resource::Type TaskManagerModel::GetResourceType(int index) const { |
| 480 CHECK_LT(index, ResourceCount()); | 480 CHECK_LT(index, ResourceCount()); |
| 481 return resources_[index]->GetType(); | 481 return resources_[index]->GetType(); |
| 482 } | 482 } |
| 483 | 483 |
| 484 TabContentsWrapper* TaskManagerModel::GetResourceTabContents(int index) const { | 484 TabContents* TaskManagerModel::GetResourceTabContents(int index) const { |
| 485 CHECK_LT(index, ResourceCount()); | 485 CHECK_LT(index, ResourceCount()); |
| 486 return resources_[index]->GetTabContents(); | 486 return resources_[index]->GetTabContents(); |
| 487 } | 487 } |
| 488 | 488 |
| 489 const extensions::Extension* TaskManagerModel::GetResourceExtension( | 489 const extensions::Extension* TaskManagerModel::GetResourceExtension( |
| 490 int index) const { | 490 int index) const { |
| 491 CHECK_LT(index, ResourceCount()); | 491 CHECK_LT(index, ResourceCount()); |
| 492 return resources_[index]->GetExtension(); | 492 return resources_[index]->GetExtension(); |
| 493 } | 493 } |
| 494 | 494 |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1091 base::ProcessHandle process = model_->GetResourceProcessHandle(index); | 1091 base::ProcessHandle process = model_->GetResourceProcessHandle(index); |
| 1092 DCHECK(process); | 1092 DCHECK(process); |
| 1093 if (process != base::GetCurrentProcessHandle()) | 1093 if (process != base::GetCurrentProcessHandle()) |
| 1094 base::KillProcess(process, content::RESULT_CODE_KILLED, false); | 1094 base::KillProcess(process, content::RESULT_CODE_KILLED, false); |
| 1095 } | 1095 } |
| 1096 | 1096 |
| 1097 void TaskManager::ActivateProcess(int index) { | 1097 void TaskManager::ActivateProcess(int index) { |
| 1098 // GetResourceTabContents returns a pointer to the relevant tab contents for | 1098 // GetResourceTabContents returns a pointer to the relevant tab contents for |
| 1099 // the resource. If the index doesn't correspond to a Tab (i.e. refers to | 1099 // the resource. If the index doesn't correspond to a Tab (i.e. refers to |
| 1100 // the Browser process or a plugin), GetTabContents will return NULL. | 1100 // the Browser process or a plugin), GetTabContents will return NULL. |
| 1101 TabContentsWrapper* chosen_tab_contents = | 1101 TabContents* chosen_tab_contents = model_->GetResourceTabContents(index); |
| 1102 model_->GetResourceTabContents(index); | |
| 1103 if (chosen_tab_contents) { | 1102 if (chosen_tab_contents) { |
| 1104 WebContents* web_contents = chosen_tab_contents->web_contents(); | 1103 WebContents* web_contents = chosen_tab_contents->web_contents(); |
| 1105 web_contents->GetDelegate()->ActivateContents(web_contents); | 1104 web_contents->GetDelegate()->ActivateContents(web_contents); |
| 1106 } | 1105 } |
| 1107 } | 1106 } |
| 1108 | 1107 |
| 1109 void TaskManager::AddResource(Resource* resource) { | 1108 void TaskManager::AddResource(Resource* resource) { |
| 1110 model_->AddResource(resource); | 1109 model_->AddResource(resource); |
| 1111 } | 1110 } |
| 1112 | 1111 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 // Count the number of extensions with background pages (including | 1191 // Count the number of extensions with background pages (including |
| 1193 // incognito). | 1192 // incognito). |
| 1194 count += CountExtensionBackgroundPagesForProfile(profile); | 1193 count += CountExtensionBackgroundPagesForProfile(profile); |
| 1195 if (profile->HasOffTheRecordProfile()) { | 1194 if (profile->HasOffTheRecordProfile()) { |
| 1196 count += CountExtensionBackgroundPagesForProfile( | 1195 count += CountExtensionBackgroundPagesForProfile( |
| 1197 profile->GetOffTheRecordProfile()); | 1196 profile->GetOffTheRecordProfile()); |
| 1198 } | 1197 } |
| 1199 } | 1198 } |
| 1200 return count; | 1199 return count; |
| 1201 } | 1200 } |
| OLD | NEW |