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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
405 return false; | 405 return false; |
406 | 406 |
407 PendingTask pending_task = deferred_non_nestable_work_queue_.front(); | 407 PendingTask pending_task = deferred_non_nestable_work_queue_.front(); |
408 deferred_non_nestable_work_queue_.pop(); | 408 deferred_non_nestable_work_queue_.pop(); |
409 | 409 |
410 RunTask(pending_task); | 410 RunTask(pending_task); |
411 return true; | 411 return true; |
412 } | 412 } |
413 | 413 |
414 void MessageLoop::RunTask(const PendingTask& pending_task) { | 414 void MessageLoop::RunTask(const PendingTask& pending_task) { |
415 // For absolutely minimal tracing, "toplevel" captures _everything_ | |
416 // on a typical message loop thread, so long as the thread runs | |
417 // semi-regular tasks (for sufficient measurement granularity). | |
epenner
2014/02/12 02:02:16
This is the primary tracing change. The rest just
| |
418 TRACE_EVENT_END0("toplevel", "All"); | |
419 TRACE_EVENT_BEGIN0("toplevel", "All"); | |
420 | |
415 tracked_objects::TrackedTime start_time = | 421 tracked_objects::TrackedTime start_time = |
416 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); | 422 tracked_objects::ThreadData::NowForStartOfRun(pending_task.birth_tally); |
417 | 423 |
418 TRACE_EVENT_FLOW_END1(TRACE_DISABLED_BY_DEFAULT("toplevel.flow"), | 424 TRACE_EVENT_FLOW_END1(TRACE_DISABLED_BY_DEFAULT("task.flow"), |
419 "MessageLoop::PostTask", TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), | 425 "MessageLoop::PostTask", TRACE_ID_MANGLE(GetTaskTraceID(pending_task)), |
420 "queue_duration", | 426 "queue_duration", |
421 (start_time - pending_task.EffectiveTimePosted()).InMilliseconds()); | 427 (start_time - pending_task.EffectiveTimePosted()).InMilliseconds()); |
422 // When tracing memory for posted tasks it's more valuable to attribute the | 428 // When tracing memory for posted tasks it's more valuable to attribute the |
423 // memory allocations to the source function than generically to "RunTask". | 429 // memory allocations to the source function than generically to "RunTask". |
424 TRACE_EVENT_WITH_MEMORY_TAG2( | 430 TRACE_EVENT_WITH_MEMORY_TAG2( |
425 "toplevel", "MessageLoop::RunTask", | 431 "task", "MessageLoop::RunTask", |
426 pending_task.posted_from.function_name(), // Name for memory tracking. | 432 pending_task.posted_from.function_name(), // Name for memory tracking. |
427 "src_file", pending_task.posted_from.file_name(), | 433 "src_file", pending_task.posted_from.file_name(), |
428 "src_func", pending_task.posted_from.function_name()); | 434 "src_func", pending_task.posted_from.function_name()); |
429 | 435 |
430 DCHECK(nestable_tasks_allowed_); | 436 DCHECK(nestable_tasks_allowed_); |
431 // Execute the task and assume the worst: It is probably not reentrant. | 437 // Execute the task and assume the worst: It is probably not reentrant. |
432 nestable_tasks_allowed_ = false; | 438 nestable_tasks_allowed_ = false; |
433 | 439 |
434 // Before running the task, store the program counter where it was posted | 440 // Before running the task, store the program counter where it was posted |
435 // and deliberately alias it to ensure it is on the stack if the task | 441 // and deliberately alias it to ensure it is on the stack if the task |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 fd, | 724 fd, |
719 persistent, | 725 persistent, |
720 mode, | 726 mode, |
721 controller, | 727 controller, |
722 delegate); | 728 delegate); |
723 } | 729 } |
724 | 730 |
725 #endif | 731 #endif |
726 | 732 |
727 } // namespace base | 733 } // namespace base |
OLD | NEW |