| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 void Comparator::Clear() { | 736 void Comparator::Clear() { |
| 737 if (tiebreaker_) { | 737 if (tiebreaker_) { |
| 738 tiebreaker_->Clear(); | 738 tiebreaker_->Clear(); |
| 739 delete tiebreaker_; | 739 delete tiebreaker_; |
| 740 tiebreaker_ = NULL; | 740 tiebreaker_ = NULL; |
| 741 } | 741 } |
| 742 use_tiebreaker_for_sort_only_ = false; | 742 use_tiebreaker_for_sort_only_ = false; |
| 743 selector_ = NIL; | 743 selector_ = NIL; |
| 744 } | 744 } |
| 745 | 745 |
| 746 void Comparator::Sort(DataCollector::Collection* collection) const { | |
| 747 std::sort(collection->begin(), collection->end(), *this); | |
| 748 } | |
| 749 | |
| 750 | |
| 751 bool Comparator::operator()(const Snapshot& left, | 746 bool Comparator::operator()(const Snapshot& left, |
| 752 const Snapshot& right) const { | 747 const Snapshot& right) const { |
| 753 switch (selector_) { | 748 switch (selector_) { |
| 754 case BIRTH_THREAD: | 749 case BIRTH_THREAD: |
| 755 if (left.birth_thread() != right.birth_thread() && | 750 if (left.birth_thread() != right.birth_thread() && |
| 756 left.birth_thread()->ThreadName() != | 751 left.birth_thread()->ThreadName() != |
| 757 right.birth_thread()->ThreadName()) | 752 right.birth_thread()->ThreadName()) |
| 758 return left.birth_thread()->ThreadName() < | 753 return left.birth_thread()->ThreadName() < |
| 759 right.birth_thread()->ThreadName(); | 754 right.birth_thread()->ThreadName(); |
| 760 break; | 755 break; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 809 break; | 804 break; |
| 810 | 805 |
| 811 default: | 806 default: |
| 812 break; | 807 break; |
| 813 } | 808 } |
| 814 if (tiebreaker_) | 809 if (tiebreaker_) |
| 815 return tiebreaker_->operator()(left, right); | 810 return tiebreaker_->operator()(left, right); |
| 816 return false; | 811 return false; |
| 817 } | 812 } |
| 818 | 813 |
| 814 void Comparator::Sort(DataCollector::Collection* collection) const { |
| 815 std::sort(collection->begin(), collection->end(), *this); |
| 816 } |
| 817 |
| 819 bool Comparator::Equivalent(const Snapshot& left, | 818 bool Comparator::Equivalent(const Snapshot& left, |
| 820 const Snapshot& right) const { | 819 const Snapshot& right) const { |
| 821 switch (selector_) { | 820 switch (selector_) { |
| 822 case BIRTH_THREAD: | 821 case BIRTH_THREAD: |
| 823 if (left.birth_thread() != right.birth_thread() && | 822 if (left.birth_thread() != right.birth_thread() && |
| 824 left.birth_thread()->ThreadName() != | 823 left.birth_thread()->ThreadName() != |
| 825 right.birth_thread()->ThreadName()) | 824 right.birth_thread()->ThreadName()) |
| 826 return false; | 825 return false; |
| 827 break; | 826 break; |
| 828 | 827 |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 (combined_selectors_ & BIRTH_THREAD) ? "*" : | 1048 (combined_selectors_ & BIRTH_THREAD) ? "*" : |
| 1050 sample.birth().birth_thread()->ThreadName().c_str(), | 1049 sample.birth().birth_thread()->ThreadName().c_str(), |
| 1051 (combined_selectors_ & DEATH_THREAD) ? "*" : | 1050 (combined_selectors_ & DEATH_THREAD) ? "*" : |
| 1052 sample.DeathThreadName().c_str()); | 1051 sample.DeathThreadName().c_str()); |
| 1053 sample.birth().location().Write(!(combined_selectors_ & BIRTH_FILE), | 1052 sample.birth().location().Write(!(combined_selectors_ & BIRTH_FILE), |
| 1054 !(combined_selectors_ & BIRTH_FUNCTION), | 1053 !(combined_selectors_ & BIRTH_FUNCTION), |
| 1055 output); | 1054 output); |
| 1056 } | 1055 } |
| 1057 | 1056 |
| 1058 } // namespace tracked_objects | 1057 } // namespace tracked_objects |
| OLD | NEW |