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/ui/webui/about_ui.h" | 5 #include "chrome/browser/ui/webui/about_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
858 child_label.append(" (diagnostics)"); | 858 child_label.append(" (diagnostics)"); |
859 child->SetString("child_name", child_label); | 859 child->SetString("child_name", child_label); |
860 ListValue* titles = new ListValue(); | 860 ListValue* titles = new ListValue(); |
861 child->Set("titles", titles); | 861 child->Set("titles", titles); |
862 for (size_t i = 0; i < info->titles.size(); ++i) | 862 for (size_t i = 0; i < info->titles.size(); ++i) |
863 titles->Append(new StringValue(info->titles[i])); | 863 titles->Append(new StringValue(info->titles[i])); |
864 } | 864 } |
865 | 865 |
866 void AboutMemoryHandler::OnDetailsAvailable() { | 866 void AboutMemoryHandler::OnDetailsAvailable() { |
867 // the root of the JSON hierarchy for about:memory jstemplate | 867 // the root of the JSON hierarchy for about:memory jstemplate |
868 DictionaryValue root; | 868 scoped_ptr<DictionaryValue> root(new DictionaryValue); |
869 ListValue* browsers = new ListValue(); | 869 ListValue* browsers = new ListValue(); |
870 root.Set("browsers", browsers); | 870 root->Set("browsers", browsers); |
871 | 871 |
872 const std::vector<ProcessData>& browser_processes = processes(); | 872 const std::vector<ProcessData>& browser_processes = processes(); |
873 | 873 |
874 // Aggregate per-process data into browser summary data. | 874 // Aggregate per-process data into browser summary data. |
875 string16 log_string; | 875 string16 log_string; |
876 for (size_t index = 0; index < browser_processes.size(); index++) { | 876 for (size_t index = 0; index < browser_processes.size(); index++) { |
877 if (browser_processes[index].processes.empty()) | 877 if (browser_processes[index].processes.empty()) |
878 continue; | 878 continue; |
879 | 879 |
880 // Sum the information for the processes within this browser. | 880 // Sum the information for the processes within this browser. |
(...skipping 29 matching lines...) Expand all Loading... | |
910 ASCIIToUTF16(", ") + | 910 ASCIIToUTF16(", ") + |
911 base::Int64ToString16(aggregate.working_set.shared) + | 911 base::Int64ToString16(aggregate.working_set.shared) + |
912 ASCIIToUTF16(", ") + | 912 ASCIIToUTF16(", ") + |
913 base::Int64ToString16(aggregate.working_set.shareable); | 913 base::Int64ToString16(aggregate.working_set.shareable); |
914 } | 914 } |
915 if (!log_string.empty()) | 915 if (!log_string.empty()) |
916 VLOG(1) << "memory: " << log_string; | 916 VLOG(1) << "memory: " << log_string; |
917 | 917 |
918 // Set the browser & renderer detailed process data. | 918 // Set the browser & renderer detailed process data. |
919 DictionaryValue* browser_data = new DictionaryValue(); | 919 DictionaryValue* browser_data = new DictionaryValue(); |
920 root.Set("browzr_data", browser_data); | 920 root->Set("browzr_data", browser_data); |
921 ListValue* child_data = new ListValue(); | 921 ListValue* child_data = new ListValue(); |
922 root.Set("child_data", child_data); | 922 root->Set("child_data", child_data); |
923 | 923 |
924 ProcessData process = browser_processes[0]; // Chrome is the first browser. | 924 ProcessData process = browser_processes[0]; // Chrome is the first browser. |
925 root.SetString("current_browser_name", process.name); | 925 root->SetString("current_browser_name", process.name); |
926 | 926 |
927 for (size_t index = 0; index < process.processes.size(); index++) { | 927 for (size_t index = 0; index < process.processes.size(); index++) { |
928 if (process.processes[index].type == content::PROCESS_TYPE_BROWSER) | 928 if (process.processes[index].type == content::PROCESS_TYPE_BROWSER) |
929 BindProcessMetrics(browser_data, &process.processes[index]); | 929 BindProcessMetrics(browser_data, &process.processes[index]); |
930 else | 930 else |
931 AppendProcess(child_data, &process.processes[index]); | 931 AppendProcess(child_data, &process.processes[index]); |
932 } | 932 } |
933 | 933 |
934 root.SetBoolean("show_other_browsers", | 934 root->SetBoolean("show_other_browsers", |
935 browser_defaults::kShowOtherBrowsersInAboutMemory); | 935 browser_defaults::kShowOtherBrowsersInAboutMemory); |
936 root.SetString("summary_desc", | |
937 l10n_util::GetStringUTF16(IDS_MEMORY_USAGE_SUMMARY_DESC)); | |
938 | 936 |
939 ChromeWebUIDataSource::SetFontAndTextDirection(&root); | 937 DictionaryValue load_time_data; |
938 load_time_data.SetString( | |
939 "summary_desc", | |
940 l10n_util::GetStringUTF16(IDS_MEMORY_USAGE_SUMMARY_DESC)); | |
941 ChromeWebUIDataSource::SetFontAndTextDirection(&load_time_data); | |
942 load_time_data.Set("jstemplateData", root.release()); | |
940 | 943 |
944 jstemplate_builder::UseVersion2 version2; | |
Dan Beam
2013/01/03 04:55:23
what else in this file makes you used a scoped Use
Evan Stade
2013/01/03 05:31:23
nothing, that's why it's local here
| |
941 std::string data; | 945 std::string data; |
942 jstemplate_builder::AppendJsonJS(&root, &data); | 946 jstemplate_builder::AppendJsonJS(&load_time_data, &data); |
943 source_->FinishDataRequest(data, request_id_); | 947 source_->FinishDataRequest(data, request_id_); |
944 } | 948 } |
945 | 949 |
946 } // namespace | 950 } // namespace |
947 | 951 |
948 // AboutUIHTMLSource ---------------------------------------------------------- | 952 // AboutUIHTMLSource ---------------------------------------------------------- |
949 | 953 |
950 AboutUIHTMLSource::AboutUIHTMLSource(const std::string& source_name, | 954 AboutUIHTMLSource::AboutUIHTMLSource(const std::string& source_name, |
951 Profile* profile) | 955 Profile* profile) |
952 : DataSource(source_name, MessageLoop::current()), | 956 : DataSource(source_name, MessageLoop::current()), |
953 profile_(profile) { | 957 profile_(profile) {} |
954 } | |
955 | 958 |
956 AboutUIHTMLSource::~AboutUIHTMLSource() { | 959 AboutUIHTMLSource::~AboutUIHTMLSource() {} |
957 } | |
958 | 960 |
959 void AboutUIHTMLSource::StartDataRequest(const std::string& path, | 961 void AboutUIHTMLSource::StartDataRequest(const std::string& path, |
960 bool is_incognito, | 962 bool is_incognito, |
961 int request_id) { | 963 int request_id) { |
962 std::string response; | 964 std::string response; |
963 std::string host = source_name(); | 965 std::string host = source_name(); |
964 // Add your data source here, in alphabetical order. | 966 // Add your data source here, in alphabetical order. |
965 if (host == chrome::kChromeUIChromeURLsHost) { | 967 if (host == chrome::kChromeUIChromeURLsHost) { |
966 response = ChromeURLs(); | 968 response = ChromeURLs(); |
967 } else if (host == chrome::kChromeUICreditsHost) { | 969 } else if (host == chrome::kChromeUICreditsHost) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1038 ThemeSource* theme = new ThemeSource(profile); | 1040 ThemeSource* theme = new ThemeSource(profile); |
1039 ChromeURLDataManager::AddDataSource(profile, theme); | 1041 ChromeURLDataManager::AddDataSource(profile, theme); |
1040 #endif | 1042 #endif |
1041 | 1043 |
1042 ChromeURLDataManager::DataSource* source = | 1044 ChromeURLDataManager::DataSource* source = |
1043 new AboutUIHTMLSource(name, profile); | 1045 new AboutUIHTMLSource(name, profile); |
1044 if (source) { | 1046 if (source) { |
1045 ChromeURLDataManager::AddDataSource(profile, source); | 1047 ChromeURLDataManager::AddDataSource(profile, source); |
1046 } | 1048 } |
1047 } | 1049 } |
OLD | NEW |