Chromium Code Reviews| Index: chrome/browser/automation/automation_provider_observers.cc |
| diff --git a/chrome/browser/automation/automation_provider_observers.cc b/chrome/browser/automation/automation_provider_observers.cc |
| index 8377cc8256a72d38abcee463a414ad04182b2ca0..2e1bd1f170e5bbb4af0343b2e215309f0c2af3cf 100644 |
| --- a/chrome/browser/automation/automation_provider_observers.cc |
| +++ b/chrome/browser/automation/automation_provider_observers.cc |
| @@ -70,6 +70,7 @@ |
| #include "content/browser/renderer_host/render_view_host.h" |
| #include "content/browser/tab_contents/navigation_controller.h" |
| #include "content/browser/tab_contents/tab_contents.h" |
| +#include "content/common/child_process_info.h" |
| #include "content/common/json_value_serializer.h" |
| #include "content/common/notification_service.h" |
| #include "googleurl/src/gurl.h" |
| @@ -2748,3 +2749,85 @@ void DragTargetDropAckNotificationObserver::Observe( |
| } |
| delete this; |
| } |
| + |
| +ProcessInfoObserver::ProcessInfoObserver( |
| + AutomationProvider* automation, |
| + IPC::Message* reply_message) |
| + : automation_(automation->AsWeakPtr()), |
| + reply_message_(reply_message) {} |
| + |
| +void ProcessInfoObserver::OnDetailsAvailable() { |
| + scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| + ListValue* browser_proc_list = new ListValue(); |
| + const std::vector<ProcessData>& browser_processes = processes(); |
|
Nirnimesh
2011/09/21 22:42:35
This includes all processes right (extensions, plu
dennis_jeffrey
2011/09/22 18:25:35
Yes, it includes all processes associated with a b
|
| + for (size_t index = 0; index < browser_processes.size(); ++index) { |
| + DictionaryValue* browser_data = new DictionaryValue(); |
| + browser_data->SetString("name", browser_processes[index].name); |
| + browser_data->SetString("process_name", |
| + browser_processes[index].process_name); |
| + |
| + ListValue* proc_list = new ListValue(); |
| + for (ProcessMemoryInformationList::const_iterator iterator = |
| + browser_processes[index].processes.begin(); |
| + iterator != browser_processes[index].processes.end(); ++iterator) { |
| + DictionaryValue* proc_data = new DictionaryValue(); |
| + |
| + proc_data->SetInteger("pid", iterator->pid); |
| + |
| + // Working set (resident) memory usage, in KBytes. |
| + DictionaryValue* working_set = new DictionaryValue(); |
| + working_set->SetInteger("priv", iterator->working_set.priv); |
| + working_set->SetInteger("shareable", iterator->working_set.shareable); |
| + working_set->SetInteger("shared", iterator->working_set.shared); |
| + proc_data->Set("working_set_mem", working_set); |
| + |
| + // Committed (resident + paged) memory usage, in KBytes. |
| + DictionaryValue* committed = new DictionaryValue(); |
| + committed->SetInteger("priv", iterator->committed.priv); |
| + committed->SetInteger("mapped", iterator->committed.mapped); |
| + committed->SetInteger("image", iterator->committed.image); |
| + proc_data->Set("committed_mem", committed); |
| + |
| + proc_data->SetString("version", iterator->version); |
| + proc_data->SetString("product_name", iterator->product_name); |
| + proc_data->SetInteger("num_processes", iterator->num_processes); |
| + proc_data->SetBoolean("is_diagnostics", iterator->is_diagnostics); |
| + |
| + // Process type, if this is a child process of Chrome (e.g., 'plugin'). |
| + std::string process_type = "Unknown"; |
| + // The following condition avoids a DCHECK in debug builds when the |
| + // process type passed to |GetTypeNameInEnglish| is unknown. |
| + if (iterator->type != ChildProcessInfo::UNKNOWN_PROCESS) |
| + process_type = ChildProcessInfo::GetTypeNameInEnglish(iterator->type); |
| + proc_data->SetString("child_process_type", process_type); |
| + |
| + // Renderer type, if this is a renderer process. |
| + std::string renderer_type = "Unknown"; |
| + // The following condition avoids a NOTREACHED in debug builds when the |
|
Nirnimesh
2011/09/21 22:42:35
No need to repeat this comment
dennis_jeffrey
2011/09/22 18:25:35
Done.
|
| + // renderer type passed to |GetRendererTypeNameInEnglish| is unknown. |
| + if (iterator->renderer_type != ChildProcessInfo::RENDERER_UNKNOWN) { |
| + renderer_type = ChildProcessInfo::GetRendererTypeNameInEnglish( |
| + iterator->renderer_type); |
| + } |
| + proc_data->SetString("renderer_type", renderer_type); |
| + |
| + // Titles associated with this process. |
| + ListValue* titles = new ListValue(); |
| + for (size_t title_index = 0; title_index < iterator->titles.size(); |
| + ++title_index) |
| + titles->Append(Value::CreateStringValue(iterator->titles[title_index])); |
| + proc_data->Set("titles", titles); |
| + |
| + proc_list->Append(proc_data); |
| + } |
| + browser_data->Set("processes", proc_list); |
| + |
| + browser_proc_list->Append(browser_data); |
| + } |
| + return_value->Set("browsers", browser_proc_list); |
| + |
| + if (automation_) { |
| + AutomationJSONReply(automation_, reply_message_.release()) |
| + .SendSuccess(return_value.get()); |
| + } |
| +} |