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 "base/tracked_objects.h" | 5 #include "base/tracked_objects.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 // Even if we have been DEACTIVATED, we will process any pending births so | 458 // Even if we have been DEACTIVATED, we will process any pending births so |
459 // that our data structures (which counted the outstanding births) remain | 459 // that our data structures (which counted the outstanding births) remain |
460 // consistent. | 460 // consistent. |
461 const Births* birth = completed_task.birth_tally; | 461 const Births* birth = completed_task.birth_tally; |
462 if (!birth) | 462 if (!birth) |
463 return; | 463 return; |
464 ThreadData* current_thread_data = Get(); | 464 ThreadData* current_thread_data = Get(); |
465 if (!current_thread_data) | 465 if (!current_thread_data) |
466 return; | 466 return; |
467 | 467 |
468 // To avoid conflating our stats with the delay duration in a PostDelayedTask, | |
469 // we identify such tasks, and replace their post_time with the time they | |
470 // were scheduled (requested?) to emerge from the delayed task queue. This | |
471 // means that queueing delay for such tasks will show how long they went | |
472 // unserviced, after they *could* be serviced. This is the same stat as we | |
473 // have for non-delayed tasks, and we consistently call it queueing delay. | |
474 TrackedTime effective_post_time = completed_task.delayed_run_time.is_null() | |
475 ? tracked_objects::TrackedTime(completed_task.time_posted) | |
476 : tracked_objects::TrackedTime(completed_task.delayed_run_time); | |
477 | |
478 // Watch out for a race where status_ is changing, and hence one or both | 468 // Watch out for a race where status_ is changing, and hence one or both |
479 // of start_of_run or end_of_run is zero. In that case, we didn't bother to | 469 // of start_of_run or end_of_run is zero. In that case, we didn't bother to |
480 // get a time value since we "weren't tracking" and we were trying to be | 470 // get a time value since we "weren't tracking" and we were trying to be |
481 // efficient by not calling for a genuine time value. For simplicity, we'll | 471 // efficient by not calling for a genuine time value. For simplicity, we'll |
482 // use a default zero duration when we can't calculate a true value. | 472 // use a default zero duration when we can't calculate a true value. |
483 int32 queue_duration = 0; | 473 int32 queue_duration = 0; |
484 int32 run_duration = 0; | 474 int32 run_duration = 0; |
485 if (!start_of_run.is_null()) { | 475 if (!start_of_run.is_null()) { |
486 queue_duration = (start_of_run - effective_post_time).InMilliseconds(); | 476 queue_duration = (start_of_run - completed_task.EffectiveTimePosted()) |
| 477 .InMilliseconds(); |
487 if (!end_of_run.is_null()) | 478 if (!end_of_run.is_null()) |
488 run_duration = (end_of_run - start_of_run).InMilliseconds(); | 479 run_duration = (end_of_run - start_of_run).InMilliseconds(); |
489 } | 480 } |
490 current_thread_data->TallyADeath(*birth, queue_duration, run_duration); | 481 current_thread_data->TallyADeath(*birth, queue_duration, run_duration); |
491 } | 482 } |
492 | 483 |
493 // static | 484 // static |
494 void ThreadData::TallyRunOnWorkerThreadIfTracking( | 485 void ThreadData::TallyRunOnWorkerThreadIfTracking( |
495 const Births* birth, | 486 const Births* birth, |
496 const TrackedTime& time_posted, | 487 const TrackedTime& time_posted, |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 : process_id(base::GetCurrentProcId()) { | 861 : process_id(base::GetCurrentProcId()) { |
871 #else | 862 #else |
872 : process_id(0) { | 863 : process_id(0) { |
873 #endif | 864 #endif |
874 } | 865 } |
875 | 866 |
876 ProcessDataSnapshot::~ProcessDataSnapshot() { | 867 ProcessDataSnapshot::~ProcessDataSnapshot() { |
877 } | 868 } |
878 | 869 |
879 } // namespace tracked_objects | 870 } // namespace tracked_objects |
OLD | NEW |