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