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

Side by Side Diff: trunk/src/content/renderer/memory_benchmarking_extension.cc

Issue 14773032: Revert 182659 "Get a filename of dumped heap profile in a V8 ext..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | trunk/src/third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/memory_benchmarking_extension.h" 5 #include "content/renderer/memory_benchmarking_extension.h"
6 6
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "content/public/renderer/render_thread.h" 8 #include "content/public/renderer/render_thread.h"
9 9
10 #if !defined(NO_TCMALLOC) && defined(OS_LINUX) 10 #if !defined(NO_TCMALLOC) && defined(OS_LINUX)
(...skipping 17 matching lines...) Expand all
28 "};" 28 "};"
29 "if (typeof(chrome.memoryBenchmarking) == 'undefined') {" 29 "if (typeof(chrome.memoryBenchmarking) == 'undefined') {"
30 " chrome.memoryBenchmarking = {};" 30 " chrome.memoryBenchmarking = {};"
31 "};" 31 "};"
32 "chrome.memoryBenchmarking.isHeapProfilerRunning = function() {" 32 "chrome.memoryBenchmarking.isHeapProfilerRunning = function() {"
33 " native function IsHeapProfilerRunning();" 33 " native function IsHeapProfilerRunning();"
34 " return IsHeapProfilerRunning();" 34 " return IsHeapProfilerRunning();"
35 "};" 35 "};"
36 "chrome.memoryBenchmarking.heapProfilerDump = function(reason) {" 36 "chrome.memoryBenchmarking.heapProfilerDump = function(reason) {"
37 " native function HeapProfilerDump();" 37 " native function HeapProfilerDump();"
38 " return HeapProfilerDump(reason);" 38 " HeapProfilerDump(reason);"
39 "};" 39 "};"
40 ) {} 40 ) {}
41 41
42 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction( 42 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunction(
43 v8::Handle<v8::String> name) OVERRIDE { 43 v8::Handle<v8::String> name) OVERRIDE {
44 if (name->Equals(v8::String::New("IsHeapProfilerRunning"))) 44 if (name->Equals(v8::String::New("IsHeapProfilerRunning")))
45 return v8::FunctionTemplate::New(IsHeapProfilerRunning); 45 return v8::FunctionTemplate::New(IsHeapProfilerRunning);
46 else if (name->Equals(v8::String::New("HeapProfilerDump"))) 46 else if (name->Equals(v8::String::New("HeapProfilerDump")))
47 return v8::FunctionTemplate::New(HeapProfilerDump); 47 return v8::FunctionTemplate::New(HeapProfilerDump);
48 48
49 return v8::Handle<v8::FunctionTemplate>(); 49 return v8::Handle<v8::FunctionTemplate>();
50 } 50 }
51 51
52 static v8::Handle<v8::Value> IsHeapProfilerRunning( 52 static v8::Handle<v8::Value> IsHeapProfilerRunning(
53 const v8::Arguments& args) { 53 const v8::Arguments& args) {
54 #if !defined(NO_TCMALLOC) && defined(OS_LINUX) 54 #if !defined(NO_TCMALLOC) && defined(OS_LINUX)
55 return v8::Boolean::New(::IsHeapProfilerRunning()); 55 return v8::Boolean::New(::IsHeapProfilerRunning());
56 #else 56 #else
57 return v8::Boolean::New(false); 57 return v8::Boolean::New(false);
58 #endif // !defined(NO_TCMALLOC) && defined(OS_LINUX) 58 #endif // !defined(NO_TCMALLOC) && defined(OS_LINUX)
59 } 59 }
60 60
61 static v8::Handle<v8::Value> HeapProfilerDump(const v8::Arguments& args) { 61 static v8::Handle<v8::Value> HeapProfilerDump(const v8::Arguments& args) {
62 #if !defined(NO_TCMALLOC) && defined(OS_LINUX) 62 #if !defined(NO_TCMALLOC) && defined(OS_LINUX)
63 char dumped_filename_buffer[1000];
64 std::string reason("benchmarking_extension"); 63 std::string reason("benchmarking_extension");
65 if (args.Length() && args[0]->IsString()) 64 if (args.Length() && args[0]->IsString())
66 reason = *v8::String::AsciiValue(args[0]); 65 reason = *v8::String::AsciiValue(args[0]);
67 ::HeapProfilerDumpWithFileName(reason.c_str(), 66 ::HeapProfilerDump(reason.c_str());
68 dumped_filename_buffer,
69 sizeof(dumped_filename_buffer));
70 return v8::String::New(dumped_filename_buffer);
71 #endif // !defined(NO_TCMALLOC) && defined(OS_LINUX) 67 #endif // !defined(NO_TCMALLOC) && defined(OS_LINUX)
72 return v8::Undefined(); 68 return v8::Undefined();
73 } 69 }
74 }; 70 };
75 71
76 } // namespace 72 } // namespace
77 73
78 namespace content { 74 namespace content {
79 75
80 v8::Extension* MemoryBenchmarkingExtension::Get() { 76 v8::Extension* MemoryBenchmarkingExtension::Get() {
81 return new MemoryBenchmarkingWrapper(); 77 return new MemoryBenchmarkingWrapper();
82 } 78 }
83 79
84 } // namespace content 80 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | trunk/src/third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698