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