Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Unified Diff: chrome/browser/chromeos/status/memory_menu_button.cc

Issue 7607009: Revert 96054 - Enable tcmalloc profiling and heap dump. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/status/memory_menu_button.cc
===================================================================
--- chrome/browser/chromeos/status/memory_menu_button.cc (revision 96064)
+++ chrome/browser/chromeos/status/memory_menu_button.cc (working copy)
@@ -4,25 +4,14 @@
#include "chrome/browser/chromeos/status/memory_menu_button.h"
-#include "base/file_util.h"
#include "base/process_util.h" // GetSystemMemoryInfo
#include "base/stringprintf.h"
#include "chrome/browser/chromeos/status/status_area_host.h"
#include "chrome/browser/memory_purger.h"
-#include "chrome/common/render_messages.h"
-#include "content/browser/renderer_host/render_process_host.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
#include "views/widget/widget.h"
-#if defined(USE_TCMALLOC)
-#include "third_party/tcmalloc/chromium/src/google/heap-profiler.h"
-#endif
-
-#if defined(USE_TCMALLOC)
-const char kProfileDumpFilePrefix[] = "/tmp/chrome_tcmalloc";
-#endif
-
namespace {
// views::MenuItemView item ids
@@ -33,10 +22,6 @@
MEM_CACHE_ITEM,
SHMEM_ITEM,
PURGE_MEMORY_ITEM,
-#if defined(USE_TCMALLOC)
- TOGGLE_PROFILING_ITEM,
- DUMP_PROFILING_ITEM,
-#endif
};
} // namespace
@@ -97,15 +82,6 @@
return StringPrintf(L"%d MB shmem", shmem_ / 1024);
case PURGE_MEMORY_ITEM:
return L"Purge memory";
-#if defined(USE_TCMALLOC)
- case TOGGLE_PROFILING_ITEM:
- if (!IsHeapProfilerRunning())
- return L"Start profiling";
- else
- return L"Stop profiling";
- case DUMP_PROFILING_ITEM:
- return L"Dump profile";
-#endif
default:
return std::wstring();
}
@@ -115,76 +91,16 @@
switch (id) {
case PURGE_MEMORY_ITEM:
return true;
-#if defined(USE_TCMALLOC)
- case TOGGLE_PROFILING_ITEM:
- case DUMP_PROFILING_ITEM:
- return true;
-#endif
default:
return false;
}
}
-namespace {
-FilePath::StringType GetFilePath(base::ProcessId pid) {
- int int_pid = static_cast<int>(pid);
- FilePath::StringType filepath = StringPrintf(
- FILE_PATH_LITERAL("%s.%d.heap"),
- FILE_PATH_LITERAL(kProfileDumpFilePrefix), int_pid);
- return filepath;
-}
-}
-
-void MemoryMenuButton::SendCommandToRenderers(int id) {
-#if defined(USE_TCMALLOC)
- // Use the "is running" value for this process to determine whether to
- // start or stop profiling on the renderer processes.
- bool started = IsHeapProfilerRunning();
- for (RenderProcessHost::iterator it = RenderProcessHost::AllHostsIterator();
- !it.IsAtEnd(); it.Advance()) {
- switch (id) {
- case TOGGLE_PROFILING_ITEM:
- it.GetCurrentValue()->Send(new ViewMsg_SetTcmallocHeapProfiling(
- started, std::string(kProfileDumpFilePrefix)));
- break;
- case DUMP_PROFILING_ITEM:
- it.GetCurrentValue()->Send(new ViewMsg_WriteTcmallocHeapProfile(
- GetFilePath(base::GetProcId(it.GetCurrentValue()->GetHandle()))));
- break;
- default:
- NOTREACHED();
- }
- }
-#endif
-}
-
void MemoryMenuButton::ExecuteCommand(int id) {
switch (id) {
case PURGE_MEMORY_ITEM:
MemoryPurger::PurgeAll();
break;
-#if defined(USE_TCMALLOC)
- case TOGGLE_PROFILING_ITEM: {
- if (!IsHeapProfilerRunning())
- HeapProfilerStart(kProfileDumpFilePrefix);
- else
- HeapProfilerStop();
- SendCommandToRenderers(id);
- break;
- }
- case DUMP_PROFILING_ITEM: {
- char* profile = GetHeapProfile();
- if (profile) {
- FilePath::StringType filepath =
- GetFilePath(base::GetProcId(base::GetCurrentProcId()));
- VLOG(0) << "Writing browser heap profile dump to: " << filepath;
- file_util::WriteFile(FilePath(filepath), profile, strlen(profile));
- delete profile;
- }
- SendCommandToRenderers(id);
- break;
- }
-#endif
default:
NOTREACHED();
break;
@@ -225,14 +141,9 @@
menu_->AppendDelegateMenuItem(MEM_BUFFERS_ITEM);
menu_->AppendDelegateMenuItem(MEM_CACHE_ITEM);
menu_->AppendDelegateMenuItem(SHMEM_ITEM);
+ // TODO(jamescook): Dump heap profiles?
menu_->AppendSeparator();
menu_->AppendDelegateMenuItem(PURGE_MEMORY_ITEM);
-#if defined(USE_TCMALLOC)
- menu_->AppendSeparator();
- menu_->AppendDelegateMenuItem(TOGGLE_PROFILING_ITEM);
- if (IsHeapProfilerRunning())
- menu_->AppendDelegateMenuItem(DUMP_PROFILING_ITEM);
-#endif
}
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/status/memory_menu_button.h ('k') | chrome/browser/renderer_host/chrome_render_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698