Chromium Code Reviews| 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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 664 } | 664 } |
| 665 | 665 |
| 666 void Aggregation::Write(std::string* output) const { | 666 void Aggregation::Write(std::string* output) const { |
| 667 if (locations_.size() == 1) { | 667 if (locations_.size() == 1) { |
| 668 locations_.begin()->first.Write(true, true, output); | 668 locations_.begin()->first.Write(true, true, output); |
| 669 } else { | 669 } else { |
| 670 base::StringAppendF(output, "%" PRIuS " Locations. ", locations_.size()); | 670 base::StringAppendF(output, "%" PRIuS " Locations. ", locations_.size()); |
| 671 if (birth_files_.size() > 1) { | 671 if (birth_files_.size() > 1) { |
| 672 base::StringAppendF(output, "%" PRIuS " Files. ", birth_files_.size()); | 672 base::StringAppendF(output, "%" PRIuS " Files. ", birth_files_.size()); |
| 673 } else { | 673 } else { |
| 674 base::StringAppendF(output, "All born in %s. ", | 674 output->append("All born in "); |
| 675 birth_files_.begin()->first.c_str()); | 675 birth_files_.begin()->first.AppendToString(output); |
| 676 output->append(". "); | |
| 676 } | 677 } |
| 677 } | 678 } |
| 678 | 679 |
| 679 if (birth_threads_.size() > 1) { | 680 if (birth_threads_.size() > 1) { |
| 680 base::StringAppendF(output, "%" PRIuS " BirthingThreads. ", | 681 base::StringAppendF(output, "%" PRIuS " BirthingThreads. ", |
| 681 birth_threads_.size()); | 682 birth_threads_.size()); |
| 682 } else { | 683 } else { |
| 683 base::StringAppendF(output, "All born on %s. ", | 684 base::StringAppendF(output, "All born on %s. ", |
| 684 birth_threads_.begin()->first->ThreadName().c_str()); | 685 birth_threads_.begin()->first->ThreadName().c_str()); |
| 685 } | 686 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 748 if (!left.death_thread()) | 749 if (!left.death_thread()) |
| 749 return true; | 750 return true; |
| 750 if (!right.death_thread()) | 751 if (!right.death_thread()) |
| 751 return false; | 752 return false; |
| 752 return left.DeathThreadName() < | 753 return left.DeathThreadName() < |
| 753 right.DeathThreadName(); | 754 right.DeathThreadName(); |
| 754 } | 755 } |
| 755 break; | 756 break; |
| 756 | 757 |
| 757 case BIRTH_FILE: | 758 case BIRTH_FILE: |
| 758 if (left.location().file_name() != right.location().file_name()) { | 759 { |
| 759 int comp = strcmp(left.location().file_name(), | 760 base::StringPiece left_file = left.location().file_name(); |
| 760 right.location().file_name()); | 761 base::StringPiece right_file = right.location().file_name(); |
| 761 if (comp) | 762 if (left_file != right_file) |
| 762 return 0 > comp; | 763 return left_file < right_file; |
| 763 } | 764 } |
| 764 break; | 765 break; |
| 765 | 766 |
| 766 case BIRTH_FUNCTION: | 767 case BIRTH_FUNCTION: |
| 767 if (left.location().function_name() != right.location().function_name()) { | 768 { |
| 768 int comp = strcmp(left.location().function_name(), | 769 base::StringPiece left_function = left.location().function_name(); |
| 769 right.location().function_name()); | 770 base::StringPiece right_function = right.location().function_name(); |
| 770 if (comp) | 771 if (left_function != right_function) |
| 771 return 0 > comp; | 772 return left_function < right_function; |
| 772 } | 773 } |
| 773 break; | 774 break; |
| 774 | 775 |
| 775 case BIRTH_LINE: | 776 case BIRTH_LINE: |
| 776 if (left.location().line_number() != right.location().line_number()) | 777 { |
| 777 return left.location().line_number() < | 778 int left_line = left.location().line_number(); |
| 778 right.location().line_number(); | 779 int right_line = right.location().line_number(); |
| 780 if (left_line != right_line) | |
| 781 return left_line < right_line; | |
| 782 } | |
| 779 break; | 783 break; |
| 780 | 784 |
| 781 case COUNT: | 785 case COUNT: |
| 782 if (left.count() != right.count()) | 786 if (left.count() != right.count()) |
| 783 return left.count() > right.count(); // Sort large at front of vector. | 787 return left.count() > right.count(); // Sort large at front of vector. |
| 784 break; | 788 break; |
| 785 | 789 |
| 786 case AVERAGE_DURATION: | 790 case AVERAGE_DURATION: |
| 787 if (!left.count() || !right.count()) | 791 if (!left.count() || !right.count()) |
| 788 break; | 792 break; |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 812 return false; | 816 return false; |
| 813 break; | 817 break; |
| 814 | 818 |
| 815 case DEATH_THREAD: | 819 case DEATH_THREAD: |
| 816 if (left.death_thread() != right.death_thread() && | 820 if (left.death_thread() != right.death_thread() && |
| 817 left.DeathThreadName() != right.DeathThreadName()) | 821 left.DeathThreadName() != right.DeathThreadName()) |
| 818 return false; | 822 return false; |
| 819 break; | 823 break; |
| 820 | 824 |
| 821 case BIRTH_FILE: | 825 case BIRTH_FILE: |
| 822 if (left.location().file_name() != right.location().file_name()) { | 826 if (left.location().file_name() != right.location().file_name()) |
| 823 int comp = strcmp(left.location().file_name(), | 827 return false; |
| 824 right.location().file_name()); | |
| 825 if (comp) | |
| 826 return false; | |
| 827 } | |
| 828 break; | 828 break; |
| 829 | 829 |
| 830 case BIRTH_FUNCTION: | 830 case BIRTH_FUNCTION: |
| 831 if (left.location().function_name() != right.location().function_name()) { | 831 if (left.location().function_name() != right.location().function_name()) |
| 832 int comp = strcmp(left.location().function_name(), | 832 return false; |
| 833 right.location().function_name()); | |
| 834 if (comp) | |
| 835 return false; | |
| 836 } | |
| 837 break; | 833 break; |
| 838 | 834 |
| 839 case COUNT: | 835 case COUNT: |
| 840 if (left.count() != right.count()) | 836 if (left.count() != right.count()) |
| 841 return false; | 837 return false; |
| 842 break; | 838 break; |
| 843 | 839 |
| 844 case AVERAGE_DURATION: | 840 case AVERAGE_DURATION: |
| 845 if (left.life_duration() != right.life_duration()) | 841 if (left.life_duration() != right.life_duration()) |
| 846 return false; | 842 return false; |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 862 std::string::npos) | 858 std::string::npos) |
| 863 return false; | 859 return false; |
| 864 break; | 860 break; |
| 865 | 861 |
| 866 case DEATH_THREAD: | 862 case DEATH_THREAD: |
| 867 if (sample.DeathThreadName().find(required_) == std::string::npos) | 863 if (sample.DeathThreadName().find(required_) == std::string::npos) |
| 868 return false; | 864 return false; |
| 869 break; | 865 break; |
| 870 | 866 |
| 871 case BIRTH_FILE: | 867 case BIRTH_FILE: |
| 872 if (!strstr(sample.location().file_name(), required_.c_str())) | 868 if (sample.location().file_name().find(required_.c_str()) == |
|
jar (doing other things)
2011/09/01 18:17:51
Since you have transition to passing SringPieces o
jbates
2011/09/01 23:01:52
Done.
| |
| 869 base::StringPiece::npos) | |
| 873 return false; | 870 return false; |
| 874 break; | 871 break; |
| 875 | 872 |
| 876 case BIRTH_FUNCTION: | 873 case BIRTH_FUNCTION: |
| 877 if (!strstr(sample.location().function_name(), required_.c_str())) | 874 if (sample.location().function_name().find(required_.c_str()) == |
| 875 base::StringPiece::npos) | |
| 878 return false; | 876 return false; |
| 879 break; | 877 break; |
| 880 | 878 |
| 881 default: | 879 default: |
| 882 break; | 880 break; |
| 883 } | 881 } |
| 884 } | 882 } |
| 885 if (tiebreaker_ && !use_tiebreaker_for_sort_only_) | 883 if (tiebreaker_ && !use_tiebreaker_for_sort_only_) |
| 886 return tiebreaker_->Acceptable(sample); | 884 return tiebreaker_->Acceptable(sample); |
| 887 return true; | 885 return true; |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1000 if (sample.death_thread()) { | 998 if (sample.death_thread()) { |
| 1001 base::StringAppendF(output, "All deleted on %s ", | 999 base::StringAppendF(output, "All deleted on %s ", |
| 1002 sample.DeathThreadName().c_str()); | 1000 sample.DeathThreadName().c_str()); |
| 1003 } else { | 1001 } else { |
| 1004 output->append("All still alive "); | 1002 output->append("All still alive "); |
| 1005 } | 1003 } |
| 1006 wrote_data = true; | 1004 wrote_data = true; |
| 1007 break; | 1005 break; |
| 1008 | 1006 |
| 1009 case BIRTH_FILE: | 1007 case BIRTH_FILE: |
| 1010 base::StringAppendF(output, "All born in %s ", | 1008 output->append("All born in "); |
| 1011 sample.location().file_name()); | 1009 sample.location().file_name().AppendToString(output); |
| 1010 output->append(" "); | |
| 1012 break; | 1011 break; |
| 1013 | 1012 |
| 1014 case BIRTH_FUNCTION: | 1013 case BIRTH_FUNCTION: |
| 1015 output->append("All born in "); | 1014 output->append("All born in "); |
| 1016 sample.location().WriteFunctionName(output); | 1015 sample.location().WriteFunctionName(output); |
| 1017 output->push_back(' '); | 1016 output->push_back(' '); |
| 1018 break; | 1017 break; |
| 1019 | 1018 |
| 1020 default: | 1019 default: |
| 1021 break; | 1020 break; |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1035 (combined_selectors_ & BIRTH_THREAD) ? "*" : | 1034 (combined_selectors_ & BIRTH_THREAD) ? "*" : |
| 1036 sample.birth().birth_thread()->ThreadName().c_str(), | 1035 sample.birth().birth_thread()->ThreadName().c_str(), |
| 1037 (combined_selectors_ & DEATH_THREAD) ? "*" : | 1036 (combined_selectors_ & DEATH_THREAD) ? "*" : |
| 1038 sample.DeathThreadName().c_str()); | 1037 sample.DeathThreadName().c_str()); |
| 1039 sample.birth().location().Write(!(combined_selectors_ & BIRTH_FILE), | 1038 sample.birth().location().Write(!(combined_selectors_ & BIRTH_FILE), |
| 1040 !(combined_selectors_ & BIRTH_FUNCTION), | 1039 !(combined_selectors_ & BIRTH_FUNCTION), |
| 1041 output); | 1040 output); |
| 1042 } | 1041 } |
| 1043 | 1042 |
| 1044 } // namespace tracked_objects | 1043 } // namespace tracked_objects |
| OLD | NEW |