Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(829)

Side by Side Diff: base/tracked_objects.cc

Issue 9348028: Revert 120789 - Propogate status setting for profiler to track parents (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/tracked_objects.h ('k') | base/tracked_objects_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
OLDNEW
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 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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 DCHECK_EQ(parent_stack_.top(), &birth); 386 DCHECK_EQ(parent_stack_.top(), &birth);
387 parent_stack_.pop(); 387 parent_stack_.pop();
388 } 388 }
389 } 389 }
390 390
391 // static 391 // static
392 Births* ThreadData::TallyABirthIfActive(const Location& location) { 392 Births* ThreadData::TallyABirthIfActive(const Location& location) {
393 if (!kTrackAllTaskObjects) 393 if (!kTrackAllTaskObjects)
394 return NULL; // Not compiled in. 394 return NULL; // Not compiled in.
395 395
396 if (!TrackingStatus()) 396 if (!tracking_status())
397 return NULL; 397 return NULL;
398 ThreadData* current_thread_data = Get(); 398 ThreadData* current_thread_data = Get();
399 if (!current_thread_data) 399 if (!current_thread_data)
400 return NULL; 400 return NULL;
401 return current_thread_data->TallyABirth(location); 401 return current_thread_data->TallyABirth(location);
402 } 402 }
403 403
404 // static 404 // static
405 void ThreadData::TallyRunOnNamedThreadIfTracking( 405 void ThreadData::TallyRunOnNamedThreadIfTracking(
406 const base::TrackingInfo& completed_task, 406 const base::TrackingInfo& completed_task,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 // we get the lock earlier in this method. 615 // we get the lock earlier in this method.
616 status_ = kInitialStartupState; 616 status_ = kInitialStartupState;
617 if (!kTrackParentChildLinks && 617 if (!kTrackParentChildLinks &&
618 kInitialStartupState == PROFILING_CHILDREN_ACTIVE) 618 kInitialStartupState == PROFILING_CHILDREN_ACTIVE)
619 status_ = PROFILING_ACTIVE; 619 status_ = PROFILING_ACTIVE;
620 DCHECK(status_ != UNINITIALIZED); 620 DCHECK(status_ != UNINITIALIZED);
621 return true; 621 return true;
622 } 622 }
623 623
624 // static 624 // static
625 bool ThreadData::InitializeAndSetTrackingStatus(Status status) { 625 bool ThreadData::InitializeAndSetTrackingStatus(bool status) {
626 DCHECK_GE(status, DEACTIVATED);
627 DCHECK_LE(status, PROFILING_CHILDREN_ACTIVE);
628
629 if (!Initialize()) // No-op if already initialized. 626 if (!Initialize()) // No-op if already initialized.
630 return false; // Not compiled in. 627 return false; // Not compiled in.
631 628
632 if (!kTrackParentChildLinks && status > DEACTIVATED) 629 if (!status) {
633 status = PROFILING_ACTIVE; 630 status_ = DEACTIVATED;
634 status_ = status; 631 } else {
632 if (kTrackParentChildLinks)
633 status_ = PROFILING_CHILDREN_ACTIVE;
634 else
635 status_ = PROFILING_ACTIVE;
636 }
635 return true; 637 return true;
636 } 638 }
637 639
638 // static 640 // static
639 ThreadData::Status ThreadData::status() { 641 bool ThreadData::tracking_status() {
640 return status_;
641 }
642
643 // static
644 bool ThreadData::TrackingStatus() {
645 return status_ > DEACTIVATED; 642 return status_ > DEACTIVATED;
646 } 643 }
647 644
648 // static 645 // static
649 bool ThreadData::TrackingParentChildStatus() { 646 bool ThreadData::tracking_parent_child_status() {
650 return status_ >= PROFILING_CHILDREN_ACTIVE; 647 return status_ >= PROFILING_CHILDREN_ACTIVE;
651 } 648 }
652 649
653 // static 650 // static
654 TrackedTime ThreadData::NowForStartOfRun(const Births* parent) { 651 TrackedTime ThreadData::NowForStartOfRun(const Births* parent) {
655 if (kTrackParentChildLinks && parent && status_ > PROFILING_ACTIVE) { 652 if (kTrackParentChildLinks && parent && status_ > PROFILING_ACTIVE) {
656 ThreadData* current_thread_data = Get(); 653 ThreadData* current_thread_data = Get();
657 if (current_thread_data) 654 if (current_thread_data)
658 current_thread_data->parent_stack_.push(parent); 655 current_thread_data->parent_stack_.push(parent);
659 } 656 }
660 return Now(); 657 return Now();
661 } 658 }
662 659
663 // static 660 // static
664 TrackedTime ThreadData::NowForEndOfRun() { 661 TrackedTime ThreadData::NowForEndOfRun() {
665 return Now(); 662 return Now();
666 } 663 }
667 664
668 // static 665 // static
669 TrackedTime ThreadData::Now() { 666 TrackedTime ThreadData::Now() {
670 if (kTrackAllTaskObjects && TrackingStatus()) 667 if (kTrackAllTaskObjects && tracking_status())
671 return TrackedTime::Now(); 668 return TrackedTime::Now();
672 return TrackedTime(); // Super fast when disabled, or not compiled. 669 return TrackedTime(); // Super fast when disabled, or not compiled.
673 } 670 }
674 671
675 // static 672 // static
676 void ThreadData::EnsureCleanupWasCalled(int major_threads_shutdown_count) { 673 void ThreadData::EnsureCleanupWasCalled(int major_threads_shutdown_count) {
677 base::AutoLock lock(*list_lock_.Pointer()); 674 base::AutoLock lock(*list_lock_.Pointer());
678 if (worker_thread_data_creation_count_ == 0) 675 if (worker_thread_data_creation_count_ == 0)
679 return; // We haven't really run much, and couldn't have leaked. 676 return; // We haven't really run much, and couldn't have leaked.
680 // Verify that we've at least shutdown/cleanup the major namesd threads. The 677 // Verify that we've at least shutdown/cleanup the major namesd threads. The
681 // caller should tell us how many thread shutdowns should have taken place by 678 // caller should tell us how many thread shutdowns should have taken place by
682 // now. 679 // now.
683 return; // TODO(jar): until this is working on XP, don't run the real test. 680 return; // TODO(jar): until this is working on XP, don't run the real test.
684 CHECK_GT(cleanup_count_, major_threads_shutdown_count); 681 CHECK_GT(cleanup_count_, major_threads_shutdown_count);
685 } 682 }
686 683
687 // static 684 // static
688 void ThreadData::ShutdownSingleThreadedCleanup(bool leak) { 685 void ThreadData::ShutdownSingleThreadedCleanup(bool leak) {
689 // This is only called from test code, where we need to cleanup so that 686 // This is only called from test code, where we need to cleanup so that
690 // additional tests can be run. 687 // additional tests can be run.
691 // We must be single threaded... but be careful anyway. 688 // We must be single threaded... but be careful anyway.
692 if (!InitializeAndSetTrackingStatus(DEACTIVATED)) 689 if (!InitializeAndSetTrackingStatus(false))
693 return; 690 return;
694 ThreadData* thread_data_list; 691 ThreadData* thread_data_list;
695 { 692 {
696 base::AutoLock lock(*list_lock_.Pointer()); 693 base::AutoLock lock(*list_lock_.Pointer());
697 thread_data_list = all_thread_data_list_head_; 694 thread_data_list = all_thread_data_list_head_;
698 all_thread_data_list_head_ = NULL; 695 all_thread_data_list_head_ = NULL;
699 ++incarnation_counter_; 696 ++incarnation_counter_;
700 // To be clean, break apart the retired worker list (though we leak them). 697 // To be clean, break apart the retired worker list (though we leak them).
701 while (first_retired_worker_) { 698 while (first_retired_worker_) {
702 ThreadData* worker = first_retired_worker_; 699 ThreadData* worker = first_retired_worker_;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 ++it) { 827 ++it) {
831 base::DictionaryValue* parent_child = new base::DictionaryValue; 828 base::DictionaryValue* parent_child = new base::DictionaryValue;
832 it->first->ToValue("parent", parent_child); 829 it->first->ToValue("parent", parent_child);
833 it->second->ToValue("child", parent_child); 830 it->second->ToValue("child", parent_child);
834 descendants->Append(parent_child); 831 descendants->Append(parent_child);
835 } 832 }
836 dictionary->Set("descendants", descendants); 833 dictionary->Set("descendants", descendants);
837 } 834 }
838 835
839 } // namespace tracked_objects 836 } // namespace tracked_objects
OLDNEW
« no previous file with comments | « base/tracked_objects.h ('k') | base/tracked_objects_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698