| 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/metrics/statistics_recorder.h" | 7 #include "base/metrics/statistics_recorder.h" |
| 8 #include "base/trace_event/trace_event.h" | 8 #include "base/trace_event/trace_event.h" |
| 9 #include "components/tracing/child_memory_dump_manager_delegate_impl.h" | 9 #include "components/tracing/child_memory_dump_manager_delegate_impl.h" |
| 10 #include "components/tracing/tracing_messages.h" | 10 #include "components/tracing/tracing_messages.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 IPC_MESSAGE_UNHANDLED(handled = false) | 66 IPC_MESSAGE_UNHANDLED(handled = false) |
| 67 IPC_END_MESSAGE_MAP() | 67 IPC_END_MESSAGE_MAP() |
| 68 return handled; | 68 return handled; |
| 69 } | 69 } |
| 70 | 70 |
| 71 ChildTraceMessageFilter::~ChildTraceMessageFilter() {} | 71 ChildTraceMessageFilter::~ChildTraceMessageFilter() {} |
| 72 | 72 |
| 73 void ChildTraceMessageFilter::OnBeginTracing( | 73 void ChildTraceMessageFilter::OnBeginTracing( |
| 74 const std::string& trace_config_str, | 74 const std::string& trace_config_str, |
| 75 base::TimeTicks browser_time, | 75 base::TimeTicks browser_time, |
| 76 uint64 tracing_process_id) { | 76 uint64_t tracing_process_id) { |
| 77 #if defined(__native_client__) | 77 #if defined(__native_client__) |
| 78 // NaCl and system times are offset by a bit, so subtract some time from | 78 // NaCl and system times are offset by a bit, so subtract some time from |
| 79 // the captured timestamps. The value might be off by a bit due to messaging | 79 // the captured timestamps. The value might be off by a bit due to messaging |
| 80 // latency. | 80 // latency. |
| 81 base::TimeDelta time_offset = base::TimeTicks::Now() - browser_time; | 81 base::TimeDelta time_offset = base::TimeTicks::Now() - browser_time; |
| 82 TraceLog::GetInstance()->SetTimeOffset(time_offset); | 82 TraceLog::GetInstance()->SetTimeOffset(time_offset); |
| 83 #endif | 83 #endif |
| 84 ChildMemoryDumpManagerDelegateImpl::GetInstance()->set_tracing_process_id( | 84 ChildMemoryDumpManagerDelegateImpl::GetInstance()->set_tracing_process_id( |
| 85 tracing_process_id); | 85 tracing_process_id); |
| 86 TraceLog::GetInstance()->SetEnabled( | 86 TraceLog::GetInstance()->SetEnabled( |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 193 } |
| 194 | 194 |
| 195 // Sent by the Browser's MemoryDumpManager when coordinating a global dump. | 195 // Sent by the Browser's MemoryDumpManager when coordinating a global dump. |
| 196 void ChildTraceMessageFilter::OnProcessMemoryDumpRequest( | 196 void ChildTraceMessageFilter::OnProcessMemoryDumpRequest( |
| 197 const base::trace_event::MemoryDumpRequestArgs& args) { | 197 const base::trace_event::MemoryDumpRequestArgs& args) { |
| 198 ChildMemoryDumpManagerDelegateImpl::GetInstance()->CreateProcessDump( | 198 ChildMemoryDumpManagerDelegateImpl::GetInstance()->CreateProcessDump( |
| 199 args, | 199 args, |
| 200 base::Bind(&ChildTraceMessageFilter::OnProcessMemoryDumpDone, this)); | 200 base::Bind(&ChildTraceMessageFilter::OnProcessMemoryDumpDone, this)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 void ChildTraceMessageFilter::OnProcessMemoryDumpDone(uint64 dump_guid, | 203 void ChildTraceMessageFilter::OnProcessMemoryDumpDone(uint64_t dump_guid, |
| 204 bool success) { | 204 bool success) { |
| 205 sender_->Send( | 205 sender_->Send( |
| 206 new TracingHostMsg_ProcessMemoryDumpResponse(dump_guid, success)); | 206 new TracingHostMsg_ProcessMemoryDumpResponse(dump_guid, success)); |
| 207 } | 207 } |
| 208 | 208 |
| 209 // Initiates a dump request, asking the Browser's MemoryDumpManager to | 209 // Initiates a dump request, asking the Browser's MemoryDumpManager to |
| 210 // coordinate a global memory dump. The Browser's MDM will answer back with a | 210 // coordinate a global memory dump. The Browser's MDM will answer back with a |
| 211 // MemoryDumpResponse when all the child processes (including this one) have | 211 // MemoryDumpResponse when all the child processes (including this one) have |
| 212 // dumped, or with a NACK (|success| == false) if the dump failed (e.g., due to | 212 // dumped, or with a NACK (|success| == false) if the dump failed (e.g., due to |
| 213 // a collision with a concurrent request from another child process). | 213 // a collision with a concurrent request from another child process). |
| 214 void ChildTraceMessageFilter::SendGlobalMemoryDumpRequest( | 214 void ChildTraceMessageFilter::SendGlobalMemoryDumpRequest( |
| 215 const base::trace_event::MemoryDumpRequestArgs& args, | 215 const base::trace_event::MemoryDumpRequestArgs& args, |
| 216 const base::trace_event::MemoryDumpCallback& callback) { | 216 const base::trace_event::MemoryDumpCallback& callback) { |
| 217 // If there is already another dump request pending from this child process, | 217 // If there is already another dump request pending from this child process, |
| 218 // there is no point bothering the Browser's MemoryDumpManager. | 218 // there is no point bothering the Browser's MemoryDumpManager. |
| 219 if (pending_memory_dump_guid_) { | 219 if (pending_memory_dump_guid_) { |
| 220 if (!callback.is_null()) | 220 if (!callback.is_null()) |
| 221 callback.Run(args.dump_guid, false); | 221 callback.Run(args.dump_guid, false); |
| 222 return; | 222 return; |
| 223 } | 223 } |
| 224 | 224 |
| 225 pending_memory_dump_guid_ = args.dump_guid; | 225 pending_memory_dump_guid_ = args.dump_guid; |
| 226 pending_memory_dump_callback_ = callback; | 226 pending_memory_dump_callback_ = callback; |
| 227 sender_->Send(new TracingHostMsg_GlobalMemoryDumpRequest(args)); | 227 sender_->Send(new TracingHostMsg_GlobalMemoryDumpRequest(args)); |
| 228 } | 228 } |
| 229 | 229 |
| 230 // Sent by the Browser's MemoryDumpManager in response of a dump request | 230 // Sent by the Browser's MemoryDumpManager in response of a dump request |
| 231 // initiated by this child process. | 231 // initiated by this child process. |
| 232 void ChildTraceMessageFilter::OnGlobalMemoryDumpResponse(uint64 dump_guid, | 232 void ChildTraceMessageFilter::OnGlobalMemoryDumpResponse(uint64_t dump_guid, |
| 233 bool success) { | 233 bool success) { |
| 234 DCHECK_NE(0U, pending_memory_dump_guid_); | 234 DCHECK_NE(0U, pending_memory_dump_guid_); |
| 235 pending_memory_dump_guid_ = 0; | 235 pending_memory_dump_guid_ = 0; |
| 236 if (pending_memory_dump_callback_.is_null()) | 236 if (pending_memory_dump_callback_.is_null()) |
| 237 return; | 237 return; |
| 238 pending_memory_dump_callback_.Run(dump_guid, success); | 238 pending_memory_dump_callback_.Run(dump_guid, success); |
| 239 } | 239 } |
| 240 | 240 |
| 241 void ChildTraceMessageFilter::OnHistogramChanged( | 241 void ChildTraceMessageFilter::OnHistogramChanged( |
| 242 const std::string& histogram_name, | 242 const std::string& histogram_name, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 329 } |
| 330 } | 330 } |
| 331 | 331 |
| 332 void ChildTraceMessageFilter::OnClearUMACallback( | 332 void ChildTraceMessageFilter::OnClearUMACallback( |
| 333 const std::string& histogram_name) { | 333 const std::string& histogram_name) { |
| 334 histogram_last_changed_ = base::Time(); | 334 histogram_last_changed_ = base::Time(); |
| 335 base::StatisticsRecorder::ClearCallback(histogram_name); | 335 base::StatisticsRecorder::ClearCallback(histogram_name); |
| 336 } | 336 } |
| 337 | 337 |
| 338 } // namespace tracing | 338 } // namespace tracing |
| OLD | NEW |