OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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/profiler_message_filter.h" |
| 6 |
| 7 #include "base/tracked_objects.h" |
| 8 #include "base/values.h" |
| 9 #include "content/browser/profiler_controller_impl.h" |
| 10 #include "content/common/child_process_messages.h" |
| 11 |
| 12 using content::BrowserThread; |
| 13 |
| 14 ProfilerMessageFilter::ProfilerMessageFilter() { |
| 15 } |
| 16 |
| 17 ProfilerMessageFilter::~ProfilerMessageFilter() { |
| 18 } |
| 19 |
| 20 void ProfilerMessageFilter::OnChannelConnected(int32 peer_pid) { |
| 21 BrowserMessageFilter::OnChannelConnected(peer_pid); |
| 22 |
| 23 bool enable = tracked_objects::ThreadData::tracking_status(); |
| 24 Send(new ChildProcessMsg_SetProfilerStatus(enable)); |
| 25 } |
| 26 |
| 27 bool ProfilerMessageFilter::OnMessageReceived(const IPC::Message& message, |
| 28 bool* message_was_ok) { |
| 29 bool handled = true; |
| 30 IPC_BEGIN_MESSAGE_MAP_EX(ProfilerMessageFilter, message, *message_was_ok) |
| 31 IPC_MESSAGE_HANDLER(ChildProcessHostMsg_ChildProfilerData, |
| 32 OnChildProfilerData) |
| 33 IPC_MESSAGE_UNHANDLED(handled = false) |
| 34 IPC_END_MESSAGE_MAP_EX() |
| 35 return handled; |
| 36 } |
| 37 |
| 38 void ProfilerMessageFilter::OnChildProfilerData( |
| 39 int sequence_number, |
| 40 const base::DictionaryValue& profiler_data) { |
| 41 base::DictionaryValue* dictionary_value = new base::DictionaryValue; |
| 42 dictionary_value->MergeDictionary(&profiler_data); |
| 43 // OnProfilerDataCollected assumes the ownership of profiler_data. |
| 44 content::ProfilerControllerImpl::GetInstance()->OnProfilerDataCollected( |
| 45 sequence_number, dictionary_value); |
| 46 } |
OLD | NEW |