Skip to content

Commit

Permalink
Add a simple about:tcmalloc page that just displays its canned stats.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sgk@chromium.org committed Sep 22, 2009
1 parent 60a3df5 commit 833b88a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
5 changes: 5 additions & 0 deletions build/build_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@
#define USE_X11 1
#endif

// Use tcmalloc
#if defined(OS_WIN) && ! defined(NO_TCMALLOC)
#define USE_TCMALLOC 1
#endif

// Compiler detection.
#if defined(__GNUC__)
#define COMPILER_GCC 1
Expand Down
3 changes: 3 additions & 0 deletions chrome/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ include_rules = [
# Allow inclusion of Mozilla interface headers.
"+third_party/mozilla",

# Allow inclusion of tcmalloc header.
"+third_party/tcmalloc",

# Allow usage of Google Toolbox for Mac.
"+third_party/GTM",

Expand Down
21 changes: 21 additions & 0 deletions chrome/browser/browser_about_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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";
Expand Down Expand Up @@ -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("<html><head><title>About tcmalloc</title></head><body><pre>\n");
data.append(buffer);
data.append("</pre></body></html>\n");
return data;
}
#endif

std::string AboutHistograms(const std::string& query) {
TimeDelta wait_time = TimeDelta::FromMilliseconds(10000);

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions chrome/chrome.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -2404,11 +2404,12 @@
'third_party/wtl/include',
],
'dependencies': [
'../gears/gears.gyp:gears',
'../google_update/google_update.gyp:google_update',
'installer/installer.gyp:installer_util',
'../third_party/cld/cld.gyp:cld',
'../third_party/tcmalloc/tcmalloc.gyp:tcmalloc',
'../views/views.gyp:views',
'../gears/gears.gyp:gears',
'installer/installer.gyp:installer_util',
],
'export_dependent_settings': [
'../views/views.gyp:views',
Expand Down

0 comments on commit 833b88a

Please sign in to comment.