| 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
|
|
|