Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/automation/automation_provider_observers.h" | 5 #include "chrome/browser/automation/automation_provider_observers.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 63 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 64 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" | 64 #include "chrome/browser/ui/webui/ntp/recently_closed_tabs_handler.h" |
| 65 #include "chrome/common/automation_messages.h" | 65 #include "chrome/common/automation_messages.h" |
| 66 #include "chrome/common/chrome_notification_types.h" | 66 #include "chrome/common/chrome_notification_types.h" |
| 67 #include "chrome/common/extensions/extension.h" | 67 #include "chrome/common/extensions/extension.h" |
| 68 #include "content/browser/download/save_package.h" | 68 #include "content/browser/download/save_package.h" |
| 69 #include "content/browser/renderer_host/render_process_host.h" | 69 #include "content/browser/renderer_host/render_process_host.h" |
| 70 #include "content/browser/renderer_host/render_view_host.h" | 70 #include "content/browser/renderer_host/render_view_host.h" |
| 71 #include "content/browser/tab_contents/navigation_controller.h" | 71 #include "content/browser/tab_contents/navigation_controller.h" |
| 72 #include "content/browser/tab_contents/tab_contents.h" | 72 #include "content/browser/tab_contents/tab_contents.h" |
| 73 #include "content/common/child_process_info.h" | |
| 73 #include "content/common/json_value_serializer.h" | 74 #include "content/common/json_value_serializer.h" |
| 74 #include "content/common/notification_service.h" | 75 #include "content/common/notification_service.h" |
| 75 #include "googleurl/src/gurl.h" | 76 #include "googleurl/src/gurl.h" |
| 76 #include "third_party/skia/include/core/SkBitmap.h" | 77 #include "third_party/skia/include/core/SkBitmap.h" |
| 77 #include "ui/gfx/codec/png_codec.h" | 78 #include "ui/gfx/codec/png_codec.h" |
| 78 #include "ui/gfx/rect.h" | 79 #include "ui/gfx/rect.h" |
| 79 | 80 |
| 80 // Holds onto start and stop timestamps for a particular tab | 81 // Holds onto start and stop timestamps for a particular tab |
| 81 class InitialLoadObserver::TabTime { | 82 class InitialLoadObserver::TabTime { |
| 82 public: | 83 public: |
| (...skipping 2658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2741 void DragTargetDropAckNotificationObserver::Observe( | 2742 void DragTargetDropAckNotificationObserver::Observe( |
| 2742 int type, | 2743 int type, |
| 2743 const NotificationSource& source, | 2744 const NotificationSource& source, |
| 2744 const NotificationDetails& details) { | 2745 const NotificationDetails& details) { |
| 2745 if (automation_) { | 2746 if (automation_) { |
| 2746 AutomationJSONReply(automation_, | 2747 AutomationJSONReply(automation_, |
| 2747 reply_message_.release()).SendSuccess(NULL); | 2748 reply_message_.release()).SendSuccess(NULL); |
| 2748 } | 2749 } |
| 2749 delete this; | 2750 delete this; |
| 2750 } | 2751 } |
| 2752 | |
| 2753 ProcessInfoObserver::ProcessInfoObserver( | |
| 2754 AutomationProvider* automation, | |
| 2755 IPC::Message* reply_message) | |
| 2756 : automation_(automation->AsWeakPtr()), | |
| 2757 reply_message_(reply_message) {} | |
| 2758 | |
| 2759 void ProcessInfoObserver::OnDetailsAvailable() { | |
| 2760 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | |
| 2761 ListValue* browser_proc_list = new ListValue(); | |
| 2762 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
| |
| 2763 for (size_t index = 0; index < browser_processes.size(); ++index) { | |
| 2764 DictionaryValue* browser_data = new DictionaryValue(); | |
| 2765 browser_data->SetString("name", browser_processes[index].name); | |
| 2766 browser_data->SetString("process_name", | |
| 2767 browser_processes[index].process_name); | |
| 2768 | |
| 2769 ListValue* proc_list = new ListValue(); | |
| 2770 for (ProcessMemoryInformationList::const_iterator iterator = | |
| 2771 browser_processes[index].processes.begin(); | |
| 2772 iterator != browser_processes[index].processes.end(); ++iterator) { | |
| 2773 DictionaryValue* proc_data = new DictionaryValue(); | |
| 2774 | |
| 2775 proc_data->SetInteger("pid", iterator->pid); | |
| 2776 | |
| 2777 // Working set (resident) memory usage, in KBytes. | |
| 2778 DictionaryValue* working_set = new DictionaryValue(); | |
| 2779 working_set->SetInteger("priv", iterator->working_set.priv); | |
| 2780 working_set->SetInteger("shareable", iterator->working_set.shareable); | |
| 2781 working_set->SetInteger("shared", iterator->working_set.shared); | |
| 2782 proc_data->Set("working_set_mem", working_set); | |
| 2783 | |
| 2784 // Committed (resident + paged) memory usage, in KBytes. | |
| 2785 DictionaryValue* committed = new DictionaryValue(); | |
| 2786 committed->SetInteger("priv", iterator->committed.priv); | |
| 2787 committed->SetInteger("mapped", iterator->committed.mapped); | |
| 2788 committed->SetInteger("image", iterator->committed.image); | |
| 2789 proc_data->Set("committed_mem", committed); | |
| 2790 | |
| 2791 proc_data->SetString("version", iterator->version); | |
| 2792 proc_data->SetString("product_name", iterator->product_name); | |
| 2793 proc_data->SetInteger("num_processes", iterator->num_processes); | |
| 2794 proc_data->SetBoolean("is_diagnostics", iterator->is_diagnostics); | |
| 2795 | |
| 2796 // Process type, if this is a child process of Chrome (e.g., 'plugin'). | |
| 2797 std::string process_type = "Unknown"; | |
| 2798 // The following condition avoids a DCHECK in debug builds when the | |
| 2799 // process type passed to |GetTypeNameInEnglish| is unknown. | |
| 2800 if (iterator->type != ChildProcessInfo::UNKNOWN_PROCESS) | |
| 2801 process_type = ChildProcessInfo::GetTypeNameInEnglish(iterator->type); | |
| 2802 proc_data->SetString("child_process_type", process_type); | |
| 2803 | |
| 2804 // Renderer type, if this is a renderer process. | |
| 2805 std::string renderer_type = "Unknown"; | |
| 2806 // 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.
| |
| 2807 // renderer type passed to |GetRendererTypeNameInEnglish| is unknown. | |
| 2808 if (iterator->renderer_type != ChildProcessInfo::RENDERER_UNKNOWN) { | |
| 2809 renderer_type = ChildProcessInfo::GetRendererTypeNameInEnglish( | |
| 2810 iterator->renderer_type); | |
| 2811 } | |
| 2812 proc_data->SetString("renderer_type", renderer_type); | |
| 2813 | |
| 2814 // Titles associated with this process. | |
| 2815 ListValue* titles = new ListValue(); | |
| 2816 for (size_t title_index = 0; title_index < iterator->titles.size(); | |
| 2817 ++title_index) | |
| 2818 titles->Append(Value::CreateStringValue(iterator->titles[title_index])); | |
| 2819 proc_data->Set("titles", titles); | |
| 2820 | |
| 2821 proc_list->Append(proc_data); | |
| 2822 } | |
| 2823 browser_data->Set("processes", proc_list); | |
| 2824 | |
| 2825 browser_proc_list->Append(browser_data); | |
| 2826 } | |
| 2827 return_value->Set("browsers", browser_proc_list); | |
| 2828 | |
| 2829 if (automation_) { | |
| 2830 AutomationJSONReply(automation_, reply_message_.release()) | |
| 2831 .SendSuccess(return_value.get()); | |
| 2832 } | |
| 2833 } | |
| OLD | NEW |