| 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/browser_about_handler.h" | 5 #include "chrome/browser/browser_about_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 829 | 829 |
| 830 // Bind metrics to dictionary. | 830 // Bind metrics to dictionary. |
| 831 data->SetInteger("ws_priv", static_cast<int>(info->working_set.priv)); | 831 data->SetInteger("ws_priv", static_cast<int>(info->working_set.priv)); |
| 832 data->SetInteger("ws_shareable", | 832 data->SetInteger("ws_shareable", |
| 833 static_cast<int>(info->working_set.shareable)); | 833 static_cast<int>(info->working_set.shareable)); |
| 834 data->SetInteger("ws_shared", static_cast<int>(info->working_set.shared)); | 834 data->SetInteger("ws_shared", static_cast<int>(info->working_set.shared)); |
| 835 data->SetInteger("comm_priv", static_cast<int>(info->committed.priv)); | 835 data->SetInteger("comm_priv", static_cast<int>(info->committed.priv)); |
| 836 data->SetInteger("comm_map", static_cast<int>(info->committed.mapped)); | 836 data->SetInteger("comm_map", static_cast<int>(info->committed.mapped)); |
| 837 data->SetInteger("comm_image", static_cast<int>(info->committed.image)); | 837 data->SetInteger("comm_image", static_cast<int>(info->committed.image)); |
| 838 data->SetInteger("pid", info->pid); | 838 data->SetInteger("pid", info->pid); |
| 839 data->SetString("version", WideToUTF16Hack(info->version)); | 839 data->SetString("version", info->version); |
| 840 data->SetInteger("processes", info->num_processes); | 840 data->SetInteger("processes", info->num_processes); |
| 841 } | 841 } |
| 842 | 842 |
| 843 // Helper for AboutMemory to append memory usage information for all | 843 // Helper for AboutMemory to append memory usage information for all |
| 844 // sub-processes (i.e. renderers, plugins) used by Chrome. | 844 // sub-processes (i.e. renderers, plugins) used by Chrome. |
| 845 void AboutMemoryHandler::AppendProcess(ListValue* child_data, | 845 void AboutMemoryHandler::AppendProcess(ListValue* child_data, |
| 846 ProcessMemoryInformation* info) { | 846 ProcessMemoryInformation* info) { |
| 847 DCHECK(child_data && info); | 847 DCHECK(child_data && info); |
| 848 | 848 |
| 849 // Append a new DictionaryValue for this renderer to our list. | 849 // Append a new DictionaryValue for this renderer to our list. |
| 850 DictionaryValue* child = new DictionaryValue(); | 850 DictionaryValue* child = new DictionaryValue(); |
| 851 child_data->Append(child); | 851 child_data->Append(child); |
| 852 BindProcessMetrics(child, info); | 852 BindProcessMetrics(child, info); |
| 853 | 853 |
| 854 std::string child_label(ChildProcessInfo::GetTypeNameInEnglish(info->type)); | 854 std::string child_label(ChildProcessInfo::GetTypeNameInEnglish(info->type)); |
| 855 if (info->is_diagnostics) | 855 if (info->is_diagnostics) |
| 856 child_label.append(" (diagnostics)"); | 856 child_label.append(" (diagnostics)"); |
| 857 child->SetString("child_name", child_label); | 857 child->SetString("child_name", child_label); |
| 858 ListValue* titles = new ListValue(); | 858 ListValue* titles = new ListValue(); |
| 859 child->Set("titles", titles); | 859 child->Set("titles", titles); |
| 860 for (size_t i = 0; i < info->titles.size(); ++i) | 860 for (size_t i = 0; i < info->titles.size(); ++i) |
| 861 titles->Append(new StringValue(WideToUTF16Hack(info->titles[i]))); | 861 titles->Append(new StringValue(info->titles[i])); |
| 862 } | 862 } |
| 863 | 863 |
| 864 | 864 |
| 865 void AboutMemoryHandler::OnDetailsAvailable() { | 865 void AboutMemoryHandler::OnDetailsAvailable() { |
| 866 // the root of the JSON hierarchy for about:memory jstemplate | 866 // the root of the JSON hierarchy for about:memory jstemplate |
| 867 DictionaryValue root; | 867 DictionaryValue root; |
| 868 ListValue* browsers = new ListValue(); | 868 ListValue* browsers = new ListValue(); |
| 869 root.Set("browsers", browsers); | 869 root.Set("browsers", browsers); |
| 870 | 870 |
| 871 const std::vector<ProcessData>& browser_processes = processes(); | 871 const std::vector<ProcessData>& browser_processes = processes(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 890 aggregate.working_set.shareable += iterator->working_set.shareable; | 890 aggregate.working_set.shareable += iterator->working_set.shareable; |
| 891 aggregate.committed.priv += iterator->committed.priv; | 891 aggregate.committed.priv += iterator->committed.priv; |
| 892 aggregate.committed.mapped += iterator->committed.mapped; | 892 aggregate.committed.mapped += iterator->committed.mapped; |
| 893 aggregate.committed.image += iterator->committed.image; | 893 aggregate.committed.image += iterator->committed.image; |
| 894 aggregate.num_processes++; | 894 aggregate.num_processes++; |
| 895 } | 895 } |
| 896 ++iterator; | 896 ++iterator; |
| 897 } | 897 } |
| 898 DictionaryValue* browser_data = new DictionaryValue(); | 898 DictionaryValue* browser_data = new DictionaryValue(); |
| 899 browsers->Append(browser_data); | 899 browsers->Append(browser_data); |
| 900 browser_data->SetString("name", | 900 browser_data->SetString("name", browser_processes[index].name); |
| 901 WideToUTF16Hack(browser_processes[index].name)); | |
| 902 | 901 |
| 903 BindProcessMetrics(browser_data, &aggregate); | 902 BindProcessMetrics(browser_data, &aggregate); |
| 904 | 903 |
| 905 // We log memory info as we record it. | 904 // We log memory info as we record it. |
| 906 if (log_string.length() > 0) | 905 if (log_string.length() > 0) |
| 907 log_string.append(L", "); | 906 log_string.append(L", "); |
| 908 log_string.append(browser_processes[index].name); | 907 log_string.append(UTF16ToWide(browser_processes[index].name)); |
| 909 log_string.append(L", "); | 908 log_string.append(L", "); |
| 910 log_string.append(UTF8ToWide( | 909 log_string.append(UTF8ToWide( |
| 911 base::Int64ToString(aggregate.working_set.priv))); | 910 base::Int64ToString(aggregate.working_set.priv))); |
| 912 log_string.append(L", "); | 911 log_string.append(L", "); |
| 913 log_string.append(UTF8ToWide( | 912 log_string.append(UTF8ToWide( |
| 914 base::Int64ToString(aggregate.working_set.shared))); | 913 base::Int64ToString(aggregate.working_set.shared))); |
| 915 log_string.append(L", "); | 914 log_string.append(L", "); |
| 916 log_string.append(UTF8ToWide( | 915 log_string.append(UTF8ToWide( |
| 917 base::Int64ToString(aggregate.working_set.shareable))); | 916 base::Int64ToString(aggregate.working_set.shareable))); |
| 918 } | 917 } |
| 919 if (log_string.length() > 0) | 918 if (log_string.length() > 0) |
| 920 VLOG(1) << "memory: " << log_string; | 919 VLOG(1) << "memory: " << log_string; |
| 921 | 920 |
| 922 // Set the browser & renderer detailed process data. | 921 // Set the browser & renderer detailed process data. |
| 923 DictionaryValue* browser_data = new DictionaryValue(); | 922 DictionaryValue* browser_data = new DictionaryValue(); |
| 924 root.Set("browzr_data", browser_data); | 923 root.Set("browzr_data", browser_data); |
| 925 ListValue* child_data = new ListValue(); | 924 ListValue* child_data = new ListValue(); |
| 926 root.Set("child_data", child_data); | 925 root.Set("child_data", child_data); |
| 927 | 926 |
| 928 ProcessData process = browser_processes[0]; // Chrome is the first browser. | 927 ProcessData process = browser_processes[0]; // Chrome is the first browser. |
| 929 root.SetString("current_browser_name", WideToUTF16Hack(process.name)); | 928 root.SetString("current_browser_name", process.name); |
| 930 | 929 |
| 931 for (size_t index = 0; index < process.processes.size(); index++) { | 930 for (size_t index = 0; index < process.processes.size(); index++) { |
| 932 if (process.processes[index].type == ChildProcessInfo::BROWSER_PROCESS) | 931 if (process.processes[index].type == ChildProcessInfo::BROWSER_PROCESS) |
| 933 BindProcessMetrics(browser_data, &process.processes[index]); | 932 BindProcessMetrics(browser_data, &process.processes[index]); |
| 934 else | 933 else |
| 935 AppendProcess(child_data, &process.processes[index]); | 934 AppendProcess(child_data, &process.processes[index]); |
| 936 } | 935 } |
| 937 | 936 |
| 938 root.SetBoolean("show_other_browsers", | 937 root.SetBoolean("show_other_browsers", |
| 939 browser_defaults::kShowOtherBrowsersInAboutMemory); | 938 browser_defaults::kShowOtherBrowsersInAboutMemory); |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 // Run the dialog. This will re-use the existing one if it's already up. | 1114 // Run the dialog. This will re-use the existing one if it's already up. |
| 1116 AboutIPCDialog::RunDialog(); | 1115 AboutIPCDialog::RunDialog(); |
| 1117 return true; | 1116 return true; |
| 1118 } | 1117 } |
| 1119 #endif | 1118 #endif |
| 1120 | 1119 |
| 1121 #endif // OFFICIAL_BUILD | 1120 #endif // OFFICIAL_BUILD |
| 1122 | 1121 |
| 1123 return false; | 1122 return false; |
| 1124 } | 1123 } |
| OLD | NEW |