| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** | 30 /** |
| 31 * @implements {WebInspector.TargetManager.Observer} | 31 * @implements {SDK.TargetManager.Observer} |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 WebInspector.ProfileLauncherView = class extends WebInspector.VBox { | 34 Profiler.ProfileLauncherView = class extends UI.VBox { |
| 35 /** | 35 /** |
| 36 * @param {!WebInspector.ProfilesPanel} profilesPanel | 36 * @param {!Profiler.ProfilesPanel} profilesPanel |
| 37 */ | 37 */ |
| 38 constructor(profilesPanel) { | 38 constructor(profilesPanel) { |
| 39 super(); | 39 super(); |
| 40 | 40 |
| 41 this._panel = profilesPanel; | 41 this._panel = profilesPanel; |
| 42 | 42 |
| 43 this.element.classList.add('profile-launcher-view'); | 43 this.element.classList.add('profile-launcher-view'); |
| 44 this.element.classList.add('panel-enabler-view'); | 44 this.element.classList.add('panel-enabler-view'); |
| 45 | 45 |
| 46 this._contentElement = this.element.createChild('div', 'profile-launcher-vie
w-content'); | 46 this._contentElement = this.element.createChild('div', 'profile-launcher-vie
w-content'); |
| 47 this._innerContentElement = this._contentElement.createChild('div'); | 47 this._innerContentElement = this._contentElement.createChild('div'); |
| 48 var targetSpan = this._contentElement.createChild('span'); | 48 var targetSpan = this._contentElement.createChild('span'); |
| 49 var selectTargetText = targetSpan.createChild('span'); | 49 var selectTargetText = targetSpan.createChild('span'); |
| 50 selectTargetText.textContent = WebInspector.UIString('Target:'); | 50 selectTargetText.textContent = Common.UIString('Target:'); |
| 51 var targetsSelect = targetSpan.createChild('select', 'chrome-select'); | 51 var targetsSelect = targetSpan.createChild('select', 'chrome-select'); |
| 52 new WebInspector.TargetsComboBoxController(targetsSelect, targetSpan); | 52 new Profiler.TargetsComboBoxController(targetsSelect, targetSpan); |
| 53 this._controlButton = createTextButton('', this._controlButtonClicked.bind(t
his), 'control-profiling'); | 53 this._controlButton = createTextButton('', this._controlButtonClicked.bind(t
his), 'control-profiling'); |
| 54 this._contentElement.appendChild(this._controlButton); | 54 this._contentElement.appendChild(this._controlButton); |
| 55 this._recordButtonEnabled = true; | 55 this._recordButtonEnabled = true; |
| 56 this._loadButton = | 56 this._loadButton = |
| 57 createTextButton(WebInspector.UIString('Load'), this._loadButtonClicked.
bind(this), 'load-profile'); | 57 createTextButton(Common.UIString('Load'), this._loadButtonClicked.bind(t
his), 'load-profile'); |
| 58 this._contentElement.appendChild(this._loadButton); | 58 this._contentElement.appendChild(this._loadButton); |
| 59 WebInspector.targetManager.observeTargets(this); | 59 SDK.targetManager.observeTargets(this); |
| 60 } | 60 } |
| 61 | 61 |
| 62 /** | 62 /** |
| 63 * @return {?WebInspector.SearchableView} | 63 * @return {?UI.SearchableView} |
| 64 */ | 64 */ |
| 65 searchableView() { | 65 searchableView() { |
| 66 return null; | 66 return null; |
| 67 } | 67 } |
| 68 | 68 |
| 69 /** | 69 /** |
| 70 * @override | 70 * @override |
| 71 * @param {!WebInspector.Target} target | 71 * @param {!SDK.Target} target |
| 72 */ | 72 */ |
| 73 targetAdded(target) { | 73 targetAdded(target) { |
| 74 this._updateLoadButtonLayout(); | 74 this._updateLoadButtonLayout(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * @override | 78 * @override |
| 79 * @param {!WebInspector.Target} target | 79 * @param {!SDK.Target} target |
| 80 */ | 80 */ |
| 81 targetRemoved(target) { | 81 targetRemoved(target) { |
| 82 this._updateLoadButtonLayout(); | 82 this._updateLoadButtonLayout(); |
| 83 } | 83 } |
| 84 | 84 |
| 85 _updateLoadButtonLayout() { | 85 _updateLoadButtonLayout() { |
| 86 this._loadButton.classList.toggle( | 86 this._loadButton.classList.toggle( |
| 87 'multi-target', WebInspector.targetManager.targets(WebInspector.Target.C
apability.JS).length > 1); | 87 'multi-target', SDK.targetManager.targets(SDK.Target.Capability.JS).leng
th > 1); |
| 88 } | 88 } |
| 89 | 89 |
| 90 /** | 90 /** |
| 91 * @param {!WebInspector.ProfileType} profileType | 91 * @param {!Profiler.ProfileType} profileType |
| 92 */ | 92 */ |
| 93 addProfileType(profileType) { | 93 addProfileType(profileType) { |
| 94 var descriptionElement = this._innerContentElement.createChild('h1'); | 94 var descriptionElement = this._innerContentElement.createChild('h1'); |
| 95 descriptionElement.textContent = profileType.description; | 95 descriptionElement.textContent = profileType.description; |
| 96 var decorationElement = profileType.decorationElement(); | 96 var decorationElement = profileType.decorationElement(); |
| 97 if (decorationElement) | 97 if (decorationElement) |
| 98 this._innerContentElement.appendChild(decorationElement); | 98 this._innerContentElement.appendChild(decorationElement); |
| 99 this._isInstantProfile = profileType.isInstantProfile(); | 99 this._isInstantProfile = profileType.isInstantProfile(); |
| 100 this._isEnabled = profileType.isEnabled(); | 100 this._isEnabled = profileType.isEnabled(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 _controlButtonClicked() { | 103 _controlButtonClicked() { |
| 104 this._panel.toggleRecord(); | 104 this._panel.toggleRecord(); |
| 105 } | 105 } |
| 106 | 106 |
| 107 _loadButtonClicked() { | 107 _loadButtonClicked() { |
| 108 this._panel.showLoadFromFileDialog(); | 108 this._panel.showLoadFromFileDialog(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 _updateControls() { | 111 _updateControls() { |
| 112 if (this._isEnabled && this._recordButtonEnabled) | 112 if (this._isEnabled && this._recordButtonEnabled) |
| 113 this._controlButton.removeAttribute('disabled'); | 113 this._controlButton.removeAttribute('disabled'); |
| 114 else | 114 else |
| 115 this._controlButton.setAttribute('disabled', ''); | 115 this._controlButton.setAttribute('disabled', ''); |
| 116 this._controlButton.title = this._recordButtonEnabled ? '' : WebInspector.an
otherProfilerActiveLabel(); | 116 this._controlButton.title = this._recordButtonEnabled ? '' : UI.anotherProfi
lerActiveLabel(); |
| 117 if (this._isInstantProfile) { | 117 if (this._isInstantProfile) { |
| 118 this._controlButton.classList.remove('running'); | 118 this._controlButton.classList.remove('running'); |
| 119 this._controlButton.textContent = WebInspector.UIString('Take Snapshot'); | 119 this._controlButton.textContent = Common.UIString('Take Snapshot'); |
| 120 } else if (this._isProfiling) { | 120 } else if (this._isProfiling) { |
| 121 this._controlButton.classList.add('running'); | 121 this._controlButton.classList.add('running'); |
| 122 this._controlButton.textContent = WebInspector.UIString('Stop'); | 122 this._controlButton.textContent = Common.UIString('Stop'); |
| 123 } else { | 123 } else { |
| 124 this._controlButton.classList.remove('running'); | 124 this._controlButton.classList.remove('running'); |
| 125 this._controlButton.textContent = WebInspector.UIString('Start'); | 125 this._controlButton.textContent = Common.UIString('Start'); |
| 126 } | 126 } |
| 127 } | 127 } |
| 128 | 128 |
| 129 profileStarted() { | 129 profileStarted() { |
| 130 this._isProfiling = true; | 130 this._isProfiling = true; |
| 131 this._updateControls(); | 131 this._updateControls(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 profileFinished() { | 134 profileFinished() { |
| 135 this._isProfiling = false; | 135 this._isProfiling = false; |
| 136 this._updateControls(); | 136 this._updateControls(); |
| 137 } | 137 } |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * @param {!WebInspector.ProfileType} profileType | 140 * @param {!Profiler.ProfileType} profileType |
| 141 * @param {boolean} recordButtonEnabled | 141 * @param {boolean} recordButtonEnabled |
| 142 */ | 142 */ |
| 143 updateProfileType(profileType, recordButtonEnabled) { | 143 updateProfileType(profileType, recordButtonEnabled) { |
| 144 this._isInstantProfile = profileType.isInstantProfile(); | 144 this._isInstantProfile = profileType.isInstantProfile(); |
| 145 this._recordButtonEnabled = recordButtonEnabled; | 145 this._recordButtonEnabled = recordButtonEnabled; |
| 146 this._isEnabled = profileType.isEnabled(); | 146 this._isEnabled = profileType.isEnabled(); |
| 147 this._updateControls(); | 147 this._updateControls(); |
| 148 } | 148 } |
| 149 }; | 149 }; |
| 150 | 150 |
| 151 /** | 151 /** |
| 152 * @unrestricted | 152 * @unrestricted |
| 153 */ | 153 */ |
| 154 WebInspector.MultiProfileLauncherView = class extends WebInspector.ProfileLaunch
erView { | 154 Profiler.MultiProfileLauncherView = class extends Profiler.ProfileLauncherView { |
| 155 /** | 155 /** |
| 156 * @param {!WebInspector.ProfilesPanel} profilesPanel | 156 * @param {!Profiler.ProfilesPanel} profilesPanel |
| 157 */ | 157 */ |
| 158 constructor(profilesPanel) { | 158 constructor(profilesPanel) { |
| 159 super(profilesPanel); | 159 super(profilesPanel); |
| 160 | 160 |
| 161 this._selectedProfileTypeSetting = WebInspector.settings.createSetting('sele
ctedProfileType', 'CPU'); | 161 this._selectedProfileTypeSetting = Common.settings.createSetting('selectedPr
ofileType', 'CPU'); |
| 162 | 162 |
| 163 var header = this._innerContentElement.createChild('h1'); | 163 var header = this._innerContentElement.createChild('h1'); |
| 164 header.textContent = WebInspector.UIString('Select profiling type'); | 164 header.textContent = Common.UIString('Select profiling type'); |
| 165 | 165 |
| 166 this._profileTypeSelectorForm = this._innerContentElement.createChild('form'
); | 166 this._profileTypeSelectorForm = this._innerContentElement.createChild('form'
); |
| 167 | 167 |
| 168 this._innerContentElement.createChild('div', 'flexible-space'); | 168 this._innerContentElement.createChild('div', 'flexible-space'); |
| 169 | 169 |
| 170 this._typeIdToOptionElement = {}; | 170 this._typeIdToOptionElement = {}; |
| 171 } | 171 } |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * @override | 174 * @override |
| 175 * @param {!WebInspector.ProfileType} profileType | 175 * @param {!Profiler.ProfileType} profileType |
| 176 */ | 176 */ |
| 177 addProfileType(profileType) { | 177 addProfileType(profileType) { |
| 178 var labelElement = createRadioLabel('profile-type', profileType.name); | 178 var labelElement = createRadioLabel('profile-type', profileType.name); |
| 179 this._profileTypeSelectorForm.appendChild(labelElement); | 179 this._profileTypeSelectorForm.appendChild(labelElement); |
| 180 var optionElement = labelElement.radioElement; | 180 var optionElement = labelElement.radioElement; |
| 181 this._typeIdToOptionElement[profileType.id] = optionElement; | 181 this._typeIdToOptionElement[profileType.id] = optionElement; |
| 182 optionElement._profileType = profileType; | 182 optionElement._profileType = profileType; |
| 183 optionElement.style.hidden = true; | 183 optionElement.style.hidden = true; |
| 184 optionElement.addEventListener('change', this._profileTypeChanged.bind(this,
profileType), false); | 184 optionElement.addEventListener('change', this._profileTypeChanged.bind(this,
profileType), false); |
| 185 var descriptionElement = labelElement.createChild('p'); | 185 var descriptionElement = labelElement.createChild('p'); |
| 186 descriptionElement.textContent = profileType.description; | 186 descriptionElement.textContent = profileType.description; |
| 187 var decorationElement = profileType.decorationElement(); | 187 var decorationElement = profileType.decorationElement(); |
| 188 if (decorationElement) | 188 if (decorationElement) |
| 189 labelElement.appendChild(decorationElement); | 189 labelElement.appendChild(decorationElement); |
| 190 } | 190 } |
| 191 | 191 |
| 192 restoreSelectedProfileType() { | 192 restoreSelectedProfileType() { |
| 193 var typeId = this._selectedProfileTypeSetting.get(); | 193 var typeId = this._selectedProfileTypeSetting.get(); |
| 194 if (!(typeId in this._typeIdToOptionElement)) | 194 if (!(typeId in this._typeIdToOptionElement)) |
| 195 typeId = Object.keys(this._typeIdToOptionElement)[0]; | 195 typeId = Object.keys(this._typeIdToOptionElement)[0]; |
| 196 this._typeIdToOptionElement[typeId].checked = true; | 196 this._typeIdToOptionElement[typeId].checked = true; |
| 197 var type = this._typeIdToOptionElement[typeId]._profileType; | 197 var type = this._typeIdToOptionElement[typeId]._profileType; |
| 198 this.dispatchEventToListeners(WebInspector.MultiProfileLauncherView.Events.P
rofileTypeSelected, type); | 198 this.dispatchEventToListeners(Profiler.MultiProfileLauncherView.Events.Profi
leTypeSelected, type); |
| 199 } | 199 } |
| 200 | 200 |
| 201 /** | 201 /** |
| 202 * @override | 202 * @override |
| 203 */ | 203 */ |
| 204 _controlButtonClicked() { | 204 _controlButtonClicked() { |
| 205 this._panel.toggleRecord(); | 205 this._panel.toggleRecord(); |
| 206 } | 206 } |
| 207 | 207 |
| 208 /** | 208 /** |
| 209 * @override | 209 * @override |
| 210 */ | 210 */ |
| 211 _updateControls() { | 211 _updateControls() { |
| 212 super._updateControls(); | 212 super._updateControls(); |
| 213 var items = this._profileTypeSelectorForm.elements; | 213 var items = this._profileTypeSelectorForm.elements; |
| 214 for (var i = 0; i < items.length; ++i) { | 214 for (var i = 0; i < items.length; ++i) { |
| 215 if (items[i].type === 'radio') | 215 if (items[i].type === 'radio') |
| 216 items[i].disabled = this._isProfiling; | 216 items[i].disabled = this._isProfiling; |
| 217 } | 217 } |
| 218 } | 218 } |
| 219 | 219 |
| 220 /** | 220 /** |
| 221 * @param {!WebInspector.ProfileType} profileType | 221 * @param {!Profiler.ProfileType} profileType |
| 222 */ | 222 */ |
| 223 _profileTypeChanged(profileType) { | 223 _profileTypeChanged(profileType) { |
| 224 this.dispatchEventToListeners(WebInspector.MultiProfileLauncherView.Events.P
rofileTypeSelected, profileType); | 224 this.dispatchEventToListeners(Profiler.MultiProfileLauncherView.Events.Profi
leTypeSelected, profileType); |
| 225 this._isInstantProfile = profileType.isInstantProfile(); | 225 this._isInstantProfile = profileType.isInstantProfile(); |
| 226 this._isEnabled = profileType.isEnabled(); | 226 this._isEnabled = profileType.isEnabled(); |
| 227 this._updateControls(); | 227 this._updateControls(); |
| 228 this._selectedProfileTypeSetting.set(profileType.id); | 228 this._selectedProfileTypeSetting.set(profileType.id); |
| 229 } | 229 } |
| 230 | 230 |
| 231 /** | 231 /** |
| 232 * @override | 232 * @override |
| 233 */ | 233 */ |
| 234 profileStarted() { | 234 profileStarted() { |
| 235 this._isProfiling = true; | 235 this._isProfiling = true; |
| 236 this._updateControls(); | 236 this._updateControls(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * @override | 240 * @override |
| 241 */ | 241 */ |
| 242 profileFinished() { | 242 profileFinished() { |
| 243 this._isProfiling = false; | 243 this._isProfiling = false; |
| 244 this._updateControls(); | 244 this._updateControls(); |
| 245 } | 245 } |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 /** @enum {symbol} */ | 248 /** @enum {symbol} */ |
| 249 WebInspector.MultiProfileLauncherView.Events = { | 249 Profiler.MultiProfileLauncherView.Events = { |
| 250 ProfileTypeSelected: Symbol('ProfileTypeSelected') | 250 ProfileTypeSelected: Symbol('ProfileTypeSelected') |
| 251 }; | 251 }; |
| OLD | NEW |