OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * Copyright (C) 2012 Intel Inc. All rights reserved. | 3 * Copyright (C) 2012 Intel Inc. All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 views.mainViews = [new WebInspector.TimelineView(this, this._mod
el, this._presentationModel, null)]; | 229 views.mainViews = [new WebInspector.TimelineView(this, this._mod
el, this._presentationModel, null)]; |
230 break; | 230 break; |
231 case WebInspector.TimelinePanel.Mode.Frames: | 231 case WebInspector.TimelinePanel.Mode.Frames: |
232 views.overviewView = new WebInspector.TimelineFrameOverview(this
._model, this.frameModel()); | 232 views.overviewView = new WebInspector.TimelineFrameOverview(this
._model, this.frameModel()); |
233 views.mainViews = [new WebInspector.TimelineView(this, this._mod
el, this._presentationModel, this.frameModel())]; | 233 views.mainViews = [new WebInspector.TimelineView(this, this._mod
el, this._presentationModel, this.frameModel())]; |
234 break; | 234 break; |
235 case WebInspector.TimelinePanel.Mode.Memory: | 235 case WebInspector.TimelinePanel.Mode.Memory: |
236 views.overviewView = new WebInspector.TimelineMemoryOverview(thi
s._model); | 236 views.overviewView = new WebInspector.TimelineMemoryOverview(thi
s._model); |
237 var timelineView = new WebInspector.TimelineView(this, this._mod
el, this._presentationModel, null); | 237 var timelineView = new WebInspector.TimelineView(this, this._mod
el, this._presentationModel, null); |
238 views.mainViews = [timelineView]; | 238 views.mainViews = [timelineView]; |
239 var memoryStatistics = new WebInspector.CountersGraph(this, this
._presentationModel); | 239 var memoryStatistics = new WebInspector.CountersGraph(this, this
._model); |
240 views.mainViews.push(memoryStatistics); | 240 views.mainViews.push(memoryStatistics); |
241 break; | 241 break; |
242 case WebInspector.TimelinePanel.Mode.FlameChart: | 242 case WebInspector.TimelinePanel.Mode.FlameChart: |
243 views.overviewView = new WebInspector.TimelineFrameOverview(this
._model, this.frameModel()); | 243 views.overviewView = new WebInspector.TimelineFrameOverview(this
._model, this.frameModel()); |
244 views.mainViews = [ | 244 views.mainViews = [ |
245 new WebInspector.TimelineFlameChart(this, this._model, this.
frameModel(), true), | 245 new WebInspector.TimelineFlameChart(this, this._model, this.
frameModel(), true), |
246 new WebInspector.TimelineFlameChart(this, this._model, this.
frameModel(), false) | 246 new WebInspector.TimelineFlameChart(this, this._model, this.
frameModel(), false) |
247 ]; | 247 ]; |
248 break; | 248 break; |
249 default: | 249 default: |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 } | 353 } |
354 return this._filterBar; | 354 return this._filterBar; |
355 }, | 355 }, |
356 | 356 |
357 _textFilterChanged: function(event) | 357 _textFilterChanged: function(event) |
358 { | 358 { |
359 var searchQuery = this._filters._textFilterUI.value(); | 359 var searchQuery = this._filters._textFilterUI.value(); |
360 this._presentationModel.setSearchFilter(null); | 360 this._presentationModel.setSearchFilter(null); |
361 delete this._searchFilter; | 361 delete this._searchFilter; |
362 | 362 |
363 function cleanRecord(record) | |
364 { | |
365 delete record.clicked; | |
366 } | |
367 WebInspector.TimelinePresentationModel.forAllRecords(this._presentationM
odel.rootRecord().children, cleanRecord); | |
368 | |
369 this.searchCanceled(); | 363 this.searchCanceled(); |
370 if (searchQuery) { | 364 if (searchQuery) { |
371 this._searchFilter = new WebInspector.TimelineSearchFilter(createPla
inTextSearchRegex(searchQuery, "i")); | 365 this._searchFilter = new WebInspector.TimelineSearchFilter(createPla
inTextSearchRegex(searchQuery, "i")); |
372 this._presentationModel.setSearchFilter(this._searchFilter); | 366 this._presentationModel.setSearchFilter(this._searchFilter); |
373 } | 367 } |
374 this._refreshViews(); | 368 this._refreshViews(); |
375 }, | 369 }, |
376 | 370 |
377 _durationFilterChanged: function() | 371 _durationFilterChanged: function() |
378 { | 372 { |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 }, | 595 }, |
602 | 596 |
603 _onRecordingStopped: function() | 597 _onRecordingStopped: function() |
604 { | 598 { |
605 this.toggleTimelineButton.title = WebInspector.UIString("Record"); | 599 this.toggleTimelineButton.title = WebInspector.UIString("Record"); |
606 this.toggleTimelineButton.toggled = false; | 600 this.toggleTimelineButton.toggled = false; |
607 }, | 601 }, |
608 | 602 |
609 _onRecordAdded: function(event) | 603 _onRecordAdded: function(event) |
610 { | 604 { |
611 this._addRecord(/** @type {!TimelineAgent.TimelineEvent} */(event.data))
; | 605 this._addRecord(/** @type {!WebInspector.TimelineModel.Record} */(event.
data)); |
612 }, | 606 }, |
613 | 607 |
614 /** | 608 /** |
615 * @param {!TimelineAgent.TimelineEvent} record | 609 * @param {!WebInspector.TimelineModel.Record} record |
616 */ | 610 */ |
617 _addRecord: function(record) | 611 _addRecord: function(record) |
618 { | 612 { |
619 var presentationRecords = this._presentationModel.addRecord(record); | 613 this._presentationModel.addRecord(record); |
620 | |
621 if (this._frameModel) | 614 if (this._frameModel) |
622 this._frameModel.addRecord(record); | 615 this._frameModel.addRecord(record); |
623 for (var i = 0; i < this._currentViews.length; ++i) | 616 for (var i = 0; i < this._currentViews.length; ++i) |
624 this._currentViews[i].addRecord(record, presentationRecords); | 617 this._currentViews[i].addRecord(record); |
625 | |
626 this._overviewPane.addRecord(record); | 618 this._overviewPane.addRecord(record); |
627 | 619 |
628 this._updateSearchHighlight(false, true); | 620 this._updateSearchHighlight(false, true); |
629 }, | 621 }, |
630 | 622 |
631 /** | 623 /** |
632 * @param {!WebInspector.Event} event | 624 * @param {!WebInspector.Event} event |
633 */ | 625 */ |
634 _willReloadPage: function(event) | 626 _willReloadPage: function(event) |
635 { | 627 { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 | 693 |
702 _updateSearchResults: function(shouldJump) | 694 _updateSearchResults: function(shouldJump) |
703 { | 695 { |
704 var searchRegExp = this._searchRegExp; | 696 var searchRegExp = this._searchRegExp; |
705 if (!searchRegExp) | 697 if (!searchRegExp) |
706 return; | 698 return; |
707 | 699 |
708 var matches = []; | 700 var matches = []; |
709 var presentationModel = this._presentationModel; | 701 var presentationModel = this._presentationModel; |
710 | 702 |
| 703 /** |
| 704 * @param {!WebInspector.TimelineModel.Record} record |
| 705 */ |
711 function processRecord(record) | 706 function processRecord(record) |
712 { | 707 { |
713 if (presentationModel.isVisible(record) && record.testContentMatchin
g(searchRegExp)) | 708 if (presentationModel.isVisible(record) && record.testContentMatchin
g(searchRegExp)) |
714 matches.push(record); | 709 matches.push(record); |
715 return false; | 710 return false; |
716 } | 711 } |
717 WebInspector.TimelinePresentationModel.forAllRecords(presentationModel.r
ootRecord().children, processRecord); | 712 this._model.forAllRecords(processRecord); |
718 | 713 |
719 var matchesCount = matches.length; | 714 var matchesCount = matches.length; |
720 if (matchesCount) { | 715 if (matchesCount) { |
721 this._searchResults = matches; | 716 this._searchResults = matches; |
722 this._searchableView.updateSearchMatchesCount(matchesCount); | 717 this._searchableView.updateSearchMatchesCount(matchesCount); |
723 | 718 |
724 var selectedIndex = matches.indexOf(this._selectedSearchResult); | 719 var selectedIndex = matches.indexOf(this._selectedSearchResult); |
725 if (shouldJump && selectedIndex === -1) | 720 if (shouldJump && selectedIndex === -1) |
726 selectedIndex = 0; | 721 selectedIndex = 0; |
727 this._selectSearchResult(selectedIndex); | 722 this._selectSearchResult(selectedIndex); |
(...skipping 27 matching lines...) Expand all Loading... |
755 var startTime = this._windowStartTime; | 750 var startTime = this._windowStartTime; |
756 var endTime = this._windowEndTime; | 751 var endTime = this._windowEndTime; |
757 // Return early in case 0 selection window. | 752 // Return early in case 0 selection window. |
758 if (startTime < 0) | 753 if (startTime < 0) |
759 return; | 754 return; |
760 | 755 |
761 var aggregatedStats = {}; | 756 var aggregatedStats = {}; |
762 | 757 |
763 /** | 758 /** |
764 * @param {number} value | 759 * @param {number} value |
765 * @param {!TimelineAgent.TimelineEvent} task | 760 * @param {!WebInspector.TimelineModel.Record} task |
766 * @return {number} | 761 * @return {number} |
767 */ | 762 */ |
768 function compareEndTime(value, task) | 763 function compareEndTime(value, task) |
769 { | 764 { |
770 return value < task.endTime ? -1 : 1; | 765 return value < task.endTime ? -1 : 1; |
771 } | 766 } |
772 | 767 |
773 /** | 768 /** |
774 * @param {!TimelineAgent.TimelineEvent} rawRecord | 769 * @param {!WebInspector.TimelineModel.Record} record |
775 */ | 770 */ |
776 function aggregateTimeForRecordWithinWindow(rawRecord) | 771 function aggregateTimeForRecordWithinWindow(record) |
777 { | 772 { |
778 if (!rawRecord.endTime || rawRecord.endTime < startTime || rawRecord
.startTime > endTime) | 773 if (!record.endTime || record.endTime < startTime || record.startTim
e > endTime) |
779 return; | 774 return; |
780 | 775 |
781 var childrenTime = 0; | 776 var childrenTime = 0; |
782 var children = rawRecord.children || []; | 777 var children = record.children || []; |
783 for (var i = 0; i < children.length; ++i) { | 778 for (var i = 0; i < children.length; ++i) { |
784 var child = children[i]; | 779 var child = children[i]; |
785 if (!child.endTime || child.endTime < startTime || child.startTi
me > endTime) | 780 if (!child.endTime || child.endTime < startTime || child.startTi
me > endTime) |
786 continue; | 781 continue; |
787 childrenTime += Math.min(endTime, child.endTime) - Math.max(star
tTime, child.startTime); | 782 childrenTime += Math.min(endTime, child.endTime) - Math.max(star
tTime, child.startTime); |
788 aggregateTimeForRecordWithinWindow(child); | 783 aggregateTimeForRecordWithinWindow(child); |
789 } | 784 } |
790 var categoryName = WebInspector.TimelineUIUtils.categoryForRecord(ra
wRecord).name; | 785 var categoryName = WebInspector.TimelineUIUtils.categoryForRecord(re
cord).name; |
791 var ownTime = Math.min(endTime, rawRecord.endTime) - Math.max(startT
ime, rawRecord.startTime) - childrenTime; | 786 var ownTime = Math.min(endTime, record.endTime) - Math.max(startTime
, record.startTime) - childrenTime; |
792 aggregatedStats[categoryName] = (aggregatedStats[categoryName] || 0)
+ ownTime; | 787 aggregatedStats[categoryName] = (aggregatedStats[categoryName] || 0)
+ ownTime; |
793 } | 788 } |
794 | 789 |
795 var mainThreadTasks = this._presentationModel.mainThreadTasks(); | 790 var mainThreadTasks = this._presentationModel.mainThreadTasks(); |
796 var taskIndex = insertionIndexForObjectInListSortedByFunction(startTime,
mainThreadTasks, compareEndTime); | 791 var taskIndex = insertionIndexForObjectInListSortedByFunction(startTime,
mainThreadTasks, compareEndTime); |
797 for (; taskIndex < mainThreadTasks.length; ++taskIndex) { | 792 for (; taskIndex < mainThreadTasks.length; ++taskIndex) { |
798 var task = mainThreadTasks[taskIndex]; | 793 var task = mainThreadTasks[taskIndex]; |
799 if (task.startTime > endTime) | 794 if (task.startTime > endTime) |
800 break; | 795 break; |
801 aggregateTimeForRecordWithinWindow(task); | 796 aggregateTimeForRecordWithinWindow(task); |
802 } | 797 } |
803 | 798 |
804 var aggregatedTotal = 0; | 799 var aggregatedTotal = 0; |
805 for (var categoryName in aggregatedStats) | 800 for (var categoryName in aggregatedStats) |
806 aggregatedTotal += aggregatedStats[categoryName]; | 801 aggregatedTotal += aggregatedStats[categoryName]; |
807 aggregatedStats["idle"] = Math.max(0, endTime - startTime - aggregatedTo
tal); | 802 aggregatedStats["idle"] = Math.max(0, endTime - startTime - aggregatedTo
tal); |
808 | 803 |
809 var fragment = document.createDocumentFragment(); | 804 var fragment = document.createDocumentFragment(); |
810 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(aggre
gatedStats)); | 805 fragment.appendChild(WebInspector.TimelineUIUtils.generatePieChart(aggre
gatedStats)); |
811 var startOffset = startTime - this._model.minimumRecordTime(); | 806 var startOffset = startTime - this._model.minimumRecordTime(); |
812 var endOffset = endTime - this._model.minimumRecordTime(); | 807 var endOffset = endTime - this._model.minimumRecordTime(); |
813 var title = WebInspector.UIString("%s \u2013 %s", Number.millisToString(
startOffset), Number.millisToString(endOffset)); | 808 var title = WebInspector.UIString("%s \u2013 %s", Number.millisToString(
startOffset), Number.millisToString(endOffset)); |
814 this._detailsView.setContent(title, fragment); | 809 this._detailsView.setContent(title, fragment); |
815 }, | 810 }, |
816 | 811 |
817 /** | 812 /** |
818 * @param {?WebInspector.TimelinePresentationModel.Record} record | 813 * @param {?WebInspector.TimelineModel.Record} record |
819 */ | 814 */ |
820 selectRecord: function(record) | 815 selectRecord: function(record) |
821 { | 816 { |
822 this._detailsLinkifier.reset(); | 817 this._detailsLinkifier.reset(); |
823 | 818 |
824 if (!record) { | 819 if (!record) { |
825 this._updateSelectionDetails(); | 820 this._updateSelectionDetails(); |
826 return; | 821 return; |
827 } | 822 } |
828 | 823 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 WebInspector.TimelineModeView = function() | 895 WebInspector.TimelineModeView = function() |
901 { | 896 { |
902 } | 897 } |
903 | 898 |
904 WebInspector.TimelineModeView.prototype = { | 899 WebInspector.TimelineModeView.prototype = { |
905 reset: function() {}, | 900 reset: function() {}, |
906 | 901 |
907 refreshRecords: function() {}, | 902 refreshRecords: function() {}, |
908 | 903 |
909 /** | 904 /** |
910 * @param {!TimelineAgent.TimelineEvent} record | 905 * @param {!WebInspector.TimelineModel.Record} record |
911 * @param {!Array.<!WebInspector.TimelinePresentationModel.Record>} presenta
tionRecords | |
912 */ | 906 */ |
913 addRecord: function(record, presentationRecords) {}, | 907 addRecord: function(record) {}, |
914 | 908 |
915 /** | 909 /** |
916 * @param {?WebInspector.TimelinePresentationModel.Record} record | 910 * @param {?WebInspector.TimelineModel.Record} record |
917 * @param {string=} regex | 911 * @param {string=} regex |
918 * @param {boolean=} selectRecord | 912 * @param {boolean=} selectRecord |
919 */ | 913 */ |
920 highlightSearchResult: function(record, regex, selectRecord) {}, | 914 highlightSearchResult: function(record, regex, selectRecord) {}, |
921 | 915 |
922 /** | 916 /** |
923 * @param {number} startTime | 917 * @param {number} startTime |
924 * @param {number} endTime | 918 * @param {number} endTime |
925 */ | 919 */ |
926 setWindowTimes: function(startTime, endTime) {}, | 920 setWindowTimes: function(startTime, endTime) {}, |
927 | 921 |
928 /** | 922 /** |
929 * @param {number} width | 923 * @param {number} width |
930 */ | 924 */ |
931 setSidebarSize: function(width) {}, | 925 setSidebarSize: function(width) {}, |
932 | 926 |
933 /** | 927 /** |
934 * @param {?WebInspector.TimelinePresentationModel.Record} record | 928 * @param {?WebInspector.TimelineModel.Record} record |
935 */ | 929 */ |
936 setSelectedRecord: function(record) {} | 930 setSelectedRecord: function(record) {} |
937 } | 931 } |
938 | 932 |
939 /** | 933 /** |
940 * @interface | 934 * @interface |
941 */ | 935 */ |
942 WebInspector.TimelineModeViewDelegate = function() {} | 936 WebInspector.TimelineModeViewDelegate = function() {} |
943 | 937 |
944 WebInspector.TimelineModeViewDelegate.prototype = { | 938 WebInspector.TimelineModeViewDelegate.prototype = { |
945 /** | 939 /** |
946 * @param {number} startTime | 940 * @param {number} startTime |
947 * @param {number} endTime | 941 * @param {number} endTime |
948 */ | 942 */ |
949 requestWindowTimes: function(startTime, endTime) {}, | 943 requestWindowTimes: function(startTime, endTime) {}, |
950 | 944 |
951 /** | 945 /** |
952 * @param {?WebInspector.TimelinePresentationModel.Record} record | 946 * @param {?WebInspector.TimelineModel.Record} record |
953 */ | 947 */ |
954 selectRecord: function(record) {} | 948 selectRecord: function(record) {} |
955 } | 949 } |
956 | 950 |
957 /** | 951 /** |
958 * @constructor | 952 * @constructor |
959 * @implements {WebInspector.TimelinePresentationModel.Filter} | 953 * @implements {WebInspector.TimelinePresentationModel.Filter} |
960 */ | 954 */ |
961 WebInspector.TimelineCategoryFilter = function() | 955 WebInspector.TimelineCategoryFilter = function() |
962 { | 956 { |
963 } | 957 } |
964 | 958 |
965 WebInspector.TimelineCategoryFilter.prototype = { | 959 WebInspector.TimelineCategoryFilter.prototype = { |
966 /** | 960 /** |
967 * @param {!WebInspector.TimelinePresentationModel.Record} record | 961 * @param {!WebInspector.TimelineModel.Record} record |
968 * @return {boolean} | 962 * @return {boolean} |
969 */ | 963 */ |
970 accept: function(record) | 964 accept: function(record) |
971 { | 965 { |
972 return !record.category.hidden; | 966 return !record.category.hidden; |
973 } | 967 } |
974 } | 968 } |
975 | 969 |
976 /** | 970 /** |
977 * @constructor | 971 * @constructor |
978 * @implements {WebInspector.TimelinePresentationModel.Filter} | 972 * @implements {WebInspector.TimelinePresentationModel.Filter} |
979 */ | 973 */ |
980 WebInspector.TimelineIsLongFilter = function() | 974 WebInspector.TimelineIsLongFilter = function() |
981 { | 975 { |
982 this._minimumRecordDuration = 0; | 976 this._minimumRecordDuration = 0; |
983 } | 977 } |
984 | 978 |
985 WebInspector.TimelineIsLongFilter.prototype = { | 979 WebInspector.TimelineIsLongFilter.prototype = { |
986 /** | 980 /** |
987 * @param {number} value | 981 * @param {number} value |
988 */ | 982 */ |
989 setMinimumRecordDuration: function(value) | 983 setMinimumRecordDuration: function(value) |
990 { | 984 { |
991 this._minimumRecordDuration = value; | 985 this._minimumRecordDuration = value; |
992 }, | 986 }, |
993 | 987 |
994 /** | 988 /** |
995 * @param {!WebInspector.TimelinePresentationModel.Record} record | 989 * @param {!WebInspector.TimelineModel.Record} record |
996 * @return {boolean} | 990 * @return {boolean} |
997 */ | 991 */ |
998 accept: function(record) | 992 accept: function(record) |
999 { | 993 { |
1000 return this._minimumRecordDuration ? ((record.lastChildEndTime - record.
startTime) >= this._minimumRecordDuration) : true; | 994 return this._minimumRecordDuration ? ((record.lastChildEndTime - record.
startTime) >= this._minimumRecordDuration) : true; |
1001 } | 995 } |
1002 } | 996 } |
1003 | 997 |
1004 /** | 998 /** |
1005 * @param {!RegExp} regExp | 999 * @param {!RegExp} regExp |
1006 * @constructor | 1000 * @constructor |
1007 * @implements {WebInspector.TimelinePresentationModel.Filter} | 1001 * @implements {WebInspector.TimelinePresentationModel.Filter} |
1008 */ | 1002 */ |
1009 WebInspector.TimelineSearchFilter = function(regExp) | 1003 WebInspector.TimelineSearchFilter = function(regExp) |
1010 { | 1004 { |
1011 this._regExp = regExp; | 1005 this._regExp = regExp; |
1012 } | 1006 } |
1013 | 1007 |
1014 WebInspector.TimelineSearchFilter.prototype = { | 1008 WebInspector.TimelineSearchFilter.prototype = { |
1015 /** | 1009 /** |
1016 * @param {!WebInspector.TimelinePresentationModel.Record} record | 1010 * @param {!WebInspector.TimelineModel.Record} record |
1017 * @return {boolean} | 1011 * @return {boolean} |
1018 */ | 1012 */ |
1019 accept: function(record) | 1013 accept: function(record) |
1020 { | 1014 { |
1021 return record.testContentMatching(this._regExp); | 1015 return record.testContentMatching(this._regExp); |
1022 } | 1016 } |
1023 } | 1017 } |
1024 | 1018 |
1025 /** | 1019 /** |
1026 * @constructor | 1020 * @constructor |
(...skipping 11 matching lines...) Expand all Loading... |
1038 this._windowEndTime = Infinity; | 1032 this._windowEndTime = Infinity; |
1039 }, | 1033 }, |
1040 | 1034 |
1041 setWindowTimes: function(windowStartTime, windowEndTime) | 1035 setWindowTimes: function(windowStartTime, windowEndTime) |
1042 { | 1036 { |
1043 this._windowStartTime = windowStartTime; | 1037 this._windowStartTime = windowStartTime; |
1044 this._windowEndTime = windowEndTime; | 1038 this._windowEndTime = windowEndTime; |
1045 }, | 1039 }, |
1046 | 1040 |
1047 /** | 1041 /** |
1048 * @param {!WebInspector.TimelinePresentationModel.Record} record | 1042 * @param {!WebInspector.TimelineModel.Record} record |
1049 * @return {boolean} | 1043 * @return {boolean} |
1050 */ | 1044 */ |
1051 accept: function(record) | 1045 accept: function(record) |
1052 { | 1046 { |
1053 return record.lastChildEndTime >= this._windowStartTime && record.startT
ime <= this._windowEndTime; | 1047 return record.lastChildEndTime >= this._windowStartTime && record.startT
ime <= this._windowEndTime; |
1054 } | 1048 } |
1055 } | 1049 } |
OLD | NEW |