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
3// found in the LICENSE file.
4
5#include "content/browser/renderer_host/memory_benchmark_message_filter.h"
6
7#include "content/common/memory_benchmark_messages.h"
8
9#if defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID))
10
11#include "third_party/tcmalloc/chromium/src/gperftools/heap-profiler.h"
12
13namespace content {
14
15MemoryBenchmarkMessageFilter::MemoryBenchmarkMessageFilter() {
16}
17
18bool MemoryBenchmarkMessageFilter::OnMessageReceived(
19    const IPC::Message& message,
20    bool* message_was_ok) {
21  bool handled = true;
22  IPC_BEGIN_MESSAGE_MAP_EX(MemoryBenchmarkMessageFilter,
23                           message,
24                           *message_was_ok)
25    IPC_MESSAGE_HANDLER(MemoryBenchmarkHostMsg_HeapProfilerDump,
26                        OnHeapProfilerDump)
27    IPC_MESSAGE_UNHANDLED(handled = false)
28  IPC_END_MESSAGE_MAP()
29  return handled;
30}
31
32MemoryBenchmarkMessageFilter::~MemoryBenchmarkMessageFilter() {
33}
34
35void MemoryBenchmarkMessageFilter::OnHeapProfilerDump(
36    const std::string& reason) {
37  ::HeapProfilerDump(reason.c_str());
38}
39
40}  // namespace content
41
42#endif  // defined(USE_TCMALLOC) && (defined(OS_LINUX) || defined(OS_ANDROID))
43