OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/profiler_message_filter.h" | 5 #include "content/browser/profiler_message_filter.h" |
6 | 6 |
7 #include "base/tracked_objects.h" | 7 #include "base/tracked_objects.h" |
| 8 #include "base/process_util.h" |
8 #include "content/browser/profiler_controller_impl.h" | 9 #include "content/browser/profiler_controller_impl.h" |
| 10 #include "content/browser/tcmalloc_internals_request_job.h" |
9 #include "content/common/child_process_messages.h" | 11 #include "content/common/child_process_messages.h" |
10 | 12 |
11 namespace content { | 13 namespace content { |
12 | 14 |
13 ProfilerMessageFilter::ProfilerMessageFilter(ProcessType process_type) | 15 ProfilerMessageFilter::ProfilerMessageFilter(ProcessType process_type) |
14 : process_type_(process_type) { | 16 : process_type_(process_type) { |
15 } | 17 } |
16 | 18 |
17 ProfilerMessageFilter::~ProfilerMessageFilter() { | 19 ProfilerMessageFilter::~ProfilerMessageFilter() { |
18 } | 20 } |
19 | 21 |
20 void ProfilerMessageFilter::OnChannelConnected(int32 peer_pid) { | 22 void ProfilerMessageFilter::OnChannelConnected(int32 peer_pid) { |
21 BrowserMessageFilter::OnChannelConnected(peer_pid); | 23 BrowserMessageFilter::OnChannelConnected(peer_pid); |
22 | 24 |
23 tracked_objects::ThreadData::Status status = | 25 tracked_objects::ThreadData::Status status = |
24 tracked_objects::ThreadData::status(); | 26 tracked_objects::ThreadData::status(); |
25 Send(new ChildProcessMsg_SetProfilerStatus(status)); | 27 Send(new ChildProcessMsg_SetProfilerStatus(status)); |
26 } | 28 } |
27 | 29 |
28 bool ProfilerMessageFilter::OnMessageReceived(const IPC::Message& message, | 30 bool ProfilerMessageFilter::OnMessageReceived(const IPC::Message& message, |
29 bool* message_was_ok) { | 31 bool* message_was_ok) { |
30 bool handled = true; | 32 bool handled = true; |
31 IPC_BEGIN_MESSAGE_MAP_EX(ProfilerMessageFilter, message, *message_was_ok) | 33 IPC_BEGIN_MESSAGE_MAP_EX(ProfilerMessageFilter, message, *message_was_ok) |
32 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ChildProfilerData, | 34 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ChildProfilerData, |
33 OnChildProfilerData) | 35 OnChildProfilerData) |
| 36 #if defined(USE_TCMALLOC) |
| 37 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TcmallocStats, OnTcmallocStats) |
| 38 #endif |
34 IPC_MESSAGE_UNHANDLED(handled = false) | 39 IPC_MESSAGE_UNHANDLED(handled = false) |
35 IPC_END_MESSAGE_MAP_EX() | 40 IPC_END_MESSAGE_MAP_EX() |
36 return handled; | 41 return handled; |
37 } | 42 } |
38 | 43 |
39 void ProfilerMessageFilter::OnChildProfilerData( | 44 void ProfilerMessageFilter::OnChildProfilerData( |
40 int sequence_number, | 45 int sequence_number, |
41 const tracked_objects::ProcessDataSnapshot& profiler_data) { | 46 const tracked_objects::ProcessDataSnapshot& profiler_data) { |
42 ProfilerControllerImpl::GetInstance()->OnProfilerDataCollected( | 47 ProfilerControllerImpl::GetInstance()->OnProfilerDataCollected( |
43 sequence_number, profiler_data, process_type_); | 48 sequence_number, profiler_data, process_type_); |
44 } | 49 } |
45 | 50 |
| 51 #if defined(USE_TCMALLOC) |
| 52 void ProfilerMessageFilter::OnTcmallocStats(const std::string& output) { |
| 53 BrowserThread::PostTask( |
| 54 BrowserThread::UI, FROM_HERE, |
| 55 base::Bind(&AboutTcmallocOutputs::OnStatsForChildProcess, |
| 56 base::Unretained(AboutTcmallocOutputs::GetInstance()), |
| 57 base::GetProcId(peer_handle()), |
| 58 process_type_, |
| 59 output)); |
46 } | 60 } |
| 61 #endif |
| 62 |
| 63 } |
OLD | NEW |