| OLD | NEW |
| 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 "content/common/memory_benchmark_messages.h" | 7 #include "content/common/memory_benchmark_messages.h" |
| 8 #include "content/renderer/chrome_object_extensions_utils.h" | 8 #include "content/renderer/chrome_object_extensions_utils.h" |
| 9 #include "content/renderer/render_thread_impl.h" | 9 #include "content/renderer/render_thread_impl.h" |
| 10 #include "gin/arguments.h" | 10 #include "gin/arguments.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 return gin::Wrappable<MemoryBenchmarkingExtension>::GetObjectTemplateBuilder( | 51 return gin::Wrappable<MemoryBenchmarkingExtension>::GetObjectTemplateBuilder( |
| 52 isolate) | 52 isolate) |
| 53 .SetMethod("isHeapProfilerRunning", | 53 .SetMethod("isHeapProfilerRunning", |
| 54 &MemoryBenchmarkingExtension::IsHeapProfilerRunning) | 54 &MemoryBenchmarkingExtension::IsHeapProfilerRunning) |
| 55 .SetMethod("heapProfilerDump", | 55 .SetMethod("heapProfilerDump", |
| 56 &MemoryBenchmarkingExtension::HeapProfilerDump); | 56 &MemoryBenchmarkingExtension::HeapProfilerDump); |
| 57 } | 57 } |
| 58 | 58 |
| 59 bool MemoryBenchmarkingExtension::IsHeapProfilerRunning() { | 59 bool MemoryBenchmarkingExtension::IsHeapProfilerRunning() { |
| 60 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) | 60 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
| 61 return ::IsHeapProfilerRunning(); | 61 return base::allocator::IsHeapProfilerRunning(); |
| 62 #else | 62 #else |
| 63 return false; | 63 return false; |
| 64 #endif | 64 #endif |
| 65 } | 65 } |
| 66 | 66 |
| 67 void MemoryBenchmarkingExtension::HeapProfilerDump(gin::Arguments* args) { | 67 void MemoryBenchmarkingExtension::HeapProfilerDump(gin::Arguments* args) { |
| 68 std::string process_type; | 68 std::string process_type; |
| 69 std::string reason("benchmarking_extension"); | 69 std::string reason("benchmarking_extension"); |
| 70 | 70 |
| 71 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsString()) { | 71 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsString()) { |
| 72 args->GetNext(&process_type); | 72 args->GetNext(&process_type); |
| 73 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsString()) | 73 if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsString()) |
| 74 args->GetNext(&reason); | 74 args->GetNext(&reason); |
| 75 } | 75 } |
| 76 | 76 |
| 77 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) | 77 #if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID)) |
| 78 if (process_type == "browser") { | 78 if (process_type == "browser") { |
| 79 content::RenderThreadImpl::current()->Send( | 79 content::RenderThreadImpl::current()->Send( |
| 80 new MemoryBenchmarkHostMsg_HeapProfilerDump(reason)); | 80 new MemoryBenchmarkHostMsg_HeapProfilerDump(reason)); |
| 81 } else { | 81 } else { |
| 82 ::HeapProfilerDump(reason.c_str()); | 82 base::allocator::HeapProfilerDump(reason.c_str()); |
| 83 } | 83 } |
| 84 #endif | 84 #endif |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // namespace content | 87 } // namespace content |
| OLD | NEW |