From 833b88a7a71cff01f35cce5a86b38ff963ae16f2 Mon Sep 17 00:00:00 2001 From: "sgk@chromium.org" Date: Tue, 22 Sep 2009 16:16:39 +0000 Subject: Add a simple about:tcmalloc page that just displays its canned stats. Add USE_TCMALLOC to control its inclusion. Make browser depend on tcmalloc to get the PERFTOOLS_DLL_DECL definition. BUG=none TEST=none Review URL: http://codereview.chromium.org/216033 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26816 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/browser_about_handler.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'chrome/browser/browser_about_handler.cc') diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 9331606..9f17f77 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -52,6 +52,10 @@ #include "chrome/browser/chromeos/chromeos_version_loader.h" #endif +#if defined(USE_TCMALLOC) +#include "third_party/tcmalloc/google/malloc_extension.h" +#endif + #ifdef CHROME_PERSONALIZATION #include "chrome/browser/sync/auth_error_state.h" #include "chrome/browser/sync/profile_sync_service.h" @@ -70,6 +74,7 @@ const char kHistogramsPath[] = "histograms"; const char kObjectsPath[] = "objects"; const char kMemoryRedirectPath[] = "memory-redirect"; const char kMemoryPath[] = "memory"; +const char kTcmallocPath[] = "tcmalloc"; const char kPluginsPath[] = "plugins"; const char kStatsPath[] = "stats"; const char kVersionPath[] = "version"; @@ -181,6 +186,18 @@ std::string AboutDns() { return data; } +#if defined(USE_TCMALLOC) +std::string AboutTcmalloc(const std::string& query) { + std::string data; + char buffer[1024*32]; + MallocExtension::instance()->GetStats(buffer, sizeof(buffer)); + data.append("About tcmalloc
\n");
+  data.append(buffer);
+  data.append("
\n"); + return data; +} +#endif + std::string AboutHistograms(const std::string& query) { TimeDelta wait_time = TimeDelta::FromMilliseconds(10000); @@ -550,6 +567,10 @@ void AboutSource::StartDataRequest(const std::string& path_raw, response = AboutPlugins(); } else if (path == kStatsPath) { response = AboutStats(); +#if defined(USE_TCMALLOC) + } else if (path == kTcmallocPath) { + response = AboutTcmalloc(info); +#endif } else if (path == kVersionPath || path.empty()) { #if defined(OS_CHROMEOS) new ChromeOSAboutVersionHandler(this, request_id); -- cgit v1.1