Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(101)

Side by Side Diff: chrome/browser/automation/automation_provider_observers.cc

Issue 7976016: New pyauto automation hook to get browser process information. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed second round of review comments. Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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>& all_processes = processes();
2763 for (size_t index = 0; index < all_processes.size(); ++index) {
2764 DictionaryValue* browser_data = new DictionaryValue();
2765 browser_data->SetString("name", all_processes[index].name);
2766 browser_data->SetString("process_name", all_processes[index].process_name);
2767
2768 ListValue* proc_list = new ListValue();
2769 for (ProcessMemoryInformationList::const_iterator iterator =
2770 all_processes[index].processes.begin();
2771 iterator != all_processes[index].processes.end(); ++iterator) {
2772 DictionaryValue* proc_data = new DictionaryValue();
2773
2774 proc_data->SetInteger("pid", iterator->pid);
2775
2776 // Working set (resident) memory usage, in KBytes.
2777 DictionaryValue* working_set = new DictionaryValue();
2778 working_set->SetInteger("priv", iterator->working_set.priv);
2779 working_set->SetInteger("shareable", iterator->working_set.shareable);
2780 working_set->SetInteger("shared", iterator->working_set.shared);
2781 proc_data->Set("working_set_mem", working_set);
2782
2783 // Committed (resident + paged) memory usage, in KBytes.
2784 DictionaryValue* committed = new DictionaryValue();
2785 committed->SetInteger("priv", iterator->committed.priv);
2786 committed->SetInteger("mapped", iterator->committed.mapped);
2787 committed->SetInteger("image", iterator->committed.image);
2788 proc_data->Set("committed_mem", committed);
2789
2790 proc_data->SetString("version", iterator->version);
2791 proc_data->SetString("product_name", iterator->product_name);
2792 proc_data->SetInteger("num_processes", iterator->num_processes);
2793 proc_data->SetBoolean("is_diagnostics", iterator->is_diagnostics);
2794
2795 // Process type, if this is a child process of Chrome (e.g., 'plugin').
2796 std::string process_type = "Unknown";
2797 // The following condition avoids a DCHECK in debug builds when the
2798 // process type passed to |GetTypeNameInEnglish| is unknown.
2799 if (iterator->type != ChildProcessInfo::UNKNOWN_PROCESS)
2800 process_type = ChildProcessInfo::GetTypeNameInEnglish(iterator->type);
2801 proc_data->SetString("child_process_type", process_type);
2802
2803 // Renderer type, if this is a renderer process.
2804 std::string renderer_type = "Unknown";
2805 if (iterator->renderer_type != ChildProcessInfo::RENDERER_UNKNOWN) {
2806 renderer_type = ChildProcessInfo::GetRendererTypeNameInEnglish(
2807 iterator->renderer_type);
2808 }
2809 proc_data->SetString("renderer_type", renderer_type);
2810
2811 // Titles associated with this process.
2812 ListValue* titles = new ListValue();
2813 for (size_t title_index = 0; title_index < iterator->titles.size();
2814 ++title_index)
2815 titles->Append(Value::CreateStringValue(iterator->titles[title_index]));
2816 proc_data->Set("titles", titles);
2817
2818 proc_list->Append(proc_data);
2819 }
2820 browser_data->Set("processes", proc_list);
2821
2822 browser_proc_list->Append(browser_data);
2823 }
2824 return_value->Set("browsers", browser_proc_list);
2825
2826 if (automation_) {
2827 AutomationJSONReply(automation_, reply_message_.release())
2828 .SendSuccess(return_value.get());
2829 }
2830 }
OLDNEW
« no previous file with comments | « chrome/browser/automation/automation_provider_observers.h ('k') | chrome/browser/automation/testing_automation_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698