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

Unified Diff: content/renderer/memory_benchmarking_extension.cc

Issue 15082004: Adds chrome.memoryBenchmarking.heapProfilerDump for the browser process. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Removes return value Created 7 years, 7 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: content/renderer/memory_benchmarking_extension.cc
diff --git a/content/renderer/memory_benchmarking_extension.cc b/content/renderer/memory_benchmarking_extension.cc
index 2dbfbda58c2923a096f5bf607516c61975fcd1f6..a1651c16854fadff8efcc9b3ac209ea454337dea 100644
--- a/content/renderer/memory_benchmarking_extension.cc
+++ b/content/renderer/memory_benchmarking_extension.cc
@@ -5,11 +5,11 @@
#include "content/renderer/memory_benchmarking_extension.h"
#include "base/string_util.h"
-#include "content/public/renderer/render_thread.h"
-
-#if !defined(NO_TCMALLOC) && defined(OS_LINUX)
+#include "content/common/memory_benchmark_messages.h"
+#include "content/renderer/render_thread_impl.h"
#include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
Dai Mikurube (NOT FULLTIME) 2013/05/15 10:24:04 This "heap-profiler.h" should be included only whe
bulach 2013/05/15 10:58:29 Done.
-#endif // !defined(NO_TCMALLOC) && defined(OS_LINUX)
+
+#if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID))
namespace {
@@ -33,9 +33,10 @@ class MemoryBenchmarkingWrapper : public v8::Extension {
" native function IsHeapProfilerRunning();"
" return IsHeapProfilerRunning();"
"};"
- "chrome.memoryBenchmarking.heapProfilerDump = function(reason) {"
+ "chrome.memoryBenchmarking.heapProfilerDump = "
+ " function(reason, process) {"
Dai Mikurube (NOT FULLTIME) 2013/05/15 10:24:04 I wonder if we could order it as (process_type, re
bulach 2013/05/15 10:58:29 sounds reasonable, done.
" native function HeapProfilerDump();"
- " return HeapProfilerDump(reason);"
+ " return HeapProfilerDump(reason, process);"
Dai Mikurube (NOT FULLTIME) 2013/05/15 10:36:55 Same argument order for this HeapProfilerDump(). A
bulach 2013/05/15 10:58:29 Done.
"};"
) {}
@@ -51,24 +52,27 @@ class MemoryBenchmarkingWrapper : public v8::Extension {
static v8::Handle<v8::Value> IsHeapProfilerRunning(
const v8::Arguments& args) {
-#if !defined(NO_TCMALLOC) && defined(OS_LINUX)
return v8::Boolean::New(::IsHeapProfilerRunning());
-#else
- return v8::Boolean::New(false);
-#endif // !defined(NO_TCMALLOC) && defined(OS_LINUX)
+ }
+
+ static void HeapProfilerDumpBrowser(const std::string& reason) {
+ content::RenderThreadImpl::current()->Send(
+ new MemoryBenchmarkHostMsg_HeapProfilerDump(reason));
}
static v8::Handle<v8::Value> HeapProfilerDump(const v8::Arguments& args) {
-#if !defined(NO_TCMALLOC) && defined(OS_LINUX)
- char dumped_filename_buffer[1000];
std::string reason("benchmarking_extension");
if (args.Length() && args[0]->IsString())
reason = *v8::String::AsciiValue(args[0]);
- ::HeapProfilerDumpWithFileName(reason.c_str(),
- dumped_filename_buffer,
- sizeof(dumped_filename_buffer));
- return v8::String::New(dumped_filename_buffer);
-#endif // !defined(NO_TCMALLOC) && defined(OS_LINUX)
+ std::string process;
+ if (args.Length() > 1 && args[1]->IsString())
+ process = *v8::String::AsciiValue(args[1]);
+ if (process == "browser") {
+ content::RenderThreadImpl::current()->Send(
+ new MemoryBenchmarkHostMsg_HeapProfilerDump(reason));
+ } else {
+ ::HeapProfilerDump(reason.c_str());
+ }
return v8::Undefined();
}
};
@@ -82,3 +86,5 @@ v8::Extension* MemoryBenchmarkingExtension::Get() {
}
} // namespace content
+
+#endif // defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID))
Dai Mikurube (NOT FULLTIME) 2013/05/15 10:24:04 I think these functions (at least chrome.memoryBen
bulach 2013/05/15 10:58:29 hmm.. see the comment from palmer, I suppose if we
Dai Mikurube (NOT FULLTIME) 2013/05/15 12:04:20 Hmm, makes sense. Ok. :)

Powered by Google App Engine
This is Rietveld 408576698