Chromium Code Reviews| 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..00d31e2f0390fa9ac47bfbb5a6c8e73f1d6350fc 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" |
| -#endif // !defined(NO_TCMALLOC) && defined(OS_LINUX) |
| + |
| +#if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
| namespace { |
| @@ -51,25 +51,29 @@ 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 v8::Handle<v8::Value> HeapProfilerDumpBrowser() { |
| + base::FilePath dump_file_name; |
| + |
| + content::RenderThreadImpl::current()->Send( |
| + new MemoryBenchmarkHostMsg_HeapProfilerDump(&dump_file_name)); |
| + return v8::String::New(dump_file_name.value().c_str(), |
| + dump_file_name.value().length()); |
| } |
| 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]); |
| + if (reason == "browser") |
|
Dai Mikurube (NOT FULLTIME)
2013/05/14 20:15:08
Ahh, sorry, I overlooked the important part. I fo
|
| + return HeapProfilerDumpBrowser(); |
| ::HeapProfilerDumpWithFileName(reason.c_str(), |
|
palmer
2013/05/10 19:53:53
So, the renderer asks the browser for a FilePath (
Dai Mikurube (NOT FULLTIME)
2013/05/10 20:41:30
Yes, this is used under a very limited situation,
|
| dumped_filename_buffer, |
| sizeof(dumped_filename_buffer)); |
| return v8::String::New(dumped_filename_buffer); |
| -#endif // !defined(NO_TCMALLOC) && defined(OS_LINUX) |
| - return v8::Undefined(); |
| } |
| }; |
| @@ -82,3 +86,5 @@ v8::Extension* MemoryBenchmarkingExtension::Get() { |
| } |
| } // namespace content |
| + |
| +#endif // defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |