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

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: palmer's comments 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
« no previous file with comments | « content/content_common.gypi ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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))
« no previous file with comments | « content/content_common.gypi ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698