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 "content/browser/profiler_controller_impl.h" | 8 #include "content/browser/profiler_controller_impl.h" |
9 #include "content/browser/tcmalloc_internals_request_job.h" | 9 #include "content/browser/tcmalloc_internals_request_job.h" |
10 #include "content/common/child_process_messages.h" | 10 #include "content/common/child_process_messages.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 ProfilerMessageFilter::ProfilerMessageFilter(int process_type) | 14 ProfilerMessageFilter::ProfilerMessageFilter(int process_type) |
15 : BrowserMessageFilter(ChildProcessMsgStart), | 15 : BrowserMessageFilter(ChildProcessMsgStart), |
16 process_type_(process_type) { | 16 process_type_(process_type) { |
17 } | 17 } |
18 | 18 |
19 void ProfilerMessageFilter::OnChannelConnected(int32 peer_pid) { | 19 void ProfilerMessageFilter::OnChannelConnected(int32 peer_pid) { |
20 tracked_objects::ThreadData::Status status = | 20 tracked_objects::ThreadData::Status status = |
21 tracked_objects::ThreadData::status(); | 21 tracked_objects::ThreadData::status(); |
22 Send(new ChildProcessMsg_SetProfilerStatus(status)); | 22 Send(new ChildProcessMsg_SetProfilerStatus(status)); |
23 } | 23 } |
24 | 24 |
25 bool ProfilerMessageFilter::OnMessageReceived(const IPC::Message& message, | 25 bool ProfilerMessageFilter::OnMessageReceived(const IPC::Message& message) { |
26 bool* message_was_ok) { | |
27 bool handled = true; | 26 bool handled = true; |
28 IPC_BEGIN_MESSAGE_MAP_EX(ProfilerMessageFilter, message, *message_was_ok) | 27 IPC_BEGIN_MESSAGE_MAP(ProfilerMessageFilter, message) |
29 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ChildProfilerData, | 28 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ChildProfilerData, |
30 OnChildProfilerData) | 29 OnChildProfilerData) |
31 #if defined(USE_TCMALLOC) | 30 #if defined(USE_TCMALLOC) |
32 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TcmallocStats, OnTcmallocStats) | 31 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_TcmallocStats, OnTcmallocStats) |
33 #endif | 32 #endif |
34 IPC_MESSAGE_UNHANDLED(handled = false) | 33 IPC_MESSAGE_UNHANDLED(handled = false) |
35 IPC_END_MESSAGE_MAP_EX() | 34 IPC_END_MESSAGE_MAP() |
36 return handled; | 35 return handled; |
37 } | 36 } |
38 | 37 |
39 ProfilerMessageFilter::~ProfilerMessageFilter() {} | 38 ProfilerMessageFilter::~ProfilerMessageFilter() {} |
40 | 39 |
41 void ProfilerMessageFilter::OnChildProfilerData( | 40 void ProfilerMessageFilter::OnChildProfilerData( |
42 int sequence_number, | 41 int sequence_number, |
43 const tracked_objects::ProcessDataSnapshot& profiler_data) { | 42 const tracked_objects::ProcessDataSnapshot& profiler_data) { |
44 ProfilerControllerImpl::GetInstance()->OnProfilerDataCollected( | 43 ProfilerControllerImpl::GetInstance()->OnProfilerDataCollected( |
45 sequence_number, profiler_data, process_type_); | 44 sequence_number, profiler_data, process_type_); |
46 } | 45 } |
47 | 46 |
48 #if defined(USE_TCMALLOC) | 47 #if defined(USE_TCMALLOC) |
49 void ProfilerMessageFilter::OnTcmallocStats(const std::string& output) { | 48 void ProfilerMessageFilter::OnTcmallocStats(const std::string& output) { |
50 AboutTcmallocOutputs::GetInstance()->OnStatsForChildProcess( | 49 AboutTcmallocOutputs::GetInstance()->OnStatsForChildProcess( |
51 peer_pid(), process_type_, output); | 50 peer_pid(), process_type_, output); |
52 } | 51 } |
53 #endif | 52 #endif |
54 | 53 |
55 } | 54 } |
OLD | NEW |