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. :)
|