OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 tracked_objects::ThreadData::Status status = | 24 bool enable = tracked_objects::ThreadData::tracking_status(); |
25 tracked_objects::ThreadData::status(); | 25 Send(new ChildProcessMsg_SetProfilerStatus(enable)); |
26 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 base::DictionaryValue& profiler_data) { |
43 base::DictionaryValue* dictionary_value = new base::DictionaryValue; | 42 base::DictionaryValue* dictionary_value = new base::DictionaryValue; |
44 dictionary_value->MergeDictionary(&profiler_data); | 43 dictionary_value->MergeDictionary(&profiler_data); |
45 // OnProfilerDataCollected assumes the ownership of profiler_data. | 44 // OnProfilerDataCollected assumes the ownership of profiler_data. |
46 content::ProfilerControllerImpl::GetInstance()->OnProfilerDataCollected( | 45 content::ProfilerControllerImpl::GetInstance()->OnProfilerDataCollected( |
47 sequence_number, dictionary_value); | 46 sequence_number, dictionary_value); |
48 } | 47 } |
OLD | NEW |