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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #include "content/public/browser/zygote_host_linux.h" | 84 #include "content/public/browser/zygote_host_linux.h" |
85 #elif defined(OS_LINUX) || defined(OS_OPENBSD) | 85 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
86 #include "content/public/browser/zygote_host_linux.h" | 86 #include "content/public/browser/zygote_host_linux.h" |
87 #endif | 87 #endif |
88 | 88 |
89 #if defined(USE_ASH) | 89 #if defined(USE_ASH) |
90 #include "ash/wm/frame_painter.h" | 90 #include "ash/wm/frame_painter.h" |
91 #include "base/string_split.h" | 91 #include "base/string_split.h" |
92 #endif | 92 #endif |
93 | 93 |
94 #if defined(USE_TCMALLOC) | |
95 #include "third_party/tcmalloc/chromium/src/gperftools/malloc_extension.h" | |
96 #endif | |
97 | |
98 using base::Time; | 94 using base::Time; |
99 using base::TimeDelta; | 95 using base::TimeDelta; |
100 using content::BrowserThread; | 96 using content::BrowserThread; |
101 using content::PluginService; | 97 using content::PluginService; |
102 using content::WebContents; | 98 using content::WebContents; |
103 | 99 |
104 namespace { | 100 namespace { |
105 | 101 |
106 const char kCreditsJsPath[] = "credits.js"; | 102 const char kCreditsJsPath[] = "credits.js"; |
107 const char kMemoryJsPath[] = "memory.js"; | 103 const char kMemoryJsPath[] = "memory.js"; |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 | 776 |
781 // Where the results are fed to. | 777 // Where the results are fed to. |
782 scoped_refptr<AboutUIHTMLSource> source_; | 778 scoped_refptr<AboutUIHTMLSource> source_; |
783 | 779 |
784 // ID identifying the request. | 780 // ID identifying the request. |
785 int request_id_; | 781 int request_id_; |
786 | 782 |
787 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); | 783 DISALLOW_COPY_AND_ASSIGN(AboutDnsHandler); |
788 }; | 784 }; |
789 | 785 |
790 #if defined(USE_TCMALLOC) | |
791 std::string AboutTcmalloc() { | |
792 std::string data; | |
793 AboutTcmallocOutputsType* outputs = | |
794 AboutTcmallocOutputs::GetInstance()->outputs(); | |
795 | |
796 // Display any stats for which we sent off requests the last time. | |
797 AppendHeader(&data, 0, "About tcmalloc"); | |
798 AppendBody(&data); | |
799 data.append("<p>Stats as of last page load;"); | |
800 data.append("reload to get stats as of this page load.</p>\n"); | |
801 data.append("<table width=\"100%\">\n"); | |
802 for (AboutTcmallocOutputsType::const_iterator oit = outputs->begin(); | |
803 oit != outputs->end(); | |
804 oit++) { | |
805 data.append("<tr><td bgcolor=\"yellow\">"); | |
806 data.append(oit->first); | |
807 data.append("</td></tr>\n"); | |
808 data.append("<tr><td><pre>\n"); | |
809 data.append(oit->second); | |
810 data.append("</pre></td></tr>\n"); | |
811 } | |
812 data.append("</table>\n"); | |
813 AppendFooter(&data); | |
814 | |
815 // Reset our collector singleton. | |
816 outputs->clear(); | |
817 | |
818 // Populate the collector with stats from the local browser process | |
819 // and send off requests to all the renderer processes. | |
820 char buffer[1024 * 32]; | |
821 MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); | |
822 std::string browser("Browser"); | |
823 AboutTcmallocOutputs::GetInstance()->SetOutput(browser, buffer); | |
824 content::RenderProcessHost::iterator | |
825 it(content::RenderProcessHost::AllHostsIterator()); | |
826 while (!it.IsAtEnd()) { | |
827 it.GetCurrentValue()->Send(new ChromeViewMsg_GetRendererTcmalloc); | |
828 it.Advance(); | |
829 } | |
830 | |
831 return data; | |
832 } | |
833 #endif | |
834 | |
835 std::string AboutHistograms(const std::string& query) { | 786 std::string AboutHistograms(const std::string& query) { |
836 TimeDelta wait_time = TimeDelta::FromMilliseconds(10000); | 787 TimeDelta wait_time = TimeDelta::FromMilliseconds(10000); |
837 | 788 |
838 #ifndef NDEBUG | 789 #ifndef NDEBUG |
839 base::StatisticsRecorder::CollectHistogramStats("Browser"); | 790 base::StatisticsRecorder::CollectHistogramStats("Browser"); |
840 #endif | 791 #endif |
841 | 792 |
842 HistogramSynchronizer* current_synchronizer = | 793 HistogramSynchronizer* current_synchronizer = |
843 HistogramSynchronizer::CurrentSynchronizer(); | 794 HistogramSynchronizer::CurrentSynchronizer(); |
844 DCHECK(current_synchronizer != NULL); | 795 DCHECK(current_synchronizer != NULL); |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 } else if (host == chrome::kChromeUIOSCreditsHost) { | 1405 } else if (host == chrome::kChromeUIOSCreditsHost) { |
1455 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1406 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
1456 IDR_OS_CREDITS_HTML).as_string(); | 1407 IDR_OS_CREDITS_HTML).as_string(); |
1457 #endif | 1408 #endif |
1458 #if defined(OS_LINUX) || defined(OS_OPENBSD) | 1409 #if defined(OS_LINUX) || defined(OS_OPENBSD) |
1459 } else if (host == chrome::kChromeUISandboxHost) { | 1410 } else if (host == chrome::kChromeUISandboxHost) { |
1460 response = AboutSandbox(); | 1411 response = AboutSandbox(); |
1461 #endif | 1412 #endif |
1462 } else if (host == chrome::kChromeUIStatsHost) { | 1413 } else if (host == chrome::kChromeUIStatsHost) { |
1463 response = AboutStats(path); | 1414 response = AboutStats(path); |
1464 #if defined(USE_TCMALLOC) | |
1465 } else if (host == chrome::kChromeUITCMallocHost) { | |
1466 response = AboutTcmalloc(); | |
1467 #endif | |
1468 } else if (host == chrome::kChromeUITermsHost) { | 1415 } else if (host == chrome::kChromeUITermsHost) { |
1469 #if defined(OS_CHROMEOS) | 1416 #if defined(OS_CHROMEOS) |
1470 ChromeOSTermsHandler::Start(this, path, request_id); | 1417 ChromeOSTermsHandler::Start(this, path, request_id); |
1471 return; | 1418 return; |
1472 #else | 1419 #else |
1473 response = ResourceBundle::GetSharedInstance().GetRawDataResource( | 1420 response = ResourceBundle::GetSharedInstance().GetRawDataResource( |
1474 IDR_TERMS_HTML).as_string(); | 1421 IDR_TERMS_HTML).as_string(); |
1475 #endif | 1422 #endif |
1476 } else if (host == chrome::kChromeUIVersionHost) { | 1423 } else if (host == chrome::kChromeUIVersionHost) { |
1477 if (path == kStringsJsPath) { | 1424 if (path == kStringsJsPath) { |
(...skipping 29 matching lines...) Expand all Loading... |
1507 } | 1454 } |
1508 | 1455 |
1509 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) | 1456 AboutUI::AboutUI(content::WebUI* web_ui, const std::string& name) |
1510 : WebUIController(web_ui) { | 1457 : WebUIController(web_ui) { |
1511 Profile* profile = Profile::FromWebUI(web_ui); | 1458 Profile* profile = Profile::FromWebUI(web_ui); |
1512 ChromeURLDataManager::DataSource* source = | 1459 ChromeURLDataManager::DataSource* source = |
1513 new AboutUIHTMLSource(name, profile); | 1460 new AboutUIHTMLSource(name, profile); |
1514 if (source) | 1461 if (source) |
1515 profile->GetChromeURLDataManager()->AddDataSource(source); | 1462 profile->GetChromeURLDataManager()->AddDataSource(source); |
1516 } | 1463 } |
OLD | NEW |