| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 } | 451 } |
| 452 | 452 |
| 453 void MessageLoop::RunTask(const PendingTask& pending_task) { | 453 void MessageLoop::RunTask(const PendingTask& pending_task) { |
| 454 tracked_objects::TrackedTime start_time = | 454 tracked_objects::TrackedTime start_time = |
| 455 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); | 455 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); |
| 456 | 456 |
| 457 TRACE_EVENT_FLOW_END1("task", "MessageLoop::PostTask", | 457 TRACE_EVENT_FLOW_END1("task", "MessageLoop::PostTask", |
| 458 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), | 458 TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), |
| 459 "queue_duration", | 459 "queue_duration", |
| 460 (start_time - pending_task.EffectiveTimePosted()).InMilliseconds()); | 460 (start_time - pending_task.EffectiveTimePosted()).InMilliseconds()); |
| 461 TRACE_EVENT2("task", "MessageLoop::RunTask", | 461 // When tracing memory for posted tasks it's more valuable to attribute the |
| 462 "src_file", pending_task.posted_from.file_name(), | 462 // memory allocations to the source function than generically to "RunTask". |
| 463 "src_func", pending_task.posted_from.function_name()); | 463 // Use a TRACE_EVENT2 variation to record a normal trace event but attribute |
| 464 // the memory to the pending task's source function name. |
| 465 TRACE_EVENT2_MEMORY_ARG2( |
| 466 "task", "MessageLoop::RunTask", |
| 467 "src_file", pending_task.posted_from.file_name(), |
| 468 "src_func", pending_task.posted_from.function_name()); |
| 464 | 469 |
| 465 DCHECK(nestable_tasks_allowed_); | 470 DCHECK(nestable_tasks_allowed_); |
| 466 // Execute the task and assume the worst: It is probably not reentrant. | 471 // Execute the task and assume the worst: It is probably not reentrant. |
| 467 nestable_tasks_allowed_ = false; | 472 nestable_tasks_allowed_ = false; |
| 468 | 473 |
| 469 // Before running the task, store the program counter where it was posted | 474 // Before running the task, store the program counter where it was posted |
| 470 // and deliberately alias it to ensure it is on the stack if the task | 475 // and deliberately alias it to ensure it is on the stack if the task |
| 471 // crashes. Be careful not to assume that the variable itself will have the | 476 // crashes. Be careful not to assume that the variable itself will have the |
| 472 // expected value when displayed by the optimizer in an optimized build. | 477 // expected value when displayed by the optimizer in an optimized build. |
| 473 // Look at a memory dump of the stack. | 478 // Look at a memory dump of the stack. |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 fd, | 750 fd, |
| 746 persistent, | 751 persistent, |
| 747 mode, | 752 mode, |
| 748 controller, | 753 controller, |
| 749 delegate); | 754 delegate); |
| 750 } | 755 } |
| 751 | 756 |
| 752 #endif | 757 #endif |
| 753 | 758 |
| 754 } // namespace base | 759 } // namespace base |
| OLD | NEW |