OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
12 #include "base/process_util.h" | 12 #include "base/process_util.h" |
13 #include "base/string_number_conversions.h" | 13 #include "base/string_number_conversions.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/thread.h" | 15 #include "base/thread.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "chrome/browser/browser_list.h" | 17 #include "chrome/browser/browser_list.h" |
18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
19 #include "chrome/browser/browser_thread.h" | 19 #include "chrome/browser/browser_thread.h" |
20 #include "chrome/browser/browser_window.h" | 20 #include "chrome/browser/browser_window.h" |
21 #include "chrome/browser/net/url_request_tracking.h" | 21 #include "chrome/browser/net/url_request_tracking.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/renderer_host/render_process_host.h" | 24 #include "chrome/browser/renderer_host/render_process_host.h" |
25 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" | 25 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
26 #include "chrome/browser/tab_contents/tab_contents.h" | 26 #include "chrome/browser/tab_contents/tab_contents.h" |
27 #include "chrome/browser/task_manager/task_manager_resource_providers.h" | 27 #include "chrome/browser/task_manager/task_manager_resource_providers.h" |
28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
| 29 #include "chrome/common/result_codes.h" |
29 #include "chrome/common/url_constants.h" | 30 #include "chrome/common/url_constants.h" |
30 #include "grit/app_resources.h" | 31 #include "grit/app_resources.h" |
31 #include "grit/chromium_strings.h" | 32 #include "grit/chromium_strings.h" |
32 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
33 #include "net/url_request/url_request.h" | 34 #include "net/url_request/url_request.h" |
34 #include "net/url_request/url_request_job.h" | 35 #include "net/url_request/url_request_job.h" |
35 #include "unicode/coll.h" | 36 #include "unicode/coll.h" |
36 | 37 |
37 #if defined(OS_MACOSX) | 38 #if defined(OS_MACOSX) |
38 #include "chrome/browser/mach_broker_mac.h" | 39 #include "chrome/browser/mach_broker_mac.h" |
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 // killing a process that manages several pages. | 938 // killing a process that manages several pages. |
938 return index < model_->ResourceCount() && | 939 return index < model_->ResourceCount() && |
939 model_->GetResourceProcessHandle(index) == | 940 model_->GetResourceProcessHandle(index) == |
940 base::GetCurrentProcessHandle(); | 941 base::GetCurrentProcessHandle(); |
941 } | 942 } |
942 | 943 |
943 void TaskManager::KillProcess(int index) { | 944 void TaskManager::KillProcess(int index) { |
944 base::ProcessHandle process = model_->GetResourceProcessHandle(index); | 945 base::ProcessHandle process = model_->GetResourceProcessHandle(index); |
945 DCHECK(process); | 946 DCHECK(process); |
946 if (process != base::GetCurrentProcessHandle()) | 947 if (process != base::GetCurrentProcessHandle()) |
947 base::KillProcess(process, base::PROCESS_END_KILLED_BY_USER, false); | 948 base::KillProcess(process, ResultCodes::KILLED, false); |
948 } | 949 } |
949 | 950 |
950 void TaskManager::ActivateProcess(int index) { | 951 void TaskManager::ActivateProcess(int index) { |
951 // GetResourceTabContents returns a pointer to the relevant tab contents for | 952 // GetResourceTabContents returns a pointer to the relevant tab contents for |
952 // the resource. If the index doesn't correspond to a Tab (i.e. refers to | 953 // the resource. If the index doesn't correspond to a Tab (i.e. refers to |
953 // the Browser process or a plugin), GetTabContents will return NULL. | 954 // the Browser process or a plugin), GetTabContents will return NULL. |
954 TabContents* chosen_tab_contents = model_->GetResourceTabContents(index); | 955 TabContents* chosen_tab_contents = model_->GetResourceTabContents(index); |
955 if (chosen_tab_contents) | 956 if (chosen_tab_contents) |
956 chosen_tab_contents->Activate(); | 957 chosen_tab_contents->Activate(); |
957 } | 958 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 MetricsMap::const_iterator iter = metrics_map_.find(handle); | 1025 MetricsMap::const_iterator iter = metrics_map_.find(handle); |
1025 if (iter == metrics_map_.end()) | 1026 if (iter == metrics_map_.end()) |
1026 return false; | 1027 return false; |
1027 | 1028 |
1028 if (!iter->second->GetMemoryBytes(&usage->first, &usage->second)) | 1029 if (!iter->second->GetMemoryBytes(&usage->first, &usage->second)) |
1029 return false; | 1030 return false; |
1030 | 1031 |
1031 memory_usage_map_.insert(std::make_pair(handle, *usage)); | 1032 memory_usage_map_.insert(std::make_pair(handle, *usage)); |
1032 return true; | 1033 return true; |
1033 } | 1034 } |
OLD | NEW |