| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 this.registerRequiredCSS("profilesPanel.css"); | 377 this.registerRequiredCSS("profilesPanel.css"); |
| 378 | 378 |
| 379 this.createSidebarViewWithTree(); | 379 this.createSidebarViewWithTree(); |
| 380 | 380 |
| 381 this._searchableView = new WebInspector.SearchableView(this); | 381 this._searchableView = new WebInspector.SearchableView(this); |
| 382 this.splitView.setMainView(this._searchableView); | 382 this.splitView.setMainView(this._searchableView); |
| 383 | 383 |
| 384 this.profilesItemTreeElement = new WebInspector.ProfilesSidebarTreeElement(t
his); | 384 this.profilesItemTreeElement = new WebInspector.ProfilesSidebarTreeElement(t
his); |
| 385 this.sidebarTree.appendChild(this.profilesItemTreeElement); | 385 this.sidebarTree.appendChild(this.profilesItemTreeElement); |
| 386 | 386 |
| 387 this._profileTypesByIdMap = {}; | |
| 388 | |
| 389 this.profileViews = document.createElement("div"); | 387 this.profileViews = document.createElement("div"); |
| 390 this.profileViews.id = "profile-views"; | 388 this.profileViews.id = "profile-views"; |
| 391 this.profileViews.classList.add("vbox"); | 389 this.profileViews.classList.add("vbox"); |
| 392 this._searchableView.element.appendChild(this.profileViews); | 390 this._searchableView.element.appendChild(this.profileViews); |
| 393 | 391 |
| 394 var statusBarContainer = this.splitView.mainElement().createChild("div", "pr
ofiles-status-bar"); | 392 var statusBarContainer = this.splitView.mainElement().createChild("div", "pr
ofiles-status-bar"); |
| 395 this._statusBarElement = statusBarContainer.createChild("div", "status-bar")
; | 393 this._statusBarElement = statusBarContainer.createChild("div", "status-bar")
; |
| 396 | 394 |
| 397 var sidebarTreeBox = this.splitView.sidebarElement().createChild("div", "pro
files-sidebar-tree-box"); | 395 var sidebarTreeBox = this.splitView.sidebarElement().createChild("div", "pro
files-sidebar-tree-box"); |
| 398 sidebarTreeBox.appendChild(this.sidebarTreeElement); | 396 sidebarTreeBox.appendChild(this.sidebarTreeElement); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 /** | 488 /** |
| 491 * @return {!WebInspector.ProfileLauncherView} | 489 * @return {!WebInspector.ProfileLauncherView} |
| 492 */ | 490 */ |
| 493 _createLauncherView: function() | 491 _createLauncherView: function() |
| 494 { | 492 { |
| 495 return new WebInspector.ProfileLauncherView(this); | 493 return new WebInspector.ProfileLauncherView(this); |
| 496 }, | 494 }, |
| 497 | 495 |
| 498 _findProfileTypeByExtension: function(fileName) | 496 _findProfileTypeByExtension: function(fileName) |
| 499 { | 497 { |
| 500 for (var id in this._profileTypesByIdMap) { | 498 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes(); |
| 501 var type = this._profileTypesByIdMap[id]; | 499 for (var i = 0; i < types.length; i++) { |
| 500 var type = types[i]; |
| 502 var extension = type.fileExtension(); | 501 var extension = type.fileExtension(); |
| 503 if (!extension) | 502 if (!extension) |
| 504 continue; | 503 continue; |
| 505 if (fileName.endsWith(type.fileExtension())) | 504 if (fileName.endsWith(type.fileExtension())) |
| 506 return type; | 505 return type; |
| 507 } | 506 } |
| 508 return null; | 507 return null; |
| 509 }, | 508 }, |
| 510 | 509 |
| 511 _registerShortcuts: function() | 510 _registerShortcuts: function() |
| (...skipping 15 matching lines...) Expand all Loading... |
| 527 /** | 526 /** |
| 528 * @param {!File} file | 527 * @param {!File} file |
| 529 */ | 528 */ |
| 530 _loadFromFile: function(file) | 529 _loadFromFile: function(file) |
| 531 { | 530 { |
| 532 this._createFileSelectorElement(); | 531 this._createFileSelectorElement(); |
| 533 | 532 |
| 534 var profileType = this._findProfileTypeByExtension(file.name); | 533 var profileType = this._findProfileTypeByExtension(file.name); |
| 535 if (!profileType) { | 534 if (!profileType) { |
| 536 var extensions = []; | 535 var extensions = []; |
| 537 for (var id in this._profileTypesByIdMap) { | 536 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes()
; |
| 538 var extension = this._profileTypesByIdMap[id].fileExtension(); | 537 for (var i = 0; i < types.length; i++) { |
| 538 var extension = types[i].fileExtension(); |
| 539 if (!extension) | 539 if (!extension) |
| 540 continue; | 540 continue; |
| 541 extensions.push(extension); | 541 extensions.push(extension); |
| 542 } | 542 } |
| 543 WebInspector.log(WebInspector.UIString("Can't load file. Only files
with extensions '%s' can be loaded.", extensions.join("', '"))); | 543 WebInspector.log(WebInspector.UIString("Can't load file. Only files
with extensions '%s' can be loaded.", extensions.join("', '"))); |
| 544 return; | 544 return; |
| 545 } | 545 } |
| 546 | 546 |
| 547 if (!!profileType.profileBeingRecorded()) { | 547 if (!!profileType.profileBeingRecorded()) { |
| 548 WebInspector.log(WebInspector.UIString("Can't load profile when othe
r profile is recording.")); | 548 WebInspector.log(WebInspector.UIString("Can't load profile when othe
r profile is recording.")); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 if (statusBarItems) { | 596 if (statusBarItems) { |
| 597 for (var i = 0; i < statusBarItems.length; ++i) | 597 for (var i = 0; i < statusBarItems.length; ++i) |
| 598 this._profileTypeStatusBarItemsContainer.appendChild(statusBarIt
ems[i]); | 598 this._profileTypeStatusBarItemsContainer.appendChild(statusBarIt
ems[i]); |
| 599 } | 599 } |
| 600 }, | 600 }, |
| 601 | 601 |
| 602 _reset: function() | 602 _reset: function() |
| 603 { | 603 { |
| 604 WebInspector.Panel.prototype.reset.call(this); | 604 WebInspector.Panel.prototype.reset.call(this); |
| 605 | 605 |
| 606 for (var typeId in this._profileTypesByIdMap) | 606 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes(); |
| 607 this._profileTypesByIdMap[typeId]._reset(); | 607 for (var i = 0; i < types.length; i++) |
| 608 types[i]._reset(); |
| 608 | 609 |
| 609 delete this.visibleView; | 610 delete this.visibleView; |
| 610 delete this.currentQuery; | 611 delete this.currentQuery; |
| 611 this.searchCanceled(); | 612 this.searchCanceled(); |
| 612 | 613 |
| 613 this._profileGroups = {}; | 614 this._profileGroups = {}; |
| 614 this.recordButton.toggled = false; | 615 this.recordButton.toggled = false; |
| 615 if (this._selectedProfileType) | 616 if (this._selectedProfileType) |
| 616 this.recordButton.title = this._selectedProfileType.buttonTooltip; | 617 this.recordButton.title = this._selectedProfileType.buttonTooltip; |
| 617 this._launcherView.profileFinished(); | 618 this._launcherView.profileFinished(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 648 _garbageCollectButtonClicked: function() | 649 _garbageCollectButtonClicked: function() |
| 649 { | 650 { |
| 650 HeapProfilerAgent.collectGarbage(); | 651 HeapProfilerAgent.collectGarbage(); |
| 651 }, | 652 }, |
| 652 | 653 |
| 653 /** | 654 /** |
| 654 * @param {!WebInspector.ProfileType} profileType | 655 * @param {!WebInspector.ProfileType} profileType |
| 655 */ | 656 */ |
| 656 _registerProfileType: function(profileType) | 657 _registerProfileType: function(profileType) |
| 657 { | 658 { |
| 658 this._profileTypesByIdMap[profileType.id] = profileType; | |
| 659 this._launcherView.addProfileType(profileType); | 659 this._launcherView.addProfileType(profileType); |
| 660 profileType.treeElement = new WebInspector.SidebarSectionTreeElement(pro
fileType.treeItemTitle, null, true); | 660 profileType.treeElement = new WebInspector.SidebarSectionTreeElement(pro
fileType.treeItemTitle, null, true); |
| 661 profileType.treeElement.hidden = true; | 661 profileType.treeElement.hidden = true; |
| 662 this.sidebarTree.appendChild(profileType.treeElement); | 662 this.sidebarTree.appendChild(profileType.treeElement); |
| 663 profileType.treeElement.childrenListElement.addEventListener("contextmen
u", this._handleContextMenuEvent.bind(this), true); | 663 profileType.treeElement.childrenListElement.addEventListener("contextmen
u", this._handleContextMenuEvent.bind(this), true); |
| 664 | 664 |
| 665 /** | 665 /** |
| 666 * @this {WebInspector.ProfilesPanel} | 666 * @this {WebInspector.ProfilesPanel} |
| 667 */ | 667 */ |
| 668 function onAddProfileHeader(event) | 668 function onAddProfileHeader(event) |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 | 851 |
| 852 return view; | 852 return view; |
| 853 }, | 853 }, |
| 854 | 854 |
| 855 /** | 855 /** |
| 856 * @param {!HeapProfilerAgent.HeapSnapshotObjectId} snapshotObjectId | 856 * @param {!HeapProfilerAgent.HeapSnapshotObjectId} snapshotObjectId |
| 857 * @param {string} viewName | 857 * @param {string} viewName |
| 858 */ | 858 */ |
| 859 showObject: function(snapshotObjectId, viewName) | 859 showObject: function(snapshotObjectId, viewName) |
| 860 { | 860 { |
| 861 var heapProfiles = this.getProfileType(WebInspector.HeapSnapshotProfileT
ype.TypeId).getProfiles(); | 861 var heapProfiles = WebInspector.ProfileTypeRegistry.instance.heapSnapsho
tProfileType.getProfiles(); |
| 862 for (var i = 0; i < heapProfiles.length; i++) { | 862 for (var i = 0; i < heapProfiles.length; i++) { |
| 863 var profile = heapProfiles[i]; | 863 var profile = heapProfiles[i]; |
| 864 // FIXME: allow to choose snapshot if there are several options. | 864 // FIXME: allow to choose snapshot if there are several options. |
| 865 if (profile.maxJSObjectId >= snapshotObjectId) { | 865 if (profile.maxJSObjectId >= snapshotObjectId) { |
| 866 this._showProfile(profile); | 866 this._showProfile(profile); |
| 867 var view = profile.view(this); | 867 var view = profile.view(this); |
| 868 view.changeView(viewName, function() { | 868 view.changeView(viewName, function() { |
| 869 function didHighlightObject(found) { | 869 function didHighlightObject(found) { |
| 870 if (!found) | 870 if (!found) |
| 871 WebInspector.log("Cannot find corresponding heap sna
pshot node", WebInspector.ConsoleMessage.MessageLevel.Error, true); | 871 WebInspector.log("Cannot find corresponding heap sna
pshot node", WebInspector.ConsoleMessage.MessageLevel.Error, true); |
| 872 } | 872 } |
| 873 view.dataGrid.highlightObjectByHeapSnapshotId(snapshotObject
Id, didHighlightObject.bind(this)); | 873 view.dataGrid.highlightObjectByHeapSnapshotId(snapshotObject
Id, didHighlightObject.bind(this)); |
| 874 }); | 874 }); |
| 875 break; | 875 break; |
| 876 } | 876 } |
| 877 } | 877 } |
| 878 }, | 878 }, |
| 879 | 879 |
| 880 /** | 880 /** |
| 881 * @param {string} typeId | |
| 882 * @param {number} uid | |
| 883 * @return {?WebInspector.ProfileHeader} | |
| 884 */ | |
| 885 getProfile: function(typeId, uid) | |
| 886 { | |
| 887 return this.getProfileType(typeId).getProfile(uid); | |
| 888 }, | |
| 889 | |
| 890 /** | |
| 891 * @param {!WebInspector.View} view | 881 * @param {!WebInspector.View} view |
| 892 */ | 882 */ |
| 893 showView: function(view) | 883 showView: function(view) |
| 894 { | 884 { |
| 895 this._showProfile(view.profile); | 885 this._showProfile(view.profile); |
| 896 }, | 886 }, |
| 897 | 887 |
| 898 /** | |
| 899 * @param {string} typeId | |
| 900 * @return {!WebInspector.ProfileType} | |
| 901 */ | |
| 902 getProfileType: function(typeId) | |
| 903 { | |
| 904 return this._profileTypesByIdMap[typeId]; | |
| 905 }, | |
| 906 | |
| 907 /** | |
| 908 * @param {string} typeId | |
| 909 * @param {string} uid | |
| 910 * @return {?WebInspector.View} | |
| 911 */ | |
| 912 showProfile: function(typeId, uid) | |
| 913 { | |
| 914 return this._showProfile(this.getProfile(typeId, Number(uid))); | |
| 915 }, | |
| 916 | |
| 917 closeVisibleView: function() | 888 closeVisibleView: function() |
| 918 { | 889 { |
| 919 if (this.visibleView) | 890 if (this.visibleView) |
| 920 this.visibleView.detach(); | 891 this.visibleView.detach(); |
| 921 delete this.visibleView; | 892 delete this.visibleView; |
| 922 }, | 893 }, |
| 923 | 894 |
| 924 /** | 895 /** |
| 925 * @param {string} query | 896 * @param {string} query |
| 926 * @param {boolean} shouldJump | 897 * @param {boolean} shouldJump |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 jumpToPreviousSearchResult: function() | 936 jumpToPreviousSearchResult: function() |
| 966 { | 937 { |
| 967 if (!this._searchResultsView) | 938 if (!this._searchResultsView) |
| 968 return; | 939 return; |
| 969 if (this._searchResultsView !== this.visibleView) | 940 if (this._searchResultsView !== this.visibleView) |
| 970 return; | 941 return; |
| 971 this._searchResultsView.jumpToPreviousSearchResult(); | 942 this._searchResultsView.jumpToPreviousSearchResult(); |
| 972 this._searchableView.updateCurrentMatchIndex(this._searchResultsView.cur
rentSearchResultIndex()); | 943 this._searchableView.updateCurrentMatchIndex(this._searchResultsView.cur
rentSearchResultIndex()); |
| 973 }, | 944 }, |
| 974 | 945 |
| 975 /** | |
| 976 * @return {!Array.<!WebInspector.ProfileHeader>} | |
| 977 */ | |
| 978 _getAllProfiles: function() | |
| 979 { | |
| 980 var profiles = []; | |
| 981 for (var typeId in this._profileTypesByIdMap) | |
| 982 profiles = profiles.concat(this._profileTypesByIdMap[typeId].getProf
iles()); | |
| 983 return profiles; | |
| 984 }, | |
| 985 | |
| 986 searchCanceled: function() | 946 searchCanceled: function() |
| 987 { | 947 { |
| 988 if (this._searchResultsView) { | 948 if (this._searchResultsView) { |
| 989 if (this._searchResultsView.searchCanceled) | 949 if (this._searchResultsView.searchCanceled) |
| 990 this._searchResultsView.searchCanceled(); | 950 this._searchResultsView.searchCanceled(); |
| 991 this._searchResultsView.currentQuery = null; | 951 this._searchResultsView.currentQuery = null; |
| 992 this._searchResultsView = null; | 952 this._searchResultsView = null; |
| 993 } | 953 } |
| 994 this._searchableView.updateSearchMatchesCount(0); | 954 this._searchableView.updateSearchMatchesCount(0); |
| 995 }, | 955 }, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1015 return; | 975 return; |
| 1016 | 976 |
| 1017 if (WebInspector.inspectorView.currentPanel() !== this) | 977 if (WebInspector.inspectorView.currentPanel() !== this) |
| 1018 return; | 978 return; |
| 1019 | 979 |
| 1020 var object = /** @type {!WebInspector.RemoteObject} */ (target); | 980 var object = /** @type {!WebInspector.RemoteObject} */ (target); |
| 1021 var objectId = object.objectId; | 981 var objectId = object.objectId; |
| 1022 if (!objectId) | 982 if (!objectId) |
| 1023 return; | 983 return; |
| 1024 | 984 |
| 1025 var heapProfiles = this.getProfileType(WebInspector.HeapSnapshotProfileT
ype.TypeId).getProfiles(); | 985 var heapProfiles = WebInspector.ProfileTypeRegistry.instance.heapSnapsho
tProfileType.getProfiles(); |
| 1026 if (!heapProfiles.length) | 986 if (!heapProfiles.length) |
| 1027 return; | 987 return; |
| 1028 | 988 |
| 1029 /** | 989 /** |
| 1030 * @this {WebInspector.ProfilesPanel} | 990 * @this {WebInspector.ProfilesPanel} |
| 1031 */ | 991 */ |
| 1032 function revealInView(viewName) | 992 function revealInView(viewName) |
| 1033 { | 993 { |
| 1034 HeapProfilerAgent.getHeapObjectId(objectId, didReceiveHeapObjectId.b
ind(this, viewName)); | 994 HeapProfilerAgent.getHeapObjectId(objectId, didReceiveHeapObjectId.b
ind(this, viewName)); |
| 1035 } | 995 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 importScript("HeapSnapshotProxy.js"); | 1150 importScript("HeapSnapshotProxy.js"); |
| 1191 importScript("HeapSnapshotDataGrids.js"); | 1151 importScript("HeapSnapshotDataGrids.js"); |
| 1192 importScript("HeapSnapshotGridNodes.js"); | 1152 importScript("HeapSnapshotGridNodes.js"); |
| 1193 importScript("HeapSnapshotView.js"); | 1153 importScript("HeapSnapshotView.js"); |
| 1194 importScript("ProfileLauncherView.js"); | 1154 importScript("ProfileLauncherView.js"); |
| 1195 importScript("TopDownProfileDataGridTree.js"); | 1155 importScript("TopDownProfileDataGridTree.js"); |
| 1196 importScript("CanvasProfileView.js"); | 1156 importScript("CanvasProfileView.js"); |
| 1197 importScript("CanvasReplayStateView.js"); | 1157 importScript("CanvasReplayStateView.js"); |
| 1198 | 1158 |
| 1199 WebInspector.ProfileTypeRegistry.instance = new WebInspector.ProfileTypeRegistry
(); | 1159 WebInspector.ProfileTypeRegistry.instance = new WebInspector.ProfileTypeRegistry
(); |
| OLD | NEW |