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