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_resource_providers.h" | 5 #include "chrome/browser/task_manager/task_manager_resource_providers.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 render_view_host_(render_view_host), | 108 render_view_host_(render_view_host), |
109 pending_stats_update_(false), | 109 pending_stats_update_(false), |
110 fps_(0.0f), | 110 fps_(0.0f), |
111 pending_fps_update_(false), | 111 pending_fps_update_(false), |
112 v8_memory_allocated_(0), | 112 v8_memory_allocated_(0), |
113 v8_memory_used_(0), | 113 v8_memory_used_(0), |
114 pending_v8_memory_allocated_update_(false) { | 114 pending_v8_memory_allocated_update_(false) { |
115 // We cache the process and pid as when a Tab/BackgroundContents is closed the | 115 // We cache the process and pid as when a Tab/BackgroundContents is closed the |
116 // process reference becomes NULL and the TaskManager still needs it. | 116 // process reference becomes NULL and the TaskManager still needs it. |
117 pid_ = base::GetProcId(process_); | 117 pid_ = base::GetProcId(process_); |
| 118 unique_process_id_ = render_view_host_->GetProcess()->GetID(); |
118 memset(&stats_, 0, sizeof(stats_)); | 119 memset(&stats_, 0, sizeof(stats_)); |
119 } | 120 } |
120 | 121 |
121 TaskManagerRendererResource::~TaskManagerRendererResource() { | 122 TaskManagerRendererResource::~TaskManagerRendererResource() { |
122 } | 123 } |
123 | 124 |
124 void TaskManagerRendererResource::Refresh() { | 125 void TaskManagerRendererResource::Refresh() { |
125 if (!pending_stats_update_) { | 126 if (!pending_stats_update_) { |
126 render_view_host_->Send(new ChromeViewMsg_GetCacheResourceStats); | 127 render_view_host_->Send(new ChromeViewMsg_GetCacheResourceStats); |
127 pending_stats_update_ = true; | 128 pending_stats_update_ = true; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 size_t v8_memory_allocated, size_t v8_memory_used) { | 170 size_t v8_memory_allocated, size_t v8_memory_used) { |
170 v8_memory_allocated_ = v8_memory_allocated; | 171 v8_memory_allocated_ = v8_memory_allocated; |
171 v8_memory_used_ = v8_memory_used; | 172 v8_memory_used_ = v8_memory_used; |
172 pending_v8_memory_allocated_update_ = false; | 173 pending_v8_memory_allocated_update_ = false; |
173 } | 174 } |
174 | 175 |
175 base::ProcessHandle TaskManagerRendererResource::GetProcess() const { | 176 base::ProcessHandle TaskManagerRendererResource::GetProcess() const { |
176 return process_; | 177 return process_; |
177 } | 178 } |
178 | 179 |
| 180 int TaskManagerRendererResource::GetUniqueChildProcessId() const { |
| 181 return unique_process_id_; |
| 182 } |
| 183 |
179 TaskManager::Resource::Type TaskManagerRendererResource::GetType() const { | 184 TaskManager::Resource::Type TaskManagerRendererResource::GetType() const { |
180 return RENDERER; | 185 return RENDERER; |
181 } | 186 } |
182 | 187 |
183 int TaskManagerRendererResource::GetRoutingID() const { | 188 int TaskManagerRendererResource::GetRoutingID() const { |
184 return render_view_host_->GetRoutingID(); | 189 return render_view_host_->GetRoutingID(); |
185 } | 190 } |
186 | 191 |
187 bool TaskManagerRendererResource::ReportsCacheStats() const { | 192 bool TaskManagerRendererResource::ReportsCacheStats() const { |
188 return true; | 193 return true; |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 } | 794 } |
790 | 795 |
791 //////////////////////////////////////////////////////////////////////////////// | 796 //////////////////////////////////////////////////////////////////////////////// |
792 // TaskManagerChildProcessResource class | 797 // TaskManagerChildProcessResource class |
793 //////////////////////////////////////////////////////////////////////////////// | 798 //////////////////////////////////////////////////////////////////////////////// |
794 SkBitmap* TaskManagerChildProcessResource::default_icon_ = NULL; | 799 SkBitmap* TaskManagerChildProcessResource::default_icon_ = NULL; |
795 | 800 |
796 TaskManagerChildProcessResource::TaskManagerChildProcessResource( | 801 TaskManagerChildProcessResource::TaskManagerChildProcessResource( |
797 content::ProcessType type, | 802 content::ProcessType type, |
798 const string16& name, | 803 const string16& name, |
799 base::ProcessHandle handle) | 804 base::ProcessHandle handle, |
| 805 int unique_process_id) |
800 : type_(type), | 806 : type_(type), |
801 name_(name), | 807 name_(name), |
802 handle_(handle), | 808 handle_(handle), |
| 809 unique_process_id_(unique_process_id), |
803 network_usage_support_(false) { | 810 network_usage_support_(false) { |
804 // We cache the process id because it's not cheap to calculate, and it won't | 811 // We cache the process id because it's not cheap to calculate, and it won't |
805 // be available when we get the plugin disconnected notification. | 812 // be available when we get the plugin disconnected notification. |
806 pid_ = base::GetProcId(handle); | 813 pid_ = base::GetProcId(handle); |
807 if (!default_icon_) { | 814 if (!default_icon_) { |
808 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 815 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
809 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); | 816 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); |
810 // TODO(jabdelmalek): use different icon for web workers. | 817 // TODO(jabdelmalek): use different icon for web workers. |
811 } | 818 } |
812 } | 819 } |
(...skipping 14 matching lines...) Expand all Loading... |
827 } | 834 } |
828 | 835 |
829 SkBitmap TaskManagerChildProcessResource::GetIcon() const { | 836 SkBitmap TaskManagerChildProcessResource::GetIcon() const { |
830 return *default_icon_; | 837 return *default_icon_; |
831 } | 838 } |
832 | 839 |
833 base::ProcessHandle TaskManagerChildProcessResource::GetProcess() const { | 840 base::ProcessHandle TaskManagerChildProcessResource::GetProcess() const { |
834 return handle_; | 841 return handle_; |
835 } | 842 } |
836 | 843 |
| 844 int TaskManagerChildProcessResource::GetUniqueChildProcessId() const { |
| 845 return unique_process_id_; |
| 846 } |
| 847 |
837 TaskManager::Resource::Type TaskManagerChildProcessResource::GetType() const { | 848 TaskManager::Resource::Type TaskManagerChildProcessResource::GetType() const { |
838 // Translate types to TaskManager::ResourceType, since ChildProcessData's type | 849 // Translate types to TaskManager::ResourceType, since ChildProcessData's type |
839 // is not available for all TaskManager resources. | 850 // is not available for all TaskManager resources. |
840 switch (type_) { | 851 switch (type_) { |
841 case content::PROCESS_TYPE_PLUGIN: | 852 case content::PROCESS_TYPE_PLUGIN: |
842 case content::PROCESS_TYPE_PPAPI_PLUGIN: | 853 case content::PROCESS_TYPE_PPAPI_PLUGIN: |
843 case content::PROCESS_TYPE_PPAPI_BROKER: | 854 case content::PROCESS_TYPE_PPAPI_BROKER: |
844 return TaskManager::Resource::PLUGIN; | 855 return TaskManager::Resource::PLUGIN; |
845 case content::PROCESS_TYPE_NACL_LOADER: | 856 case content::PROCESS_TYPE_NACL_LOADER: |
846 case content::PROCESS_TYPE_NACL_BROKER: | 857 case content::PROCESS_TYPE_NACL_BROKER: |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 // Finally, delete the resource. | 1071 // Finally, delete the resource. |
1061 delete resource; | 1072 delete resource; |
1062 } | 1073 } |
1063 | 1074 |
1064 void TaskManagerChildProcessResourceProvider::AddToTaskManager( | 1075 void TaskManagerChildProcessResourceProvider::AddToTaskManager( |
1065 const content::ChildProcessData& child_process_data) { | 1076 const content::ChildProcessData& child_process_data) { |
1066 TaskManagerChildProcessResource* resource = | 1077 TaskManagerChildProcessResource* resource = |
1067 new TaskManagerChildProcessResource( | 1078 new TaskManagerChildProcessResource( |
1068 child_process_data.type, | 1079 child_process_data.type, |
1069 child_process_data.name, | 1080 child_process_data.name, |
1070 child_process_data.handle); | 1081 child_process_data.handle, |
| 1082 child_process_data.id); |
1071 resources_[child_process_data.handle] = resource; | 1083 resources_[child_process_data.handle] = resource; |
1072 pid_to_resources_[resource->process_id()] = resource; | 1084 pid_to_resources_[resource->process_id()] = resource; |
1073 task_manager_->AddResource(resource); | 1085 task_manager_->AddResource(resource); |
1074 } | 1086 } |
1075 | 1087 |
1076 // The ChildProcessData::Iterator has to be used from the IO thread. | 1088 // The ChildProcessData::Iterator has to be used from the IO thread. |
1077 void TaskManagerChildProcessResourceProvider::RetrieveChildProcessData() { | 1089 void TaskManagerChildProcessResourceProvider::RetrieveChildProcessData() { |
1078 std::vector<content::ChildProcessData> child_processes; | 1090 std::vector<content::ChildProcessData> child_processes; |
1079 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { | 1091 for (BrowserChildProcessHostIterator iter; !iter.Done(); ++iter) { |
1080 // Only add processes which are already started, since we need their handle. | 1092 // Only add processes which are already started, since we need their handle. |
(...skipping 24 matching lines...) Expand all Loading... |
1105 SkBitmap* TaskManagerExtensionProcessResource::default_icon_ = NULL; | 1117 SkBitmap* TaskManagerExtensionProcessResource::default_icon_ = NULL; |
1106 | 1118 |
1107 TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource( | 1119 TaskManagerExtensionProcessResource::TaskManagerExtensionProcessResource( |
1108 ExtensionHost* extension_host) | 1120 ExtensionHost* extension_host) |
1109 : extension_host_(extension_host) { | 1121 : extension_host_(extension_host) { |
1110 if (!default_icon_) { | 1122 if (!default_icon_) { |
1111 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 1123 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
1112 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); | 1124 default_icon_ = rb.GetBitmapNamed(IDR_PLUGIN); |
1113 } | 1125 } |
1114 process_handle_ = extension_host_->render_process_host()->GetHandle(); | 1126 process_handle_ = extension_host_->render_process_host()->GetHandle(); |
| 1127 unique_process_id_ = extension_host_->render_process_host()->GetID(); |
1115 pid_ = base::GetProcId(process_handle_); | 1128 pid_ = base::GetProcId(process_handle_); |
1116 string16 extension_name = UTF8ToUTF16(GetExtension()->name()); | 1129 string16 extension_name = UTF8ToUTF16(GetExtension()->name()); |
1117 DCHECK(!extension_name.empty()); | 1130 DCHECK(!extension_name.empty()); |
1118 | 1131 |
1119 int message_id = GetMessagePrefixID(GetExtension()->is_app(), true, | 1132 int message_id = GetMessagePrefixID(GetExtension()->is_app(), true, |
1120 extension_host_->profile()->IsOffTheRecord(), false, false); | 1133 extension_host_->profile()->IsOffTheRecord(), false, false); |
1121 title_ = l10n_util::GetStringFUTF16(message_id, extension_name); | 1134 title_ = l10n_util::GetStringFUTF16(message_id, extension_name); |
1122 } | 1135 } |
1123 | 1136 |
1124 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { | 1137 TaskManagerExtensionProcessResource::~TaskManagerExtensionProcessResource() { |
(...skipping 15 matching lines...) Expand all Loading... |
1140 } | 1153 } |
1141 | 1154 |
1142 SkBitmap TaskManagerExtensionProcessResource::GetIcon() const { | 1155 SkBitmap TaskManagerExtensionProcessResource::GetIcon() const { |
1143 return *default_icon_; | 1156 return *default_icon_; |
1144 } | 1157 } |
1145 | 1158 |
1146 base::ProcessHandle TaskManagerExtensionProcessResource::GetProcess() const { | 1159 base::ProcessHandle TaskManagerExtensionProcessResource::GetProcess() const { |
1147 return process_handle_; | 1160 return process_handle_; |
1148 } | 1161 } |
1149 | 1162 |
| 1163 int TaskManagerExtensionProcessResource::GetUniqueChildProcessId() const { |
| 1164 return unique_process_id_; |
| 1165 } |
| 1166 |
1150 TaskManager::Resource::Type | 1167 TaskManager::Resource::Type |
1151 TaskManagerExtensionProcessResource::GetType() const { | 1168 TaskManagerExtensionProcessResource::GetType() const { |
1152 return EXTENSION; | 1169 return EXTENSION; |
1153 } | 1170 } |
1154 | 1171 |
1155 bool TaskManagerExtensionProcessResource::CanInspect() const { | 1172 bool TaskManagerExtensionProcessResource::CanInspect() const { |
1156 return true; | 1173 return true; |
1157 } | 1174 } |
1158 | 1175 |
1159 void TaskManagerExtensionProcessResource::Inspect() const { | 1176 void TaskManagerExtensionProcessResource::Inspect() const { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 } | 1389 } |
1373 | 1390 |
1374 size_t TaskManagerBrowserProcessResource::SqliteMemoryUsedBytes() const { | 1391 size_t TaskManagerBrowserProcessResource::SqliteMemoryUsedBytes() const { |
1375 return static_cast<size_t>(sqlite3_memory_used()); | 1392 return static_cast<size_t>(sqlite3_memory_used()); |
1376 } | 1393 } |
1377 | 1394 |
1378 base::ProcessHandle TaskManagerBrowserProcessResource::GetProcess() const { | 1395 base::ProcessHandle TaskManagerBrowserProcessResource::GetProcess() const { |
1379 return base::GetCurrentProcessHandle(); // process_; | 1396 return base::GetCurrentProcessHandle(); // process_; |
1380 } | 1397 } |
1381 | 1398 |
| 1399 int TaskManagerBrowserProcessResource::GetUniqueChildProcessId() const { |
| 1400 return 0; |
| 1401 } |
| 1402 |
1382 TaskManager::Resource::Type TaskManagerBrowserProcessResource::GetType() const { | 1403 TaskManager::Resource::Type TaskManagerBrowserProcessResource::GetType() const { |
1383 return BROWSER; | 1404 return BROWSER; |
1384 } | 1405 } |
1385 | 1406 |
1386 bool TaskManagerBrowserProcessResource::SupportNetworkUsage() const { | 1407 bool TaskManagerBrowserProcessResource::SupportNetworkUsage() const { |
1387 return true; | 1408 return true; |
1388 } | 1409 } |
1389 | 1410 |
1390 void TaskManagerBrowserProcessResource::SetSupportNetworkUsage() { | 1411 void TaskManagerBrowserProcessResource::SetSupportNetworkUsage() { |
1391 NOTREACHED(); | 1412 NOTREACHED(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1441 | 1462 |
1442 return &resource_; | 1463 return &resource_; |
1443 } | 1464 } |
1444 | 1465 |
1445 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { | 1466 void TaskManagerBrowserProcessResourceProvider::StartUpdating() { |
1446 task_manager_->AddResource(&resource_); | 1467 task_manager_->AddResource(&resource_); |
1447 } | 1468 } |
1448 | 1469 |
1449 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { | 1470 void TaskManagerBrowserProcessResourceProvider::StopUpdating() { |
1450 } | 1471 } |
OLD | NEW |