OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | 8 |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 Duration run_duration; | 502 Duration run_duration; |
503 if (!start_of_run.is_null()) { | 503 if (!start_of_run.is_null()) { |
504 queue_duration = start_of_run - time_posted; | 504 queue_duration = start_of_run - time_posted; |
505 if (!end_of_run.is_null()) | 505 if (!end_of_run.is_null()) |
506 run_duration = end_of_run - start_of_run; | 506 run_duration = end_of_run - start_of_run; |
507 } | 507 } |
508 current_thread_data->TallyADeath(*birth, queue_duration, run_duration); | 508 current_thread_data->TallyADeath(*birth, queue_duration, run_duration); |
509 } | 509 } |
510 | 510 |
511 // static | 511 // static |
| 512 void ThreadData::TallyRunInAScopedRegionIfTracking( |
| 513 const Births* birth, |
| 514 const TrackedTime& start_of_run, |
| 515 const TrackedTime& end_of_run) { |
| 516 if (!kTrackAllTaskObjects) |
| 517 return; // Not compiled in. |
| 518 |
| 519 // Even if we have been DEACTIVATED, we will process any pending births so |
| 520 // that our data structures (which counted the outstanding births) remain |
| 521 // consistent. |
| 522 if (!birth) |
| 523 return; |
| 524 |
| 525 ThreadData* current_thread_data = Get(); |
| 526 if (!current_thread_data) |
| 527 return; |
| 528 |
| 529 Duration queue_duration = Duration(); |
| 530 Duration run_duration = end_of_run - start_of_run; |
| 531 current_thread_data->TallyADeath(*birth, queue_duration, run_duration); |
| 532 } |
| 533 |
| 534 |
| 535 |
| 536 // static |
512 ThreadData* ThreadData::first() { | 537 ThreadData* ThreadData::first() { |
513 base::AutoLock lock(*list_lock_); | 538 base::AutoLock lock(*list_lock_); |
514 return all_thread_data_list_head_; | 539 return all_thread_data_list_head_; |
515 } | 540 } |
516 | 541 |
517 // This may be called from another thread. | 542 // This may be called from another thread. |
518 void ThreadData::SnapshotBirthMap(BirthMap *output) const { | 543 void ThreadData::SnapshotBirthMap(BirthMap *output) const { |
519 base::AutoLock lock(lock_); | 544 base::AutoLock lock(lock_); |
520 for (BirthMap::const_iterator it = birth_map_.begin(); | 545 for (BirthMap::const_iterator it = birth_map_.begin(); |
521 it != birth_map_.end(); ++it) | 546 it != birth_map_.end(); ++it) |
(...skipping 700 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1222 (combined_selectors_ & BIRTH_THREAD) ? "*" : | 1247 (combined_selectors_ & BIRTH_THREAD) ? "*" : |
1223 sample.birth().birth_thread()->thread_name().c_str(), | 1248 sample.birth().birth_thread()->thread_name().c_str(), |
1224 (combined_selectors_ & DEATH_THREAD) ? "*" : | 1249 (combined_selectors_ & DEATH_THREAD) ? "*" : |
1225 sample.DeathThreadName().c_str()); | 1250 sample.DeathThreadName().c_str()); |
1226 sample.birth().location().Write(!(combined_selectors_ & BIRTH_FILE), | 1251 sample.birth().location().Write(!(combined_selectors_ & BIRTH_FILE), |
1227 !(combined_selectors_ & BIRTH_FUNCTION), | 1252 !(combined_selectors_ & BIRTH_FUNCTION), |
1228 output); | 1253 output); |
1229 } | 1254 } |
1230 | 1255 |
1231 } // namespace tracked_objects | 1256 } // namespace tracked_objects |
OLD | NEW |