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