| 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 |
| 11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
| 12 * | 12 * |
| 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
| 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
| 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 /** | 26 /** |
| 27 * @unrestricted | 27 * @unrestricted |
| 28 */ | 28 */ |
| 29 WebInspector.ProfileType = class extends WebInspector.Object { | 29 Profiler.ProfileType = class extends Common.Object { |
| 30 /** | 30 /** |
| 31 * @param {string} id | 31 * @param {string} id |
| 32 * @param {string} name | 32 * @param {string} name |
| 33 * @suppressGlobalPropertiesCheck | 33 * @suppressGlobalPropertiesCheck |
| 34 */ | 34 */ |
| 35 constructor(id, name) { | 35 constructor(id, name) { |
| 36 super(); | 36 super(); |
| 37 this._id = id; | 37 this._id = id; |
| 38 this._name = name; | 38 this._name = name; |
| 39 /** @type {!Array.<!WebInspector.ProfileHeader>} */ | 39 /** @type {!Array.<!Profiler.ProfileHeader>} */ |
| 40 this._profiles = []; | 40 this._profiles = []; |
| 41 /** @type {?WebInspector.ProfileHeader} */ | 41 /** @type {?Profiler.ProfileHeader} */ |
| 42 this._profileBeingRecorded = null; | 42 this._profileBeingRecorded = null; |
| 43 this._nextProfileUid = 1; | 43 this._nextProfileUid = 1; |
| 44 | 44 |
| 45 if (!window.opener) | 45 if (!window.opener) |
| 46 window.addEventListener('unload', this._clearTempStorage.bind(this), false
); | 46 window.addEventListener('unload', this._clearTempStorage.bind(this), false
); |
| 47 } | 47 } |
| 48 | 48 |
| 49 /** | 49 /** |
| 50 * @return {string} | 50 * @return {string} |
| 51 */ | 51 */ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * @return {?string} | 71 * @return {?string} |
| 72 */ | 72 */ |
| 73 fileExtension() { | 73 fileExtension() { |
| 74 return null; | 74 return null; |
| 75 } | 75 } |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * @return {!Array.<!WebInspector.ToolbarItem>} | 78 * @return {!Array.<!UI.ToolbarItem>} |
| 79 */ | 79 */ |
| 80 toolbarItems() { | 80 toolbarItems() { |
| 81 return []; | 81 return []; |
| 82 } | 82 } |
| 83 | 83 |
| 84 get buttonTooltip() { | 84 get buttonTooltip() { |
| 85 return ''; | 85 return ''; |
| 86 } | 86 } |
| 87 | 87 |
| 88 get id() { | 88 get id() { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 /** | 118 /** |
| 119 * @return {boolean} | 119 * @return {boolean} |
| 120 */ | 120 */ |
| 121 isEnabled() { | 121 isEnabled() { |
| 122 return true; | 122 return true; |
| 123 } | 123 } |
| 124 | 124 |
| 125 /** | 125 /** |
| 126 * @return {!Array.<!WebInspector.ProfileHeader>} | 126 * @return {!Array.<!Profiler.ProfileHeader>} |
| 127 */ | 127 */ |
| 128 getProfiles() { | 128 getProfiles() { |
| 129 /** | 129 /** |
| 130 * @param {!WebInspector.ProfileHeader} profile | 130 * @param {!Profiler.ProfileHeader} profile |
| 131 * @return {boolean} | 131 * @return {boolean} |
| 132 * @this {WebInspector.ProfileType} | 132 * @this {Profiler.ProfileType} |
| 133 */ | 133 */ |
| 134 function isFinished(profile) { | 134 function isFinished(profile) { |
| 135 return this._profileBeingRecorded !== profile; | 135 return this._profileBeingRecorded !== profile; |
| 136 } | 136 } |
| 137 return this._profiles.filter(isFinished.bind(this)); | 137 return this._profiles.filter(isFinished.bind(this)); |
| 138 } | 138 } |
| 139 | 139 |
| 140 /** | 140 /** |
| 141 * @return {?Element} | 141 * @return {?Element} |
| 142 */ | 142 */ |
| 143 decorationElement() { | 143 decorationElement() { |
| 144 return null; | 144 return null; |
| 145 } | 145 } |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * @param {number} uid | 148 * @param {number} uid |
| 149 * @return {?WebInspector.ProfileHeader} | 149 * @return {?Profiler.ProfileHeader} |
| 150 */ | 150 */ |
| 151 getProfile(uid) { | 151 getProfile(uid) { |
| 152 for (var i = 0; i < this._profiles.length; ++i) { | 152 for (var i = 0; i < this._profiles.length; ++i) { |
| 153 if (this._profiles[i].uid === uid) | 153 if (this._profiles[i].uid === uid) |
| 154 return this._profiles[i]; | 154 return this._profiles[i]; |
| 155 } | 155 } |
| 156 return null; | 156 return null; |
| 157 } | 157 } |
| 158 | 158 |
| 159 /** | 159 /** |
| 160 * @param {!File} file | 160 * @param {!File} file |
| 161 */ | 161 */ |
| 162 loadFromFile(file) { | 162 loadFromFile(file) { |
| 163 var name = file.name; | 163 var name = file.name; |
| 164 var fileExtension = this.fileExtension(); | 164 var fileExtension = this.fileExtension(); |
| 165 if (fileExtension && name.endsWith(fileExtension)) | 165 if (fileExtension && name.endsWith(fileExtension)) |
| 166 name = name.substr(0, name.length - fileExtension.length); | 166 name = name.substr(0, name.length - fileExtension.length); |
| 167 var profile = this.createProfileLoadedFromFile(name); | 167 var profile = this.createProfileLoadedFromFile(name); |
| 168 profile.setFromFile(); | 168 profile.setFromFile(); |
| 169 this.setProfileBeingRecorded(profile); | 169 this.setProfileBeingRecorded(profile); |
| 170 this.addProfile(profile); | 170 this.addProfile(profile); |
| 171 profile.loadFromFile(file); | 171 profile.loadFromFile(file); |
| 172 } | 172 } |
| 173 | 173 |
| 174 /** | 174 /** |
| 175 * @param {string} title | 175 * @param {string} title |
| 176 * @return {!WebInspector.ProfileHeader} | 176 * @return {!Profiler.ProfileHeader} |
| 177 */ | 177 */ |
| 178 createProfileLoadedFromFile(title) { | 178 createProfileLoadedFromFile(title) { |
| 179 throw new Error('Needs implemented.'); | 179 throw new Error('Needs implemented.'); |
| 180 } | 180 } |
| 181 | 181 |
| 182 /** | 182 /** |
| 183 * @param {!WebInspector.ProfileHeader} profile | 183 * @param {!Profiler.ProfileHeader} profile |
| 184 */ | 184 */ |
| 185 addProfile(profile) { | 185 addProfile(profile) { |
| 186 this._profiles.push(profile); | 186 this._profiles.push(profile); |
| 187 this.dispatchEventToListeners(WebInspector.ProfileType.Events.AddProfileHead
er, profile); | 187 this.dispatchEventToListeners(Profiler.ProfileType.Events.AddProfileHeader,
profile); |
| 188 } | 188 } |
| 189 | 189 |
| 190 /** | 190 /** |
| 191 * @param {!WebInspector.ProfileHeader} profile | 191 * @param {!Profiler.ProfileHeader} profile |
| 192 */ | 192 */ |
| 193 removeProfile(profile) { | 193 removeProfile(profile) { |
| 194 var index = this._profiles.indexOf(profile); | 194 var index = this._profiles.indexOf(profile); |
| 195 if (index === -1) | 195 if (index === -1) |
| 196 return; | 196 return; |
| 197 this._profiles.splice(index, 1); | 197 this._profiles.splice(index, 1); |
| 198 this._disposeProfile(profile); | 198 this._disposeProfile(profile); |
| 199 } | 199 } |
| 200 | 200 |
| 201 _clearTempStorage() { | 201 _clearTempStorage() { |
| 202 for (var i = 0; i < this._profiles.length; ++i) | 202 for (var i = 0; i < this._profiles.length; ++i) |
| 203 this._profiles[i].removeTempFile(); | 203 this._profiles[i].removeTempFile(); |
| 204 } | 204 } |
| 205 | 205 |
| 206 /** | 206 /** |
| 207 * @return {?WebInspector.ProfileHeader} | 207 * @return {?Profiler.ProfileHeader} |
| 208 */ | 208 */ |
| 209 profileBeingRecorded() { | 209 profileBeingRecorded() { |
| 210 return this._profileBeingRecorded; | 210 return this._profileBeingRecorded; |
| 211 } | 211 } |
| 212 | 212 |
| 213 /** | 213 /** |
| 214 * @param {?WebInspector.ProfileHeader} profile | 214 * @param {?Profiler.ProfileHeader} profile |
| 215 */ | 215 */ |
| 216 setProfileBeingRecorded(profile) { | 216 setProfileBeingRecorded(profile) { |
| 217 this._profileBeingRecorded = profile; | 217 this._profileBeingRecorded = profile; |
| 218 } | 218 } |
| 219 | 219 |
| 220 profileBeingRecordedRemoved() { | 220 profileBeingRecordedRemoved() { |
| 221 } | 221 } |
| 222 | 222 |
| 223 _reset() { | 223 _reset() { |
| 224 var profiles = this._profiles.slice(0); | 224 var profiles = this._profiles.slice(0); |
| 225 for (var i = 0; i < profiles.length; ++i) | 225 for (var i = 0; i < profiles.length; ++i) |
| 226 this._disposeProfile(profiles[i]); | 226 this._disposeProfile(profiles[i]); |
| 227 this._profiles = []; | 227 this._profiles = []; |
| 228 | 228 |
| 229 this._nextProfileUid = 1; | 229 this._nextProfileUid = 1; |
| 230 } | 230 } |
| 231 | 231 |
| 232 /** | 232 /** |
| 233 * @param {!WebInspector.ProfileHeader} profile | 233 * @param {!Profiler.ProfileHeader} profile |
| 234 */ | 234 */ |
| 235 _disposeProfile(profile) { | 235 _disposeProfile(profile) { |
| 236 this.dispatchEventToListeners(WebInspector.ProfileType.Events.RemoveProfileH
eader, profile); | 236 this.dispatchEventToListeners(Profiler.ProfileType.Events.RemoveProfileHeade
r, profile); |
| 237 profile.dispose(); | 237 profile.dispose(); |
| 238 if (this._profileBeingRecorded === profile) { | 238 if (this._profileBeingRecorded === profile) { |
| 239 this.profileBeingRecordedRemoved(); | 239 this.profileBeingRecordedRemoved(); |
| 240 this.setProfileBeingRecorded(null); | 240 this.setProfileBeingRecorded(null); |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 }; | 243 }; |
| 244 | 244 |
| 245 /** @enum {symbol} */ | 245 /** @enum {symbol} */ |
| 246 WebInspector.ProfileType.Events = { | 246 Profiler.ProfileType.Events = { |
| 247 AddProfileHeader: Symbol('add-profile-header'), | 247 AddProfileHeader: Symbol('add-profile-header'), |
| 248 ProfileComplete: Symbol('profile-complete'), | 248 ProfileComplete: Symbol('profile-complete'), |
| 249 RemoveProfileHeader: Symbol('remove-profile-header'), | 249 RemoveProfileHeader: Symbol('remove-profile-header'), |
| 250 ViewUpdated: Symbol('view-updated') | 250 ViewUpdated: Symbol('view-updated') |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 /** | 253 /** |
| 254 * @interface | 254 * @interface |
| 255 */ | 255 */ |
| 256 WebInspector.ProfileType.DataDisplayDelegate = function() {}; | 256 Profiler.ProfileType.DataDisplayDelegate = function() {}; |
| 257 | 257 |
| 258 WebInspector.ProfileType.DataDisplayDelegate.prototype = { | 258 Profiler.ProfileType.DataDisplayDelegate.prototype = { |
| 259 /** | 259 /** |
| 260 * @param {?WebInspector.ProfileHeader} profile | 260 * @param {?Profiler.ProfileHeader} profile |
| 261 * @return {?WebInspector.Widget} | 261 * @return {?UI.Widget} |
| 262 */ | 262 */ |
| 263 showProfile: function(profile) {}, | 263 showProfile: function(profile) {}, |
| 264 | 264 |
| 265 /** | 265 /** |
| 266 * @param {!Protocol.HeapProfiler.HeapSnapshotObjectId} snapshotObjectId | 266 * @param {!Protocol.HeapProfiler.HeapSnapshotObjectId} snapshotObjectId |
| 267 * @param {string} perspectiveName | 267 * @param {string} perspectiveName |
| 268 */ | 268 */ |
| 269 showObject: function(snapshotObjectId, perspectiveName) {} | 269 showObject: function(snapshotObjectId, perspectiveName) {} |
| 270 }; | 270 }; |
| 271 | 271 |
| 272 /** | 272 /** |
| 273 * @unrestricted | 273 * @unrestricted |
| 274 */ | 274 */ |
| 275 WebInspector.ProfileHeader = class extends WebInspector.Object { | 275 Profiler.ProfileHeader = class extends Common.Object { |
| 276 /** | 276 /** |
| 277 * @param {?WebInspector.Target} target | 277 * @param {?SDK.Target} target |
| 278 * @param {!WebInspector.ProfileType} profileType | 278 * @param {!Profiler.ProfileType} profileType |
| 279 * @param {string} title | 279 * @param {string} title |
| 280 */ | 280 */ |
| 281 constructor(target, profileType, title) { | 281 constructor(target, profileType, title) { |
| 282 super(); | 282 super(); |
| 283 this._target = target; | 283 this._target = target; |
| 284 this._profileType = profileType; | 284 this._profileType = profileType; |
| 285 this.title = title; | 285 this.title = title; |
| 286 this.uid = profileType._nextProfileUid++; | 286 this.uid = profileType._nextProfileUid++; |
| 287 this._fromFile = false; | 287 this._fromFile = false; |
| 288 } | 288 } |
| 289 | 289 |
| 290 /** | 290 /** |
| 291 * @return {?WebInspector.Target} | 291 * @return {?SDK.Target} |
| 292 */ | 292 */ |
| 293 target() { | 293 target() { |
| 294 return this._target; | 294 return this._target; |
| 295 } | 295 } |
| 296 | 296 |
| 297 /** | 297 /** |
| 298 * @return {!WebInspector.ProfileType} | 298 * @return {!Profiler.ProfileType} |
| 299 */ | 299 */ |
| 300 profileType() { | 300 profileType() { |
| 301 return this._profileType; | 301 return this._profileType; |
| 302 } | 302 } |
| 303 | 303 |
| 304 /** | 304 /** |
| 305 * @param {?string} subtitle | 305 * @param {?string} subtitle |
| 306 * @param {boolean=} wait | 306 * @param {boolean=} wait |
| 307 */ | 307 */ |
| 308 updateStatus(subtitle, wait) { | 308 updateStatus(subtitle, wait) { |
| 309 this.dispatchEventToListeners( | 309 this.dispatchEventToListeners( |
| 310 WebInspector.ProfileHeader.Events.UpdateStatus, new WebInspector.Profile
Header.StatusUpdate(subtitle, wait)); | 310 Profiler.ProfileHeader.Events.UpdateStatus, new Profiler.ProfileHeader.S
tatusUpdate(subtitle, wait)); |
| 311 } | 311 } |
| 312 | 312 |
| 313 /** | 313 /** |
| 314 * Must be implemented by subclasses. | 314 * Must be implemented by subclasses. |
| 315 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate | 315 * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate |
| 316 * @return {!WebInspector.ProfileSidebarTreeElement} | 316 * @return {!Profiler.ProfileSidebarTreeElement} |
| 317 */ | 317 */ |
| 318 createSidebarTreeElement(dataDisplayDelegate) { | 318 createSidebarTreeElement(dataDisplayDelegate) { |
| 319 throw new Error('Needs implemented.'); | 319 throw new Error('Needs implemented.'); |
| 320 } | 320 } |
| 321 | 321 |
| 322 /** | 322 /** |
| 323 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate | 323 * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate |
| 324 * @return {!WebInspector.Widget} | 324 * @return {!UI.Widget} |
| 325 */ | 325 */ |
| 326 createView(dataDisplayDelegate) { | 326 createView(dataDisplayDelegate) { |
| 327 throw new Error('Not implemented.'); | 327 throw new Error('Not implemented.'); |
| 328 } | 328 } |
| 329 | 329 |
| 330 removeTempFile() { | 330 removeTempFile() { |
| 331 if (this._tempFile) | 331 if (this._tempFile) |
| 332 this._tempFile.remove(); | 332 this._tempFile.remove(); |
| 333 } | 333 } |
| 334 | 334 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 361 } | 361 } |
| 362 | 362 |
| 363 setFromFile() { | 363 setFromFile() { |
| 364 this._fromFile = true; | 364 this._fromFile = true; |
| 365 } | 365 } |
| 366 }; | 366 }; |
| 367 | 367 |
| 368 /** | 368 /** |
| 369 * @unrestricted | 369 * @unrestricted |
| 370 */ | 370 */ |
| 371 WebInspector.ProfileHeader.StatusUpdate = class { | 371 Profiler.ProfileHeader.StatusUpdate = class { |
| 372 /** | 372 /** |
| 373 * @param {?string} subtitle | 373 * @param {?string} subtitle |
| 374 * @param {boolean|undefined} wait | 374 * @param {boolean|undefined} wait |
| 375 */ | 375 */ |
| 376 constructor(subtitle, wait) { | 376 constructor(subtitle, wait) { |
| 377 /** @type {?string} */ | 377 /** @type {?string} */ |
| 378 this.subtitle = subtitle; | 378 this.subtitle = subtitle; |
| 379 /** @type {boolean|undefined} */ | 379 /** @type {boolean|undefined} */ |
| 380 this.wait = wait; | 380 this.wait = wait; |
| 381 } | 381 } |
| 382 }; | 382 }; |
| 383 | 383 |
| 384 /** @enum {symbol} */ | 384 /** @enum {symbol} */ |
| 385 WebInspector.ProfileHeader.Events = { | 385 Profiler.ProfileHeader.Events = { |
| 386 UpdateStatus: Symbol('UpdateStatus'), | 386 UpdateStatus: Symbol('UpdateStatus'), |
| 387 ProfileReceived: Symbol('ProfileReceived') | 387 ProfileReceived: Symbol('ProfileReceived') |
| 388 }; | 388 }; |
| 389 | 389 |
| 390 /** | 390 /** |
| 391 * @implements {WebInspector.ProfileType.DataDisplayDelegate} | 391 * @implements {Profiler.ProfileType.DataDisplayDelegate} |
| 392 * @unrestricted | 392 * @unrestricted |
| 393 */ | 393 */ |
| 394 WebInspector.ProfilesPanel = class extends WebInspector.PanelWithSidebar { | 394 Profiler.ProfilesPanel = class extends UI.PanelWithSidebar { |
| 395 constructor() { | 395 constructor() { |
| 396 super('profiles'); | 396 super('profiles'); |
| 397 this.registerRequiredCSS('ui/panelEnablerView.css'); | 397 this.registerRequiredCSS('ui/panelEnablerView.css'); |
| 398 this.registerRequiredCSS('profiler/heapProfiler.css'); | 398 this.registerRequiredCSS('profiler/heapProfiler.css'); |
| 399 this.registerRequiredCSS('profiler/profilesPanel.css'); | 399 this.registerRequiredCSS('profiler/profilesPanel.css'); |
| 400 this.registerRequiredCSS('components/objectValue.css'); | 400 this.registerRequiredCSS('components/objectValue.css'); |
| 401 | 401 |
| 402 var mainContainer = new WebInspector.VBox(); | 402 var mainContainer = new UI.VBox(); |
| 403 this.splitWidget().setMainWidget(mainContainer); | 403 this.splitWidget().setMainWidget(mainContainer); |
| 404 | 404 |
| 405 this.profilesItemTreeElement = new WebInspector.ProfilesSidebarTreeElement(t
his); | 405 this.profilesItemTreeElement = new Profiler.ProfilesSidebarTreeElement(this)
; |
| 406 | 406 |
| 407 this._sidebarTree = new TreeOutlineInShadow(); | 407 this._sidebarTree = new TreeOutlineInShadow(); |
| 408 this._sidebarTree.registerRequiredCSS('profiler/profilesSidebarTree.css'); | 408 this._sidebarTree.registerRequiredCSS('profiler/profilesSidebarTree.css'); |
| 409 this.panelSidebarElement().appendChild(this._sidebarTree.element); | 409 this.panelSidebarElement().appendChild(this._sidebarTree.element); |
| 410 | 410 |
| 411 this._sidebarTree.appendChild(this.profilesItemTreeElement); | 411 this._sidebarTree.appendChild(this.profilesItemTreeElement); |
| 412 | 412 |
| 413 this.profileViews = createElement('div'); | 413 this.profileViews = createElement('div'); |
| 414 this.profileViews.id = 'profile-views'; | 414 this.profileViews.id = 'profile-views'; |
| 415 this.profileViews.classList.add('vbox'); | 415 this.profileViews.classList.add('vbox'); |
| 416 mainContainer.element.appendChild(this.profileViews); | 416 mainContainer.element.appendChild(this.profileViews); |
| 417 | 417 |
| 418 this._toolbarElement = createElementWithClass('div', 'profiles-toolbar'); | 418 this._toolbarElement = createElementWithClass('div', 'profiles-toolbar'); |
| 419 mainContainer.element.insertBefore(this._toolbarElement, mainContainer.eleme
nt.firstChild); | 419 mainContainer.element.insertBefore(this._toolbarElement, mainContainer.eleme
nt.firstChild); |
| 420 | 420 |
| 421 this.panelSidebarElement().classList.add('profiles-sidebar-tree-box'); | 421 this.panelSidebarElement().classList.add('profiles-sidebar-tree-box'); |
| 422 var toolbarContainerLeft = createElementWithClass('div', 'profiles-toolbar')
; | 422 var toolbarContainerLeft = createElementWithClass('div', 'profiles-toolbar')
; |
| 423 this.panelSidebarElement().insertBefore(toolbarContainerLeft, this.panelSide
barElement().firstChild); | 423 this.panelSidebarElement().insertBefore(toolbarContainerLeft, this.panelSide
barElement().firstChild); |
| 424 var toolbar = new WebInspector.Toolbar('', toolbarContainerLeft); | 424 var toolbar = new UI.Toolbar('', toolbarContainerLeft); |
| 425 | 425 |
| 426 this._toggleRecordAction = | 426 this._toggleRecordAction = |
| 427 /** @type {!WebInspector.Action }*/ (WebInspector.actionRegistry.action(
'profiler.toggle-recording')); | 427 /** @type {!UI.Action }*/ (UI.actionRegistry.action('profiler.toggle-rec
ording')); |
| 428 this._toggleRecordButton = WebInspector.Toolbar.createActionButton(this._tog
gleRecordAction); | 428 this._toggleRecordButton = UI.Toolbar.createActionButton(this._toggleRecordA
ction); |
| 429 toolbar.appendToolbarItem(this._toggleRecordButton); | 429 toolbar.appendToolbarItem(this._toggleRecordButton); |
| 430 | 430 |
| 431 this.clearResultsButton = | 431 this.clearResultsButton = |
| 432 new WebInspector.ToolbarButton(WebInspector.UIString('Clear all profiles
'), 'largeicon-clear'); | 432 new UI.ToolbarButton(Common.UIString('Clear all profiles'), 'largeicon-c
lear'); |
| 433 this.clearResultsButton.addEventListener('click', this._reset, this); | 433 this.clearResultsButton.addEventListener('click', this._reset, this); |
| 434 toolbar.appendToolbarItem(this.clearResultsButton); | 434 toolbar.appendToolbarItem(this.clearResultsButton); |
| 435 | 435 |
| 436 this._profileTypeToolbar = new WebInspector.Toolbar('', this._toolbarElement
); | 436 this._profileTypeToolbar = new UI.Toolbar('', this._toolbarElement); |
| 437 this._profileViewToolbar = new WebInspector.Toolbar('', this._toolbarElement
); | 437 this._profileViewToolbar = new UI.Toolbar('', this._toolbarElement); |
| 438 | 438 |
| 439 this._profileGroups = {}; | 439 this._profileGroups = {}; |
| 440 this._launcherView = new WebInspector.MultiProfileLauncherView(this); | 440 this._launcherView = new Profiler.MultiProfileLauncherView(this); |
| 441 this._launcherView.addEventListener( | 441 this._launcherView.addEventListener( |
| 442 WebInspector.MultiProfileLauncherView.Events.ProfileTypeSelected, this._
onProfileTypeSelected, this); | 442 Profiler.MultiProfileLauncherView.Events.ProfileTypeSelected, this._onPr
ofileTypeSelected, this); |
| 443 | 443 |
| 444 this._profileToView = []; | 444 this._profileToView = []; |
| 445 this._typeIdToSidebarSection = {}; | 445 this._typeIdToSidebarSection = {}; |
| 446 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes(); | 446 var types = Profiler.ProfileTypeRegistry.instance.profileTypes(); |
| 447 for (var i = 0; i < types.length; i++) | 447 for (var i = 0; i < types.length; i++) |
| 448 this._registerProfileType(types[i]); | 448 this._registerProfileType(types[i]); |
| 449 this._launcherView.restoreSelectedProfileType(); | 449 this._launcherView.restoreSelectedProfileType(); |
| 450 this.profilesItemTreeElement.select(); | 450 this.profilesItemTreeElement.select(); |
| 451 this._showLauncherView(); | 451 this._showLauncherView(); |
| 452 | 452 |
| 453 this._createFileSelectorElement(); | 453 this._createFileSelectorElement(); |
| 454 this.element.addEventListener('contextmenu', this._handleContextMenuEvent.bi
nd(this), false); | 454 this.element.addEventListener('contextmenu', this._handleContextMenuEvent.bi
nd(this), false); |
| 455 | 455 |
| 456 this.contentElement.addEventListener('keydown', this._onKeyDown.bind(this),
false); | 456 this.contentElement.addEventListener('keydown', this._onKeyDown.bind(this),
false); |
| 457 | 457 |
| 458 WebInspector.targetManager.addEventListener( | 458 SDK.targetManager.addEventListener( |
| 459 WebInspector.TargetManager.Events.SuspendStateChanged, this._onSuspendSt
ateChanged, this); | 459 SDK.TargetManager.Events.SuspendStateChanged, this._onSuspendStateChange
d, this); |
| 460 } | 460 } |
| 461 | 461 |
| 462 /** | 462 /** |
| 463 * @return {!WebInspector.ProfilesPanel} | 463 * @return {!Profiler.ProfilesPanel} |
| 464 */ | 464 */ |
| 465 static _instance() { | 465 static _instance() { |
| 466 return /** @type {!WebInspector.ProfilesPanel} */ (self.runtime.sharedInstan
ce(WebInspector.ProfilesPanel)); | 466 return /** @type {!Profiler.ProfilesPanel} */ (self.runtime.sharedInstance(P
rofiler.ProfilesPanel)); |
| 467 } | 467 } |
| 468 | 468 |
| 469 /** | 469 /** |
| 470 * @param {!Event} event | 470 * @param {!Event} event |
| 471 */ | 471 */ |
| 472 _onKeyDown(event) { | 472 _onKeyDown(event) { |
| 473 var handled = false; | 473 var handled = false; |
| 474 if (event.key === 'ArrowDown' && !event.altKey) | 474 if (event.key === 'ArrowDown' && !event.altKey) |
| 475 handled = this._sidebarTree.selectNext(); | 475 handled = this._sidebarTree.selectNext(); |
| 476 else if (event.key === 'ArrowUp' && !event.altKey) | 476 else if (event.key === 'ArrowUp' && !event.altKey) |
| 477 handled = this._sidebarTree.selectPrevious(); | 477 handled = this._sidebarTree.selectPrevious(); |
| 478 if (handled) | 478 if (handled) |
| 479 event.consume(true); | 479 event.consume(true); |
| 480 } | 480 } |
| 481 | 481 |
| 482 /** | 482 /** |
| 483 * @override | 483 * @override |
| 484 * @return {?WebInspector.SearchableView} | 484 * @return {?UI.SearchableView} |
| 485 */ | 485 */ |
| 486 searchableView() { | 486 searchableView() { |
| 487 return this.visibleView && this.visibleView.searchableView ? this.visibleVie
w.searchableView() : null; | 487 return this.visibleView && this.visibleView.searchableView ? this.visibleVie
w.searchableView() : null; |
| 488 } | 488 } |
| 489 | 489 |
| 490 _createFileSelectorElement() { | 490 _createFileSelectorElement() { |
| 491 if (this._fileSelectorElement) | 491 if (this._fileSelectorElement) |
| 492 this.element.removeChild(this._fileSelectorElement); | 492 this.element.removeChild(this._fileSelectorElement); |
| 493 this._fileSelectorElement = WebInspector.createFileSelectorElement(this._loa
dFromFile.bind(this)); | 493 this._fileSelectorElement = Bindings.createFileSelectorElement(this._loadFro
mFile.bind(this)); |
| 494 WebInspector.ProfilesPanel._fileSelectorElement = this._fileSelectorElement; | 494 Profiler.ProfilesPanel._fileSelectorElement = this._fileSelectorElement; |
| 495 this.element.appendChild(this._fileSelectorElement); | 495 this.element.appendChild(this._fileSelectorElement); |
| 496 } | 496 } |
| 497 | 497 |
| 498 _findProfileTypeByExtension(fileName) { | 498 _findProfileTypeByExtension(fileName) { |
| 499 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes(); | 499 var types = Profiler.ProfileTypeRegistry.instance.profileTypes(); |
| 500 for (var i = 0; i < types.length; i++) { | 500 for (var i = 0; i < types.length; i++) { |
| 501 var type = types[i]; | 501 var type = types[i]; |
| 502 var extension = type.fileExtension(); | 502 var extension = type.fileExtension(); |
| 503 if (!extension) | 503 if (!extension) |
| 504 continue; | 504 continue; |
| 505 if (fileName.endsWith(type.fileExtension())) | 505 if (fileName.endsWith(type.fileExtension())) |
| 506 return type; | 506 return type; |
| 507 } | 507 } |
| 508 return null; | 508 return null; |
| 509 } | 509 } |
| 510 | 510 |
| 511 /** | 511 /** |
| 512 * @param {!File} file | 512 * @param {!File} file |
| 513 */ | 513 */ |
| 514 _loadFromFile(file) { | 514 _loadFromFile(file) { |
| 515 this._createFileSelectorElement(); | 515 this._createFileSelectorElement(); |
| 516 | 516 |
| 517 var profileType = this._findProfileTypeByExtension(file.name); | 517 var profileType = this._findProfileTypeByExtension(file.name); |
| 518 if (!profileType) { | 518 if (!profileType) { |
| 519 var extensions = []; | 519 var extensions = []; |
| 520 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes(); | 520 var types = Profiler.ProfileTypeRegistry.instance.profileTypes(); |
| 521 for (var i = 0; i < types.length; i++) { | 521 for (var i = 0; i < types.length; i++) { |
| 522 var extension = types[i].fileExtension(); | 522 var extension = types[i].fileExtension(); |
| 523 if (!extension || extensions.indexOf(extension) !== -1) | 523 if (!extension || extensions.indexOf(extension) !== -1) |
| 524 continue; | 524 continue; |
| 525 extensions.push(extension); | 525 extensions.push(extension); |
| 526 } | 526 } |
| 527 WebInspector.console.error(WebInspector.UIString( | 527 Common.console.error(Common.UIString( |
| 528 'Can\'t load file. Only files with extensions \'%s\' can be loaded.',
extensions.join('\', \''))); | 528 'Can\'t load file. Only files with extensions \'%s\' can be loaded.',
extensions.join('\', \''))); |
| 529 return; | 529 return; |
| 530 } | 530 } |
| 531 | 531 |
| 532 if (!!profileType.profileBeingRecorded()) { | 532 if (!!profileType.profileBeingRecorded()) { |
| 533 WebInspector.console.error(WebInspector.UIString('Can\'t load profile whil
e another profile is recording.')); | 533 Common.console.error(Common.UIString('Can\'t load profile while another pr
ofile is recording.')); |
| 534 return; | 534 return; |
| 535 } | 535 } |
| 536 | 536 |
| 537 profileType.loadFromFile(file); | 537 profileType.loadFromFile(file); |
| 538 } | 538 } |
| 539 | 539 |
| 540 /** | 540 /** |
| 541 * @return {boolean} | 541 * @return {boolean} |
| 542 */ | 542 */ |
| 543 toggleRecord() { | 543 toggleRecord() { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 557 } | 557 } |
| 558 | 558 |
| 559 _onSuspendStateChanged() { | 559 _onSuspendStateChanged() { |
| 560 this._updateToggleRecordAction(this._toggleRecordAction.toggled()); | 560 this._updateToggleRecordAction(this._toggleRecordAction.toggled()); |
| 561 } | 561 } |
| 562 | 562 |
| 563 /** | 563 /** |
| 564 * @param {boolean} toggled | 564 * @param {boolean} toggled |
| 565 */ | 565 */ |
| 566 _updateToggleRecordAction(toggled) { | 566 _updateToggleRecordAction(toggled) { |
| 567 var enable = toggled || !WebInspector.targetManager.allTargetsSuspended(); | 567 var enable = toggled || !SDK.targetManager.allTargetsSuspended(); |
| 568 this._toggleRecordAction.setEnabled(enable); | 568 this._toggleRecordAction.setEnabled(enable); |
| 569 this._toggleRecordAction.setToggled(toggled); | 569 this._toggleRecordAction.setToggled(toggled); |
| 570 if (enable) | 570 if (enable) |
| 571 this._toggleRecordButton.setTitle(this._selectedProfileType ? this._select
edProfileType.buttonTooltip : ''); | 571 this._toggleRecordButton.setTitle(this._selectedProfileType ? this._select
edProfileType.buttonTooltip : ''); |
| 572 else | 572 else |
| 573 this._toggleRecordButton.setTitle(WebInspector.anotherProfilerActiveLabel(
)); | 573 this._toggleRecordButton.setTitle(UI.anotherProfilerActiveLabel()); |
| 574 if (this._selectedProfileType) | 574 if (this._selectedProfileType) |
| 575 this._launcherView.updateProfileType(this._selectedProfileType, enable); | 575 this._launcherView.updateProfileType(this._selectedProfileType, enable); |
| 576 } | 576 } |
| 577 | 577 |
| 578 _profileBeingRecordedRemoved() { | 578 _profileBeingRecordedRemoved() { |
| 579 this._updateToggleRecordAction(false); | 579 this._updateToggleRecordAction(false); |
| 580 this._launcherView.profileFinished(); | 580 this._launcherView.profileFinished(); |
| 581 } | 581 } |
| 582 | 582 |
| 583 /** | 583 /** |
| 584 * @param {!WebInspector.Event} event | 584 * @param {!Common.Event} event |
| 585 */ | 585 */ |
| 586 _onProfileTypeSelected(event) { | 586 _onProfileTypeSelected(event) { |
| 587 this._selectedProfileType = /** @type {!WebInspector.ProfileType} */ (event.
data); | 587 this._selectedProfileType = /** @type {!Profiler.ProfileType} */ (event.data
); |
| 588 this._updateProfileTypeSpecificUI(); | 588 this._updateProfileTypeSpecificUI(); |
| 589 } | 589 } |
| 590 | 590 |
| 591 _updateProfileTypeSpecificUI() { | 591 _updateProfileTypeSpecificUI() { |
| 592 this._updateToggleRecordAction(this._toggleRecordAction.toggled()); | 592 this._updateToggleRecordAction(this._toggleRecordAction.toggled()); |
| 593 this._profileTypeToolbar.removeToolbarItems(); | 593 this._profileTypeToolbar.removeToolbarItems(); |
| 594 var toolbarItems = this._selectedProfileType.toolbarItems(); | 594 var toolbarItems = this._selectedProfileType.toolbarItems(); |
| 595 for (var i = 0; i < toolbarItems.length; ++i) | 595 for (var i = 0; i < toolbarItems.length; ++i) |
| 596 this._profileTypeToolbar.appendToolbarItem(toolbarItems[i]); | 596 this._profileTypeToolbar.appendToolbarItem(toolbarItems[i]); |
| 597 } | 597 } |
| 598 | 598 |
| 599 _reset() { | 599 _reset() { |
| 600 var types = WebInspector.ProfileTypeRegistry.instance.profileTypes(); | 600 var types = Profiler.ProfileTypeRegistry.instance.profileTypes(); |
| 601 for (var i = 0; i < types.length; i++) | 601 for (var i = 0; i < types.length; i++) |
| 602 types[i]._reset(); | 602 types[i]._reset(); |
| 603 | 603 |
| 604 delete this.visibleView; | 604 delete this.visibleView; |
| 605 | 605 |
| 606 this._profileGroups = {}; | 606 this._profileGroups = {}; |
| 607 this._updateToggleRecordAction(false); | 607 this._updateToggleRecordAction(false); |
| 608 this._launcherView.profileFinished(); | 608 this._launcherView.profileFinished(); |
| 609 | 609 |
| 610 this._sidebarTree.element.classList.remove('some-expandable'); | 610 this._sidebarTree.element.classList.remove('some-expandable'); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 622 } | 622 } |
| 623 | 623 |
| 624 _showLauncherView() { | 624 _showLauncherView() { |
| 625 this.closeVisibleView(); | 625 this.closeVisibleView(); |
| 626 this._profileViewToolbar.removeToolbarItems(); | 626 this._profileViewToolbar.removeToolbarItems(); |
| 627 this._launcherView.show(this.profileViews); | 627 this._launcherView.show(this.profileViews); |
| 628 this.visibleView = this._launcherView; | 628 this.visibleView = this._launcherView; |
| 629 } | 629 } |
| 630 | 630 |
| 631 /** | 631 /** |
| 632 * @param {!WebInspector.ProfileType} profileType | 632 * @param {!Profiler.ProfileType} profileType |
| 633 */ | 633 */ |
| 634 _registerProfileType(profileType) { | 634 _registerProfileType(profileType) { |
| 635 this._launcherView.addProfileType(profileType); | 635 this._launcherView.addProfileType(profileType); |
| 636 var profileTypeSection = new WebInspector.ProfileTypeSidebarSection(this, pr
ofileType); | 636 var profileTypeSection = new Profiler.ProfileTypeSidebarSection(this, profil
eType); |
| 637 this._typeIdToSidebarSection[profileType.id] = profileTypeSection; | 637 this._typeIdToSidebarSection[profileType.id] = profileTypeSection; |
| 638 this._sidebarTree.appendChild(profileTypeSection); | 638 this._sidebarTree.appendChild(profileTypeSection); |
| 639 profileTypeSection.childrenListElement.addEventListener( | 639 profileTypeSection.childrenListElement.addEventListener( |
| 640 'contextmenu', this._handleContextMenuEvent.bind(this), false); | 640 'contextmenu', this._handleContextMenuEvent.bind(this), false); |
| 641 | 641 |
| 642 /** | 642 /** |
| 643 * @param {!WebInspector.Event} event | 643 * @param {!Common.Event} event |
| 644 * @this {WebInspector.ProfilesPanel} | 644 * @this {Profiler.ProfilesPanel} |
| 645 */ | 645 */ |
| 646 function onAddProfileHeader(event) { | 646 function onAddProfileHeader(event) { |
| 647 this._addProfileHeader(/** @type {!WebInspector.ProfileHeader} */ (event.d
ata)); | 647 this._addProfileHeader(/** @type {!Profiler.ProfileHeader} */ (event.data)
); |
| 648 } | 648 } |
| 649 | 649 |
| 650 /** | 650 /** |
| 651 * @param {!WebInspector.Event} event | 651 * @param {!Common.Event} event |
| 652 * @this {WebInspector.ProfilesPanel} | 652 * @this {Profiler.ProfilesPanel} |
| 653 */ | 653 */ |
| 654 function onRemoveProfileHeader(event) { | 654 function onRemoveProfileHeader(event) { |
| 655 this._removeProfileHeader(/** @type {!WebInspector.ProfileHeader} */ (even
t.data)); | 655 this._removeProfileHeader(/** @type {!Profiler.ProfileHeader} */ (event.da
ta)); |
| 656 } | 656 } |
| 657 | 657 |
| 658 /** | 658 /** |
| 659 * @param {!WebInspector.Event} event | 659 * @param {!Common.Event} event |
| 660 * @this {WebInspector.ProfilesPanel} | 660 * @this {Profiler.ProfilesPanel} |
| 661 */ | 661 */ |
| 662 function profileComplete(event) { | 662 function profileComplete(event) { |
| 663 this.showProfile(/** @type {!WebInspector.ProfileHeader} */ (event.data)); | 663 this.showProfile(/** @type {!Profiler.ProfileHeader} */ (event.data)); |
| 664 } | 664 } |
| 665 | 665 |
| 666 profileType.addEventListener(WebInspector.ProfileType.Events.ViewUpdated, th
is._updateProfileTypeSpecificUI, this); | 666 profileType.addEventListener(Profiler.ProfileType.Events.ViewUpdated, this._
updateProfileTypeSpecificUI, this); |
| 667 profileType.addEventListener(WebInspector.ProfileType.Events.AddProfileHeade
r, onAddProfileHeader, this); | 667 profileType.addEventListener(Profiler.ProfileType.Events.AddProfileHeader, o
nAddProfileHeader, this); |
| 668 profileType.addEventListener(WebInspector.ProfileType.Events.RemoveProfileHe
ader, onRemoveProfileHeader, this); | 668 profileType.addEventListener(Profiler.ProfileType.Events.RemoveProfileHeader
, onRemoveProfileHeader, this); |
| 669 profileType.addEventListener(WebInspector.ProfileType.Events.ProfileComplete
, profileComplete, this); | 669 profileType.addEventListener(Profiler.ProfileType.Events.ProfileComplete, pr
ofileComplete, this); |
| 670 | 670 |
| 671 var profiles = profileType.getProfiles(); | 671 var profiles = profileType.getProfiles(); |
| 672 for (var i = 0; i < profiles.length; i++) | 672 for (var i = 0; i < profiles.length; i++) |
| 673 this._addProfileHeader(profiles[i]); | 673 this._addProfileHeader(profiles[i]); |
| 674 } | 674 } |
| 675 | 675 |
| 676 /** | 676 /** |
| 677 * @param {!Event} event | 677 * @param {!Event} event |
| 678 */ | 678 */ |
| 679 _handleContextMenuEvent(event) { | 679 _handleContextMenuEvent(event) { |
| 680 var contextMenu = new WebInspector.ContextMenu(event); | 680 var contextMenu = new UI.ContextMenu(event); |
| 681 if (this.visibleView instanceof WebInspector.HeapSnapshotView) { | 681 if (this.visibleView instanceof Profiler.HeapSnapshotView) { |
| 682 this.visibleView.populateContextMenu(contextMenu, event); | 682 this.visibleView.populateContextMenu(contextMenu, event); |
| 683 } | 683 } |
| 684 if (this.panelSidebarElement().isSelfOrAncestor(event.srcElement)) | 684 if (this.panelSidebarElement().isSelfOrAncestor(event.srcElement)) |
| 685 contextMenu.appendItem( | 685 contextMenu.appendItem( |
| 686 WebInspector.UIString('Load\u2026'), this._fileSelectorElement.click.b
ind(this._fileSelectorElement)); | 686 Common.UIString('Load\u2026'), this._fileSelectorElement.click.bind(th
is._fileSelectorElement)); |
| 687 contextMenu.show(); | 687 contextMenu.show(); |
| 688 } | 688 } |
| 689 | 689 |
| 690 showLoadFromFileDialog() { | 690 showLoadFromFileDialog() { |
| 691 this._fileSelectorElement.click(); | 691 this._fileSelectorElement.click(); |
| 692 } | 692 } |
| 693 | 693 |
| 694 /** | 694 /** |
| 695 * @param {!WebInspector.ProfileHeader} profile | 695 * @param {!Profiler.ProfileHeader} profile |
| 696 */ | 696 */ |
| 697 _addProfileHeader(profile) { | 697 _addProfileHeader(profile) { |
| 698 var profileType = profile.profileType(); | 698 var profileType = profile.profileType(); |
| 699 var typeId = profileType.id; | 699 var typeId = profileType.id; |
| 700 this._typeIdToSidebarSection[typeId].addProfileHeader(profile); | 700 this._typeIdToSidebarSection[typeId].addProfileHeader(profile); |
| 701 if (!this.visibleView || this.visibleView === this._launcherView) | 701 if (!this.visibleView || this.visibleView === this._launcherView) |
| 702 this.showProfile(profile); | 702 this.showProfile(profile); |
| 703 } | 703 } |
| 704 | 704 |
| 705 /** | 705 /** |
| 706 * @param {!WebInspector.ProfileHeader} profile | 706 * @param {!Profiler.ProfileHeader} profile |
| 707 */ | 707 */ |
| 708 _removeProfileHeader(profile) { | 708 _removeProfileHeader(profile) { |
| 709 if (profile.profileType()._profileBeingRecorded === profile) | 709 if (profile.profileType()._profileBeingRecorded === profile) |
| 710 this._profileBeingRecordedRemoved(); | 710 this._profileBeingRecordedRemoved(); |
| 711 | 711 |
| 712 var i = this._indexOfViewForProfile(profile); | 712 var i = this._indexOfViewForProfile(profile); |
| 713 if (i !== -1) | 713 if (i !== -1) |
| 714 this._profileToView.splice(i, 1); | 714 this._profileToView.splice(i, 1); |
| 715 | 715 |
| 716 var profileType = profile.profileType(); | 716 var profileType = profile.profileType(); |
| 717 var typeId = profileType.id; | 717 var typeId = profileType.id; |
| 718 var sectionIsEmpty = this._typeIdToSidebarSection[typeId].removeProfileHeade
r(profile); | 718 var sectionIsEmpty = this._typeIdToSidebarSection[typeId].removeProfileHeade
r(profile); |
| 719 | 719 |
| 720 // No other item will be selected if there aren't any other profiles, so | 720 // No other item will be selected if there aren't any other profiles, so |
| 721 // make sure that view gets cleared when the last profile is removed. | 721 // make sure that view gets cleared when the last profile is removed. |
| 722 if (sectionIsEmpty) { | 722 if (sectionIsEmpty) { |
| 723 this.profilesItemTreeElement.select(); | 723 this.profilesItemTreeElement.select(); |
| 724 this._showLauncherView(); | 724 this._showLauncherView(); |
| 725 } | 725 } |
| 726 } | 726 } |
| 727 | 727 |
| 728 /** | 728 /** |
| 729 * @override | 729 * @override |
| 730 * @param {?WebInspector.ProfileHeader} profile | 730 * @param {?Profiler.ProfileHeader} profile |
| 731 * @return {?WebInspector.Widget} | 731 * @return {?UI.Widget} |
| 732 */ | 732 */ |
| 733 showProfile(profile) { | 733 showProfile(profile) { |
| 734 if (!profile || | 734 if (!profile || |
| 735 (profile.profileType().profileBeingRecorded() === profile) && !profile.p
rofileType().hasTemporaryView()) | 735 (profile.profileType().profileBeingRecorded() === profile) && !profile.p
rofileType().hasTemporaryView()) |
| 736 return null; | 736 return null; |
| 737 | 737 |
| 738 var view = this._viewForProfile(profile); | 738 var view = this._viewForProfile(profile); |
| 739 if (view === this.visibleView) | 739 if (view === this.visibleView) |
| 740 return view; | 740 return view; |
| 741 | 741 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 758 | 758 |
| 759 return view; | 759 return view; |
| 760 } | 760 } |
| 761 | 761 |
| 762 /** | 762 /** |
| 763 * @override | 763 * @override |
| 764 * @param {!Protocol.HeapProfiler.HeapSnapshotObjectId} snapshotObjectId | 764 * @param {!Protocol.HeapProfiler.HeapSnapshotObjectId} snapshotObjectId |
| 765 * @param {string} perspectiveName | 765 * @param {string} perspectiveName |
| 766 */ | 766 */ |
| 767 showObject(snapshotObjectId, perspectiveName) { | 767 showObject(snapshotObjectId, perspectiveName) { |
| 768 var heapProfiles = WebInspector.ProfileTypeRegistry.instance.heapSnapshotPro
fileType.getProfiles(); | 768 var heapProfiles = Profiler.ProfileTypeRegistry.instance.heapSnapshotProfile
Type.getProfiles(); |
| 769 for (var i = 0; i < heapProfiles.length; i++) { | 769 for (var i = 0; i < heapProfiles.length; i++) { |
| 770 var profile = heapProfiles[i]; | 770 var profile = heapProfiles[i]; |
| 771 // FIXME: allow to choose snapshot if there are several options. | 771 // FIXME: allow to choose snapshot if there are several options. |
| 772 if (profile.maxJSObjectId >= snapshotObjectId) { | 772 if (profile.maxJSObjectId >= snapshotObjectId) { |
| 773 this.showProfile(profile); | 773 this.showProfile(profile); |
| 774 var view = this._viewForProfile(profile); | 774 var view = this._viewForProfile(profile); |
| 775 view.selectLiveObject(perspectiveName, snapshotObjectId); | 775 view.selectLiveObject(perspectiveName, snapshotObjectId); |
| 776 break; | 776 break; |
| 777 } | 777 } |
| 778 } | 778 } |
| 779 } | 779 } |
| 780 | 780 |
| 781 /** | 781 /** |
| 782 * @param {!WebInspector.ProfileHeader} profile | 782 * @param {!Profiler.ProfileHeader} profile |
| 783 * @return {!WebInspector.Widget} | 783 * @return {!UI.Widget} |
| 784 */ | 784 */ |
| 785 _viewForProfile(profile) { | 785 _viewForProfile(profile) { |
| 786 var index = this._indexOfViewForProfile(profile); | 786 var index = this._indexOfViewForProfile(profile); |
| 787 if (index !== -1) | 787 if (index !== -1) |
| 788 return this._profileToView[index].view; | 788 return this._profileToView[index].view; |
| 789 var view = profile.createView(this); | 789 var view = profile.createView(this); |
| 790 view.element.classList.add('profile-view'); | 790 view.element.classList.add('profile-view'); |
| 791 this._profileToView.push({profile: profile, view: view}); | 791 this._profileToView.push({profile: profile, view: view}); |
| 792 return view; | 792 return view; |
| 793 } | 793 } |
| 794 | 794 |
| 795 /** | 795 /** |
| 796 * @param {!WebInspector.ProfileHeader} profile | 796 * @param {!Profiler.ProfileHeader} profile |
| 797 * @return {number} | 797 * @return {number} |
| 798 */ | 798 */ |
| 799 _indexOfViewForProfile(profile) { | 799 _indexOfViewForProfile(profile) { |
| 800 for (var i = 0; i < this._profileToView.length; i++) { | 800 for (var i = 0; i < this._profileToView.length; i++) { |
| 801 if (this._profileToView[i].profile === profile) | 801 if (this._profileToView[i].profile === profile) |
| 802 return i; | 802 return i; |
| 803 } | 803 } |
| 804 return -1; | 804 return -1; |
| 805 } | 805 } |
| 806 | 806 |
| 807 closeVisibleView() { | 807 closeVisibleView() { |
| 808 if (this.visibleView) | 808 if (this.visibleView) |
| 809 this.visibleView.detach(); | 809 this.visibleView.detach(); |
| 810 delete this.visibleView; | 810 delete this.visibleView; |
| 811 } | 811 } |
| 812 | 812 |
| 813 /** | 813 /** |
| 814 * @param {!Event} event | 814 * @param {!Event} event |
| 815 * @param {!WebInspector.ContextMenu} contextMenu | 815 * @param {!UI.ContextMenu} contextMenu |
| 816 * @param {!Object} target | 816 * @param {!Object} target |
| 817 */ | 817 */ |
| 818 appendApplicableItems(event, contextMenu, target) { | 818 appendApplicableItems(event, contextMenu, target) { |
| 819 if (!(target instanceof WebInspector.RemoteObject)) | 819 if (!(target instanceof SDK.RemoteObject)) |
| 820 return; | 820 return; |
| 821 | 821 |
| 822 if (!this.isShowing()) | 822 if (!this.isShowing()) |
| 823 return; | 823 return; |
| 824 | 824 |
| 825 var object = /** @type {!WebInspector.RemoteObject} */ (target); | 825 var object = /** @type {!SDK.RemoteObject} */ (target); |
| 826 var objectId = object.objectId; | 826 var objectId = object.objectId; |
| 827 if (!objectId) | 827 if (!objectId) |
| 828 return; | 828 return; |
| 829 | 829 |
| 830 var heapProfiles = WebInspector.ProfileTypeRegistry.instance.heapSnapshotPro
fileType.getProfiles(); | 830 var heapProfiles = Profiler.ProfileTypeRegistry.instance.heapSnapshotProfile
Type.getProfiles(); |
| 831 if (!heapProfiles.length) | 831 if (!heapProfiles.length) |
| 832 return; | 832 return; |
| 833 | 833 |
| 834 /** | 834 /** |
| 835 * @this {WebInspector.ProfilesPanel} | 835 * @this {Profiler.ProfilesPanel} |
| 836 */ | 836 */ |
| 837 function revealInView(viewName) { | 837 function revealInView(viewName) { |
| 838 object.target().heapProfilerAgent().getHeapObjectId(objectId, didReceiveHe
apObjectId.bind(this, viewName)); | 838 object.target().heapProfilerAgent().getHeapObjectId(objectId, didReceiveHe
apObjectId.bind(this, viewName)); |
| 839 } | 839 } |
| 840 | 840 |
| 841 /** | 841 /** |
| 842 * @this {WebInspector.ProfilesPanel} | 842 * @this {Profiler.ProfilesPanel} |
| 843 */ | 843 */ |
| 844 function didReceiveHeapObjectId(viewName, error, result) { | 844 function didReceiveHeapObjectId(viewName, error, result) { |
| 845 if (!this.isShowing()) | 845 if (!this.isShowing()) |
| 846 return; | 846 return; |
| 847 if (!error) | 847 if (!error) |
| 848 this.showObject(result, viewName); | 848 this.showObject(result, viewName); |
| 849 } | 849 } |
| 850 | 850 |
| 851 contextMenu.appendItem( | 851 contextMenu.appendItem( |
| 852 WebInspector.UIString.capitalize('Reveal in Summary ^view'), revealInVie
w.bind(this, 'Summary')); | 852 Common.UIString.capitalize('Reveal in Summary ^view'), revealInView.bind
(this, 'Summary')); |
| 853 } | 853 } |
| 854 | 854 |
| 855 /** | 855 /** |
| 856 * @override | 856 * @override |
| 857 */ | 857 */ |
| 858 wasShown() { | 858 wasShown() { |
| 859 WebInspector.context.setFlavor(WebInspector.ProfilesPanel, this); | 859 UI.context.setFlavor(Profiler.ProfilesPanel, this); |
| 860 } | 860 } |
| 861 | 861 |
| 862 /** | 862 /** |
| 863 * @override | 863 * @override |
| 864 */ | 864 */ |
| 865 focus() { | 865 focus() { |
| 866 this._sidebarTree.focus(); | 866 this._sidebarTree.focus(); |
| 867 } | 867 } |
| 868 | 868 |
| 869 /** | 869 /** |
| 870 * @override | 870 * @override |
| 871 */ | 871 */ |
| 872 willHide() { | 872 willHide() { |
| 873 WebInspector.context.setFlavor(WebInspector.ProfilesPanel, null); | 873 UI.context.setFlavor(Profiler.ProfilesPanel, null); |
| 874 } | 874 } |
| 875 }; | 875 }; |
| 876 | 876 |
| 877 /** | 877 /** |
| 878 * @unrestricted | 878 * @unrestricted |
| 879 */ | 879 */ |
| 880 WebInspector.ProfileTypeSidebarSection = class extends TreeElement { | 880 Profiler.ProfileTypeSidebarSection = class extends TreeElement { |
| 881 /** | 881 /** |
| 882 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate | 882 * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate |
| 883 * @param {!WebInspector.ProfileType} profileType | 883 * @param {!Profiler.ProfileType} profileType |
| 884 */ | 884 */ |
| 885 constructor(dataDisplayDelegate, profileType) { | 885 constructor(dataDisplayDelegate, profileType) { |
| 886 super(profileType.treeItemTitle.escapeHTML(), true); | 886 super(profileType.treeItemTitle.escapeHTML(), true); |
| 887 this.selectable = false; | 887 this.selectable = false; |
| 888 this._dataDisplayDelegate = dataDisplayDelegate; | 888 this._dataDisplayDelegate = dataDisplayDelegate; |
| 889 /** @type {!Array<!WebInspector.ProfileSidebarTreeElement>} */ | 889 /** @type {!Array<!Profiler.ProfileSidebarTreeElement>} */ |
| 890 this._profileTreeElements = []; | 890 this._profileTreeElements = []; |
| 891 /** @type {!Object<string, !WebInspector.ProfileTypeSidebarSection.ProfileGr
oup>} */ | 891 /** @type {!Object<string, !Profiler.ProfileTypeSidebarSection.ProfileGroup>
} */ |
| 892 this._profileGroups = {}; | 892 this._profileGroups = {}; |
| 893 this.expand(); | 893 this.expand(); |
| 894 this.hidden = true; | 894 this.hidden = true; |
| 895 } | 895 } |
| 896 | 896 |
| 897 /** | 897 /** |
| 898 * @param {!WebInspector.ProfileHeader} profile | 898 * @param {!Profiler.ProfileHeader} profile |
| 899 */ | 899 */ |
| 900 addProfileHeader(profile) { | 900 addProfileHeader(profile) { |
| 901 this.hidden = false; | 901 this.hidden = false; |
| 902 var profileType = profile.profileType(); | 902 var profileType = profile.profileType(); |
| 903 var sidebarParent = this; | 903 var sidebarParent = this; |
| 904 var profileTreeElement = profile.createSidebarTreeElement(this._dataDisplayD
elegate); | 904 var profileTreeElement = profile.createSidebarTreeElement(this._dataDisplayD
elegate); |
| 905 this._profileTreeElements.push(profileTreeElement); | 905 this._profileTreeElements.push(profileTreeElement); |
| 906 | 906 |
| 907 if (!profile.fromFile() && profileType.profileBeingRecorded() !== profile) { | 907 if (!profile.fromFile() && profileType.profileBeingRecorded() !== profile) { |
| 908 var profileTitle = profile.title; | 908 var profileTitle = profile.title; |
| 909 var group = this._profileGroups[profileTitle]; | 909 var group = this._profileGroups[profileTitle]; |
| 910 if (!group) { | 910 if (!group) { |
| 911 group = new WebInspector.ProfileTypeSidebarSection.ProfileGroup(); | 911 group = new Profiler.ProfileTypeSidebarSection.ProfileGroup(); |
| 912 this._profileGroups[profileTitle] = group; | 912 this._profileGroups[profileTitle] = group; |
| 913 } | 913 } |
| 914 group.profileSidebarTreeElements.push(profileTreeElement); | 914 group.profileSidebarTreeElements.push(profileTreeElement); |
| 915 | 915 |
| 916 var groupSize = group.profileSidebarTreeElements.length; | 916 var groupSize = group.profileSidebarTreeElements.length; |
| 917 if (groupSize === 2) { | 917 if (groupSize === 2) { |
| 918 // Make a group TreeElement now that there are 2 profiles. | 918 // Make a group TreeElement now that there are 2 profiles. |
| 919 group.sidebarTreeElement = | 919 group.sidebarTreeElement = |
| 920 new WebInspector.ProfileGroupSidebarTreeElement(this._dataDisplayDel
egate, profile.title); | 920 new Profiler.ProfileGroupSidebarTreeElement(this._dataDisplayDelegat
e, profile.title); |
| 921 | 921 |
| 922 var firstProfileTreeElement = group.profileSidebarTreeElements[0]; | 922 var firstProfileTreeElement = group.profileSidebarTreeElements[0]; |
| 923 // Insert at the same index for the first profile of the group. | 923 // Insert at the same index for the first profile of the group. |
| 924 var index = this.children().indexOf(firstProfileTreeElement); | 924 var index = this.children().indexOf(firstProfileTreeElement); |
| 925 this.insertChild(group.sidebarTreeElement, index); | 925 this.insertChild(group.sidebarTreeElement, index); |
| 926 | 926 |
| 927 // Move the first profile to the group. | 927 // Move the first profile to the group. |
| 928 var selected = firstProfileTreeElement.selected; | 928 var selected = firstProfileTreeElement.selected; |
| 929 this.removeChild(firstProfileTreeElement); | 929 this.removeChild(firstProfileTreeElement); |
| 930 group.sidebarTreeElement.appendChild(firstProfileTreeElement); | 930 group.sidebarTreeElement.appendChild(firstProfileTreeElement); |
| 931 if (selected) | 931 if (selected) |
| 932 firstProfileTreeElement.revealAndSelect(); | 932 firstProfileTreeElement.revealAndSelect(); |
| 933 | 933 |
| 934 firstProfileTreeElement.setSmall(true); | 934 firstProfileTreeElement.setSmall(true); |
| 935 firstProfileTreeElement.setMainTitle(WebInspector.UIString('Run %d', 1))
; | 935 firstProfileTreeElement.setMainTitle(Common.UIString('Run %d', 1)); |
| 936 | 936 |
| 937 this.treeOutline.element.classList.add('some-expandable'); | 937 this.treeOutline.element.classList.add('some-expandable'); |
| 938 } | 938 } |
| 939 | 939 |
| 940 if (groupSize >= 2) { | 940 if (groupSize >= 2) { |
| 941 sidebarParent = group.sidebarTreeElement; | 941 sidebarParent = group.sidebarTreeElement; |
| 942 profileTreeElement.setSmall(true); | 942 profileTreeElement.setSmall(true); |
| 943 profileTreeElement.setMainTitle(WebInspector.UIString('Run %d', groupSiz
e)); | 943 profileTreeElement.setMainTitle(Common.UIString('Run %d', groupSize)); |
| 944 } | 944 } |
| 945 } | 945 } |
| 946 | 946 |
| 947 sidebarParent.appendChild(profileTreeElement); | 947 sidebarParent.appendChild(profileTreeElement); |
| 948 } | 948 } |
| 949 | 949 |
| 950 /** | 950 /** |
| 951 * @param {!WebInspector.ProfileHeader} profile | 951 * @param {!Profiler.ProfileHeader} profile |
| 952 * @return {boolean} | 952 * @return {boolean} |
| 953 */ | 953 */ |
| 954 removeProfileHeader(profile) { | 954 removeProfileHeader(profile) { |
| 955 var index = this._sidebarElementIndex(profile); | 955 var index = this._sidebarElementIndex(profile); |
| 956 if (index === -1) | 956 if (index === -1) |
| 957 return false; | 957 return false; |
| 958 var profileTreeElement = this._profileTreeElements[index]; | 958 var profileTreeElement = this._profileTreeElements[index]; |
| 959 this._profileTreeElements.splice(index, 1); | 959 this._profileTreeElements.splice(index, 1); |
| 960 | 960 |
| 961 var sidebarParent = this; | 961 var sidebarParent = this; |
| 962 var group = this._profileGroups[profile.title]; | 962 var group = this._profileGroups[profile.title]; |
| 963 if (group) { | 963 if (group) { |
| 964 var groupElements = group.profileSidebarTreeElements; | 964 var groupElements = group.profileSidebarTreeElements; |
| 965 groupElements.splice(groupElements.indexOf(profileTreeElement), 1); | 965 groupElements.splice(groupElements.indexOf(profileTreeElement), 1); |
| 966 if (groupElements.length === 1) { | 966 if (groupElements.length === 1) { |
| 967 // Move the last profile out of its group and remove the group. | 967 // Move the last profile out of its group and remove the group. |
| 968 var pos = sidebarParent.children().indexOf( | 968 var pos = sidebarParent.children().indexOf( |
| 969 /** @type {!WebInspector.ProfileGroupSidebarTreeElement} */ (group.s
idebarTreeElement)); | 969 /** @type {!Profiler.ProfileGroupSidebarTreeElement} */ (group.sideb
arTreeElement)); |
| 970 group.sidebarTreeElement.removeChild(groupElements[0]); | 970 group.sidebarTreeElement.removeChild(groupElements[0]); |
| 971 this.insertChild(groupElements[0], pos); | 971 this.insertChild(groupElements[0], pos); |
| 972 groupElements[0].setSmall(false); | 972 groupElements[0].setSmall(false); |
| 973 groupElements[0].setMainTitle(profile.title); | 973 groupElements[0].setMainTitle(profile.title); |
| 974 this.removeChild(group.sidebarTreeElement); | 974 this.removeChild(group.sidebarTreeElement); |
| 975 } | 975 } |
| 976 if (groupElements.length !== 0) | 976 if (groupElements.length !== 0) |
| 977 sidebarParent = group.sidebarTreeElement; | 977 sidebarParent = group.sidebarTreeElement; |
| 978 } | 978 } |
| 979 sidebarParent.removeChild(profileTreeElement); | 979 sidebarParent.removeChild(profileTreeElement); |
| 980 profileTreeElement.dispose(); | 980 profileTreeElement.dispose(); |
| 981 | 981 |
| 982 if (this.childCount()) | 982 if (this.childCount()) |
| 983 return false; | 983 return false; |
| 984 this.hidden = true; | 984 this.hidden = true; |
| 985 return true; | 985 return true; |
| 986 } | 986 } |
| 987 | 987 |
| 988 /** | 988 /** |
| 989 * @param {!WebInspector.ProfileHeader} profile | 989 * @param {!Profiler.ProfileHeader} profile |
| 990 * @return {?WebInspector.ProfileSidebarTreeElement} | 990 * @return {?Profiler.ProfileSidebarTreeElement} |
| 991 */ | 991 */ |
| 992 sidebarElementForProfile(profile) { | 992 sidebarElementForProfile(profile) { |
| 993 var index = this._sidebarElementIndex(profile); | 993 var index = this._sidebarElementIndex(profile); |
| 994 return index === -1 ? null : this._profileTreeElements[index]; | 994 return index === -1 ? null : this._profileTreeElements[index]; |
| 995 } | 995 } |
| 996 | 996 |
| 997 /** | 997 /** |
| 998 * @param {!WebInspector.ProfileHeader} profile | 998 * @param {!Profiler.ProfileHeader} profile |
| 999 * @return {number} | 999 * @return {number} |
| 1000 */ | 1000 */ |
| 1001 _sidebarElementIndex(profile) { | 1001 _sidebarElementIndex(profile) { |
| 1002 var elements = this._profileTreeElements; | 1002 var elements = this._profileTreeElements; |
| 1003 for (var i = 0; i < elements.length; i++) { | 1003 for (var i = 0; i < elements.length; i++) { |
| 1004 if (elements[i].profile === profile) | 1004 if (elements[i].profile === profile) |
| 1005 return i; | 1005 return i; |
| 1006 } | 1006 } |
| 1007 return -1; | 1007 return -1; |
| 1008 } | 1008 } |
| 1009 | 1009 |
| 1010 /** | 1010 /** |
| 1011 * @override | 1011 * @override |
| 1012 */ | 1012 */ |
| 1013 onattach() { | 1013 onattach() { |
| 1014 this.listItemElement.classList.add('profiles-tree-section'); | 1014 this.listItemElement.classList.add('profiles-tree-section'); |
| 1015 } | 1015 } |
| 1016 }; | 1016 }; |
| 1017 | 1017 |
| 1018 /** | 1018 /** |
| 1019 * @unrestricted | 1019 * @unrestricted |
| 1020 */ | 1020 */ |
| 1021 WebInspector.ProfileTypeSidebarSection.ProfileGroup = class { | 1021 Profiler.ProfileTypeSidebarSection.ProfileGroup = class { |
| 1022 constructor() { | 1022 constructor() { |
| 1023 /** @type {!Array<!WebInspector.ProfileSidebarTreeElement>} */ | 1023 /** @type {!Array<!Profiler.ProfileSidebarTreeElement>} */ |
| 1024 this.profileSidebarTreeElements = []; | 1024 this.profileSidebarTreeElements = []; |
| 1025 /** @type {?WebInspector.ProfileGroupSidebarTreeElement} */ | 1025 /** @type {?Profiler.ProfileGroupSidebarTreeElement} */ |
| 1026 this.sidebarTreeElement = null; | 1026 this.sidebarTreeElement = null; |
| 1027 } | 1027 } |
| 1028 }; | 1028 }; |
| 1029 | 1029 |
| 1030 /** | 1030 /** |
| 1031 * @implements {WebInspector.ContextMenu.Provider} | 1031 * @implements {UI.ContextMenu.Provider} |
| 1032 * @unrestricted | 1032 * @unrestricted |
| 1033 */ | 1033 */ |
| 1034 WebInspector.ProfilesPanel.ContextMenuProvider = class { | 1034 Profiler.ProfilesPanel.ContextMenuProvider = class { |
| 1035 /** | 1035 /** |
| 1036 * @override | 1036 * @override |
| 1037 * @param {!Event} event | 1037 * @param {!Event} event |
| 1038 * @param {!WebInspector.ContextMenu} contextMenu | 1038 * @param {!UI.ContextMenu} contextMenu |
| 1039 * @param {!Object} target | 1039 * @param {!Object} target |
| 1040 */ | 1040 */ |
| 1041 appendApplicableItems(event, contextMenu, target) { | 1041 appendApplicableItems(event, contextMenu, target) { |
| 1042 WebInspector.ProfilesPanel._instance().appendApplicableItems(event, contextM
enu, target); | 1042 Profiler.ProfilesPanel._instance().appendApplicableItems(event, contextMenu,
target); |
| 1043 } | 1043 } |
| 1044 }; | 1044 }; |
| 1045 | 1045 |
| 1046 /** | 1046 /** |
| 1047 * @unrestricted | 1047 * @unrestricted |
| 1048 */ | 1048 */ |
| 1049 WebInspector.ProfileSidebarTreeElement = class extends TreeElement { | 1049 Profiler.ProfileSidebarTreeElement = class extends TreeElement { |
| 1050 /** | 1050 /** |
| 1051 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate | 1051 * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate |
| 1052 * @param {!WebInspector.ProfileHeader} profile | 1052 * @param {!Profiler.ProfileHeader} profile |
| 1053 * @param {string} className | 1053 * @param {string} className |
| 1054 */ | 1054 */ |
| 1055 constructor(dataDisplayDelegate, profile, className) { | 1055 constructor(dataDisplayDelegate, profile, className) { |
| 1056 super('', false); | 1056 super('', false); |
| 1057 this._iconElement = createElementWithClass('div', 'icon'); | 1057 this._iconElement = createElementWithClass('div', 'icon'); |
| 1058 this._titlesElement = createElementWithClass('div', 'titles no-subtitle'); | 1058 this._titlesElement = createElementWithClass('div', 'titles no-subtitle'); |
| 1059 this._titleContainer = this._titlesElement.createChild('span', 'title-contai
ner'); | 1059 this._titleContainer = this._titlesElement.createChild('span', 'title-contai
ner'); |
| 1060 this._titleElement = this._titleContainer.createChild('span', 'title'); | 1060 this._titleElement = this._titleContainer.createChild('span', 'title'); |
| 1061 this._subtitleElement = this._titlesElement.createChild('span', 'subtitle'); | 1061 this._subtitleElement = this._titlesElement.createChild('span', 'subtitle'); |
| 1062 | 1062 |
| 1063 this._titleElement.textContent = profile.title; | 1063 this._titleElement.textContent = profile.title; |
| 1064 this._className = className; | 1064 this._className = className; |
| 1065 this._small = false; | 1065 this._small = false; |
| 1066 this._dataDisplayDelegate = dataDisplayDelegate; | 1066 this._dataDisplayDelegate = dataDisplayDelegate; |
| 1067 this.profile = profile; | 1067 this.profile = profile; |
| 1068 profile.addEventListener(WebInspector.ProfileHeader.Events.UpdateStatus, thi
s._updateStatus, this); | 1068 profile.addEventListener(Profiler.ProfileHeader.Events.UpdateStatus, this._u
pdateStatus, this); |
| 1069 if (profile.canSaveToFile()) | 1069 if (profile.canSaveToFile()) |
| 1070 this._createSaveLink(); | 1070 this._createSaveLink(); |
| 1071 else | 1071 else |
| 1072 profile.addEventListener(WebInspector.ProfileHeader.Events.ProfileReceived
, this._onProfileReceived, this); | 1072 profile.addEventListener(Profiler.ProfileHeader.Events.ProfileReceived, th
is._onProfileReceived, this); |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 _createSaveLink() { | 1075 _createSaveLink() { |
| 1076 this._saveLinkElement = this._titleContainer.createChild('span', 'save-link'
); | 1076 this._saveLinkElement = this._titleContainer.createChild('span', 'save-link'
); |
| 1077 this._saveLinkElement.textContent = WebInspector.UIString('Save'); | 1077 this._saveLinkElement.textContent = Common.UIString('Save'); |
| 1078 this._saveLinkElement.addEventListener('click', this._saveProfile.bind(this)
, false); | 1078 this._saveLinkElement.addEventListener('click', this._saveProfile.bind(this)
, false); |
| 1079 } | 1079 } |
| 1080 | 1080 |
| 1081 _onProfileReceived(event) { | 1081 _onProfileReceived(event) { |
| 1082 this._createSaveLink(); | 1082 this._createSaveLink(); |
| 1083 } | 1083 } |
| 1084 | 1084 |
| 1085 /** | 1085 /** |
| 1086 * @param {!WebInspector.Event} event | 1086 * @param {!Common.Event} event |
| 1087 */ | 1087 */ |
| 1088 _updateStatus(event) { | 1088 _updateStatus(event) { |
| 1089 var statusUpdate = event.data; | 1089 var statusUpdate = event.data; |
| 1090 if (statusUpdate.subtitle !== null) { | 1090 if (statusUpdate.subtitle !== null) { |
| 1091 this._subtitleElement.textContent = statusUpdate.subtitle || ''; | 1091 this._subtitleElement.textContent = statusUpdate.subtitle || ''; |
| 1092 this._titlesElement.classList.toggle('no-subtitle', !statusUpdate.subtitle
); | 1092 this._titlesElement.classList.toggle('no-subtitle', !statusUpdate.subtitle
); |
| 1093 } | 1093 } |
| 1094 if (typeof statusUpdate.wait === 'boolean' && this.listItemElement) | 1094 if (typeof statusUpdate.wait === 'boolean' && this.listItemElement) |
| 1095 this.listItemElement.classList.toggle('wait', statusUpdate.wait); | 1095 this.listItemElement.classList.toggle('wait', statusUpdate.wait); |
| 1096 } | 1096 } |
| 1097 | 1097 |
| 1098 dispose() { | 1098 dispose() { |
| 1099 this.profile.removeEventListener(WebInspector.ProfileHeader.Events.UpdateSta
tus, this._updateStatus, this); | 1099 this.profile.removeEventListener(Profiler.ProfileHeader.Events.UpdateStatus,
this._updateStatus, this); |
| 1100 this.profile.removeEventListener(WebInspector.ProfileHeader.Events.ProfileRe
ceived, this._onProfileReceived, this); | 1100 this.profile.removeEventListener(Profiler.ProfileHeader.Events.ProfileReceiv
ed, this._onProfileReceived, this); |
| 1101 } | 1101 } |
| 1102 | 1102 |
| 1103 /** | 1103 /** |
| 1104 * @override | 1104 * @override |
| 1105 * @return {boolean} | 1105 * @return {boolean} |
| 1106 */ | 1106 */ |
| 1107 onselect() { | 1107 onselect() { |
| 1108 this._dataDisplayDelegate.showProfile(this.profile); | 1108 this._dataDisplayDelegate.showProfile(this.profile); |
| 1109 return true; | 1109 return true; |
| 1110 } | 1110 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1128 this.listItemElement.classList.add('small'); | 1128 this.listItemElement.classList.add('small'); |
| 1129 this.listItemElement.appendChildren(this._iconElement, this._titlesElement); | 1129 this.listItemElement.appendChildren(this._iconElement, this._titlesElement); |
| 1130 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu
Event.bind(this), true); | 1130 this.listItemElement.addEventListener('contextmenu', this._handleContextMenu
Event.bind(this), true); |
| 1131 } | 1131 } |
| 1132 | 1132 |
| 1133 /** | 1133 /** |
| 1134 * @param {!Event} event | 1134 * @param {!Event} event |
| 1135 */ | 1135 */ |
| 1136 _handleContextMenuEvent(event) { | 1136 _handleContextMenuEvent(event) { |
| 1137 var profile = this.profile; | 1137 var profile = this.profile; |
| 1138 var contextMenu = new WebInspector.ContextMenu(event); | 1138 var contextMenu = new UI.ContextMenu(event); |
| 1139 // FIXME: use context menu provider | 1139 // FIXME: use context menu provider |
| 1140 contextMenu.appendItem( | 1140 contextMenu.appendItem( |
| 1141 WebInspector.UIString('Load\u2026'), | 1141 Common.UIString('Load\u2026'), |
| 1142 WebInspector.ProfilesPanel._fileSelectorElement.click.bind(WebInspector.
ProfilesPanel._fileSelectorElement)); | 1142 Profiler.ProfilesPanel._fileSelectorElement.click.bind(Profiler.Profiles
Panel._fileSelectorElement)); |
| 1143 if (profile.canSaveToFile()) | 1143 if (profile.canSaveToFile()) |
| 1144 contextMenu.appendItem(WebInspector.UIString('Save\u2026'), profile.saveTo
File.bind(profile)); | 1144 contextMenu.appendItem(Common.UIString('Save\u2026'), profile.saveToFile.b
ind(profile)); |
| 1145 contextMenu.appendItem(WebInspector.UIString('Delete'), this.ondelete.bind(t
his)); | 1145 contextMenu.appendItem(Common.UIString('Delete'), this.ondelete.bind(this)); |
| 1146 contextMenu.show(); | 1146 contextMenu.show(); |
| 1147 } | 1147 } |
| 1148 | 1148 |
| 1149 _saveProfile(event) { | 1149 _saveProfile(event) { |
| 1150 this.profile.saveToFile(); | 1150 this.profile.saveToFile(); |
| 1151 } | 1151 } |
| 1152 | 1152 |
| 1153 /** | 1153 /** |
| 1154 * @param {boolean} small | 1154 * @param {boolean} small |
| 1155 */ | 1155 */ |
| 1156 setSmall(small) { | 1156 setSmall(small) { |
| 1157 this._small = small; | 1157 this._small = small; |
| 1158 if (this.listItemElement) | 1158 if (this.listItemElement) |
| 1159 this.listItemElement.classList.toggle('small', this._small); | 1159 this.listItemElement.classList.toggle('small', this._small); |
| 1160 } | 1160 } |
| 1161 | 1161 |
| 1162 /** | 1162 /** |
| 1163 * @param {string} title | 1163 * @param {string} title |
| 1164 */ | 1164 */ |
| 1165 setMainTitle(title) { | 1165 setMainTitle(title) { |
| 1166 this._titleElement.textContent = title; | 1166 this._titleElement.textContent = title; |
| 1167 } | 1167 } |
| 1168 }; | 1168 }; |
| 1169 | 1169 |
| 1170 /** | 1170 /** |
| 1171 * @unrestricted | 1171 * @unrestricted |
| 1172 */ | 1172 */ |
| 1173 WebInspector.ProfileGroupSidebarTreeElement = class extends TreeElement { | 1173 Profiler.ProfileGroupSidebarTreeElement = class extends TreeElement { |
| 1174 /** | 1174 /** |
| 1175 * @param {!WebInspector.ProfileType.DataDisplayDelegate} dataDisplayDelegate | 1175 * @param {!Profiler.ProfileType.DataDisplayDelegate} dataDisplayDelegate |
| 1176 * @param {string} title | 1176 * @param {string} title |
| 1177 */ | 1177 */ |
| 1178 constructor(dataDisplayDelegate, title) { | 1178 constructor(dataDisplayDelegate, title) { |
| 1179 super('', true); | 1179 super('', true); |
| 1180 this.selectable = false; | 1180 this.selectable = false; |
| 1181 this._dataDisplayDelegate = dataDisplayDelegate; | 1181 this._dataDisplayDelegate = dataDisplayDelegate; |
| 1182 this._title = title; | 1182 this._title = title; |
| 1183 this.expand(); | 1183 this.expand(); |
| 1184 this.toggleOnClick = true; | 1184 this.toggleOnClick = true; |
| 1185 } | 1185 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1204 this.listItemElement.createChild('div', 'titles no-subtitle') | 1204 this.listItemElement.createChild('div', 'titles no-subtitle') |
| 1205 .createChild('span', 'title-container') | 1205 .createChild('span', 'title-container') |
| 1206 .createChild('span', 'title') | 1206 .createChild('span', 'title') |
| 1207 .textContent = this._title; | 1207 .textContent = this._title; |
| 1208 } | 1208 } |
| 1209 }; | 1209 }; |
| 1210 | 1210 |
| 1211 /** | 1211 /** |
| 1212 * @unrestricted | 1212 * @unrestricted |
| 1213 */ | 1213 */ |
| 1214 WebInspector.ProfilesSidebarTreeElement = class extends TreeElement { | 1214 Profiler.ProfilesSidebarTreeElement = class extends TreeElement { |
| 1215 /** | 1215 /** |
| 1216 * @param {!WebInspector.ProfilesPanel} panel | 1216 * @param {!Profiler.ProfilesPanel} panel |
| 1217 */ | 1217 */ |
| 1218 constructor(panel) { | 1218 constructor(panel) { |
| 1219 super('', false); | 1219 super('', false); |
| 1220 this.selectable = true; | 1220 this.selectable = true; |
| 1221 this._panel = panel; | 1221 this._panel = panel; |
| 1222 } | 1222 } |
| 1223 | 1223 |
| 1224 /** | 1224 /** |
| 1225 * @override | 1225 * @override |
| 1226 * @return {boolean} | 1226 * @return {boolean} |
| 1227 */ | 1227 */ |
| 1228 onselect() { | 1228 onselect() { |
| 1229 this._panel._showLauncherView(); | 1229 this._panel._showLauncherView(); |
| 1230 return true; | 1230 return true; |
| 1231 } | 1231 } |
| 1232 | 1232 |
| 1233 /** | 1233 /** |
| 1234 * @override | 1234 * @override |
| 1235 */ | 1235 */ |
| 1236 onattach() { | 1236 onattach() { |
| 1237 this.listItemElement.classList.add('profile-launcher-view-tree-item'); | 1237 this.listItemElement.classList.add('profile-launcher-view-tree-item'); |
| 1238 this.listItemElement.createChild('div', 'icon'); | 1238 this.listItemElement.createChild('div', 'icon'); |
| 1239 this.listItemElement.createChild('div', 'titles no-subtitle') | 1239 this.listItemElement.createChild('div', 'titles no-subtitle') |
| 1240 .createChild('span', 'title-container') | 1240 .createChild('span', 'title-container') |
| 1241 .createChild('span', 'title') | 1241 .createChild('span', 'title') |
| 1242 .textContent = WebInspector.UIString('Profiles'); | 1242 .textContent = Common.UIString('Profiles'); |
| 1243 } | 1243 } |
| 1244 }; | 1244 }; |
| 1245 | 1245 |
| 1246 | 1246 |
| 1247 /** | 1247 /** |
| 1248 * @implements {WebInspector.ActionDelegate} | 1248 * @implements {UI.ActionDelegate} |
| 1249 * @unrestricted | 1249 * @unrestricted |
| 1250 */ | 1250 */ |
| 1251 WebInspector.ProfilesPanel.RecordActionDelegate = class { | 1251 Profiler.ProfilesPanel.RecordActionDelegate = class { |
| 1252 /** | 1252 /** |
| 1253 * @override | 1253 * @override |
| 1254 * @param {!WebInspector.Context} context | 1254 * @param {!UI.Context} context |
| 1255 * @param {string} actionId | 1255 * @param {string} actionId |
| 1256 * @return {boolean} | 1256 * @return {boolean} |
| 1257 */ | 1257 */ |
| 1258 handleAction(context, actionId) { | 1258 handleAction(context, actionId) { |
| 1259 var panel = WebInspector.context.flavor(WebInspector.ProfilesPanel); | 1259 var panel = UI.context.flavor(Profiler.ProfilesPanel); |
| 1260 console.assert(panel && panel instanceof WebInspector.ProfilesPanel); | 1260 console.assert(panel && panel instanceof Profiler.ProfilesPanel); |
| 1261 panel.toggleRecord(); | 1261 panel.toggleRecord(); |
| 1262 return true; | 1262 return true; |
| 1263 } | 1263 } |
| 1264 }; | 1264 }; |
| OLD | NEW |