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 "components/tracing/child_trace_message_filter.h" | 5 #include "components/tracing/child_trace_message_filter.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/message_loop/message_loop_proxy.h" | 8 #include "base/message_loop/message_loop_proxy.h" |
9 #include "components/tracing/tracing_messages.h" | 9 #include "components/tracing/tracing_messages.h" |
10 #include "ipc/ipc_channel.h" | 10 #include "ipc/ipc_channel.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 IPC_MESSAGE_UNHANDLED(handled = false) | 43 IPC_MESSAGE_UNHANDLED(handled = false) |
44 IPC_END_MESSAGE_MAP() | 44 IPC_END_MESSAGE_MAP() |
45 return handled; | 45 return handled; |
46 } | 46 } |
47 | 47 |
48 ChildTraceMessageFilter::~ChildTraceMessageFilter() {} | 48 ChildTraceMessageFilter::~ChildTraceMessageFilter() {} |
49 | 49 |
50 void ChildTraceMessageFilter::OnBeginTracing( | 50 void ChildTraceMessageFilter::OnBeginTracing( |
51 const std::string& category_filter_str, | 51 const std::string& category_filter_str, |
52 base::TimeTicks browser_time, | 52 base::TimeTicks browser_time, |
53 int options) { | 53 const std::string& options) { |
54 #if defined(__native_client__) | 54 #if defined(__native_client__) |
55 // NaCl and system times are offset by a bit, so subtract some time from | 55 // NaCl and system times are offset by a bit, so subtract some time from |
56 // the captured timestamps. The value might be off by a bit due to messaging | 56 // the captured timestamps. The value might be off by a bit due to messaging |
57 // latency. | 57 // latency. |
58 base::TimeDelta time_offset = base::TimeTicks::NowFromSystemTraceTime() - | 58 base::TimeDelta time_offset = base::TimeTicks::NowFromSystemTraceTime() - |
59 browser_time; | 59 browser_time; |
60 TraceLog::GetInstance()->SetTimeOffset(time_offset); | 60 TraceLog::GetInstance()->SetTimeOffset(time_offset); |
61 #endif | 61 #endif |
62 | 62 |
63 TraceLog::GetInstance()->SetEnabled( | 63 TraceLog::GetInstance()->SetEnabled( |
64 base::debug::CategoryFilter(category_filter_str), | 64 base::debug::CategoryFilter(category_filter_str), |
65 base::debug::TraceLog::RECORDING_MODE, | 65 base::debug::TraceLog::RECORDING_MODE, |
66 static_cast<base::debug::TraceLog::Options>(options)); | 66 base::debug::TraceOptions(options)); |
67 } | 67 } |
68 | 68 |
69 void ChildTraceMessageFilter::OnEndTracing() { | 69 void ChildTraceMessageFilter::OnEndTracing() { |
70 TraceLog::GetInstance()->SetDisabled(); | 70 TraceLog::GetInstance()->SetDisabled(); |
71 | 71 |
72 // Flush will generate one or more callbacks to OnTraceDataCollected | 72 // Flush will generate one or more callbacks to OnTraceDataCollected |
73 // synchronously or asynchronously. EndTracingAck will be sent in the last | 73 // synchronously or asynchronously. EndTracingAck will be sent in the last |
74 // OnTraceDataCollected. We are already on the IO thread, so the | 74 // OnTraceDataCollected. We are already on the IO thread, so the |
75 // OnTraceDataCollected calls will not be deferred. | 75 // OnTraceDataCollected calls will not be deferred. |
76 TraceLog::GetInstance()->Flush( | 76 TraceLog::GetInstance()->Flush( |
77 base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this)); | 77 base::Bind(&ChildTraceMessageFilter::OnTraceDataCollected, this)); |
78 } | 78 } |
79 | 79 |
80 void ChildTraceMessageFilter::OnEnableMonitoring( | 80 void ChildTraceMessageFilter::OnEnableMonitoring( |
81 const std::string& category_filter_str, | 81 const std::string& category_filter_str, |
82 base::TimeTicks browser_time, | 82 base::TimeTicks browser_time, |
83 int options) { | 83 const std::string& options) { |
84 TraceLog::GetInstance()->SetEnabled( | 84 TraceLog::GetInstance()->SetEnabled( |
85 base::debug::CategoryFilter(category_filter_str), | 85 base::debug::CategoryFilter(category_filter_str), |
86 base::debug::TraceLog::MONITORING_MODE, | 86 base::debug::TraceLog::MONITORING_MODE, |
87 static_cast<base::debug::TraceLog::Options>(options)); | 87 base::debug::TraceOptions(options)); |
88 } | 88 } |
89 | 89 |
90 void ChildTraceMessageFilter::OnDisableMonitoring() { | 90 void ChildTraceMessageFilter::OnDisableMonitoring() { |
91 TraceLog::GetInstance()->SetDisabled(); | 91 TraceLog::GetInstance()->SetDisabled(); |
92 } | 92 } |
93 | 93 |
94 void ChildTraceMessageFilter::OnCaptureMonitoringSnapshot() { | 94 void ChildTraceMessageFilter::OnCaptureMonitoringSnapshot() { |
95 // Flush will generate one or more callbacks to | 95 // Flush will generate one or more callbacks to |
96 // OnMonitoringTraceDataCollected. It's important that the last | 96 // OnMonitoringTraceDataCollected. It's important that the last |
97 // OnMonitoringTraceDataCollected gets called before | 97 // OnMonitoringTraceDataCollected gets called before |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 return; | 161 return; |
162 } | 162 } |
163 sender_->Send(new TracingHostMsg_MonitoringTraceDataCollected( | 163 sender_->Send(new TracingHostMsg_MonitoringTraceDataCollected( |
164 events_str_ptr->data())); | 164 events_str_ptr->data())); |
165 | 165 |
166 if (!has_more_events) | 166 if (!has_more_events) |
167 sender_->Send(new TracingHostMsg_CaptureMonitoringSnapshotAck()); | 167 sender_->Send(new TracingHostMsg_CaptureMonitoringSnapshotAck()); |
168 } | 168 } |
169 | 169 |
170 } // namespace tracing | 170 } // namespace tracing |
OLD | NEW |