| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @extends {WebInspector.VBox} | 7 * @extends {WebInspector.VBox} |
| 8 */ | 8 */ |
| 9 WebInspector.PromisesPanel = function() | 9 WebInspector.PromisePane = function() |
| 10 { | 10 { |
| 11 WebInspector.VBox.call(this); | 11 WebInspector.VBox.call(this); |
| 12 this.registerRequiredCSS("promises/promisesPanel.css"); | 12 this.registerRequiredCSS("promises/promisePane.css"); |
| 13 this.element.classList.add("promises"); | 13 this.element.classList.add("promises"); |
| 14 | 14 |
| 15 var statusBar = this.element.createChild("div", "panel-status-bar"); | 15 var statusBar = this.element.createChild("div", "panel-status-bar"); |
| 16 this._recordButton = new WebInspector.StatusBarButton(WebInspector.UIString(
"Record Promises"), "record-profile-status-bar-item"); | 16 this._recordButton = new WebInspector.StatusBarButton(WebInspector.UIString(
"Record Promises"), "record-profile-status-bar-item"); |
| 17 this._recordButton.addEventListener("click", this._recordButtonClicked.bind(
this)); | 17 this._recordButton.addEventListener("click", this._recordButtonClicked.bind(
this)); |
| 18 statusBar.appendChild(this._recordButton.element); | 18 statusBar.appendChild(this._recordButton.element); |
| 19 var clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("Cl
ear"), "clear-status-bar-item"); | 19 var clearButton = new WebInspector.StatusBarButton(WebInspector.UIString("Cl
ear"), "clear-status-bar-item"); |
| 20 clearButton.addEventListener("click", this._clearButtonClicked.bind(this)); | 20 clearButton.addEventListener("click", this._clearButtonClicked.bind(this)); |
| 21 statusBar.appendChild(clearButton.element); | 21 statusBar.appendChild(clearButton.element); |
| 22 this._refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString
("Refresh"), "refresh-storage-status-bar-item"); | 22 this._refreshButton = new WebInspector.StatusBarButton(WebInspector.UIString
("Refresh"), "refresh-storage-status-bar-item"); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 34 { id: "location", title: WebInspector.UIString("Location"), disclosure:
true }, | 34 { id: "location", title: WebInspector.UIString("Location"), disclosure:
true }, |
| 35 { id: "status", title: WebInspector.UIString("Status") }, | 35 { id: "status", title: WebInspector.UIString("Status") }, |
| 36 { id: "tts", title: WebInspector.UIString("Time to settle") } | 36 { id: "tts", title: WebInspector.UIString("Time to settle") } |
| 37 ]; | 37 ]; |
| 38 this._dataGrid = new WebInspector.DataGrid(columns, undefined, undefined, un
defined, this._onContextMenu.bind(this)); | 38 this._dataGrid = new WebInspector.DataGrid(columns, undefined, undefined, un
defined, this._onContextMenu.bind(this)); |
| 39 this._dataGrid.show(this._dataGridContainer.element); | 39 this._dataGrid.show(this._dataGridContainer.element); |
| 40 | 40 |
| 41 this._linkifier = new WebInspector.Linkifier(); | 41 this._linkifier = new WebInspector.Linkifier(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 WebInspector.PromisesPanel.prototype = { | 44 WebInspector.PromisePane.prototype = { |
| 45 _recordButtonClicked: function(event) | 45 _recordButtonClicked: function(event) |
| 46 { | 46 { |
| 47 var recording = !this._recordButton.toggled; | 47 var recording = !this._recordButton.toggled; |
| 48 this._recordButton.toggled = recording; | 48 this._recordButton.toggled = recording; |
| 49 this._refreshButton.setEnabled(recording); | 49 this._refreshButton.setEnabled(recording); |
| 50 if (recording) | 50 if (recording) |
| 51 this._enablePromiseTracker(); | 51 this._enablePromiseTracker(); |
| 52 else | 52 else |
| 53 this._disablePromiseTracker(); | 53 this._disablePromiseTracker(); |
| 54 }, | 54 }, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 var t1 = p1.creationTime || 0; | 90 var t1 = p1.creationTime || 0; |
| 91 var t2 = p2.creationTime || 0; | 91 var t2 = p2.creationTime || 0; |
| 92 return t1 - t2; | 92 return t1 - t2; |
| 93 }, | 93 }, |
| 94 | 94 |
| 95 _updateData: function() | 95 _updateData: function() |
| 96 { | 96 { |
| 97 /** | 97 /** |
| 98 * @param {?Protocol.Error} error | 98 * @param {?Protocol.Error} error |
| 99 * @param {?Array.<!DebuggerAgent.PromiseDetails>} promiseData | 99 * @param {?Array.<!DebuggerAgent.PromiseDetails>} promiseData |
| 100 * @this {WebInspector.PromisesPanel} | 100 * @this {WebInspector.PromisePane} |
| 101 */ | 101 */ |
| 102 function callback(error, promiseData) | 102 function callback(error, promiseData) |
| 103 { | 103 { |
| 104 if (error || !promiseData) | 104 if (error || !promiseData) |
| 105 return; | 105 return; |
| 106 | 106 |
| 107 promiseData.sort(this._comparePromises); | 107 promiseData.sort(this._comparePromises); |
| 108 var nodesToInsert = { __proto__: null }; | 108 var nodesToInsert = { __proto__: null }; |
| 109 for (var i = 0; i < promiseData.length; i++) { | 109 for (var i = 0; i < promiseData.length; i++) { |
| 110 var promise = promiseData[i]; | 110 var promise = promiseData[i]; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 _onContextMenu: function(contextMenu, node) | 152 _onContextMenu: function(contextMenu, node) |
| 153 { | 153 { |
| 154 if (!this._target) | 154 if (!this._target) |
| 155 return; | 155 return; |
| 156 var promiseId = node.data.promiseId; | 156 var promiseId = node.data.promiseId; |
| 157 | 157 |
| 158 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe
nuTitles() ? "Show in console" : "Show In Console"), showPromiseInConsole.bind(t
his)); | 158 contextMenu.appendItem(WebInspector.UIString(WebInspector.useLowerCaseMe
nuTitles() ? "Show in console" : "Show In Console"), showPromiseInConsole.bind(t
his)); |
| 159 contextMenu.show(); | 159 contextMenu.show(); |
| 160 | 160 |
| 161 /** | 161 /** |
| 162 * @this {WebInspector.PromisesPanel} | 162 * @this {WebInspector.PromisePane} |
| 163 */ | 163 */ |
| 164 function showPromiseInConsole() | 164 function showPromiseInConsole() |
| 165 { | 165 { |
| 166 if (this._target) | 166 if (this._target) |
| 167 this._target.debuggerAgent().getPromiseById(promiseId, "console"
, didGetPromiseById.bind(this)); | 167 this._target.debuggerAgent().getPromiseById(promiseId, "console"
, didGetPromiseById.bind(this)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 /** | 170 /** |
| 171 * @param {?Protocol.Error} error | 171 * @param {?Protocol.Error} error |
| 172 * @param {?RuntimeAgent.RemoteObject} promise | 172 * @param {?RuntimeAgent.RemoteObject} promise |
| 173 * @this {WebInspector.PromisesPanel} | 173 * @this {WebInspector.PromisePane} |
| 174 */ | 174 */ |
| 175 function didGetPromiseById(error, promise) | 175 function didGetPromiseById(error, promise) |
| 176 { | 176 { |
| 177 if (error || !promise) | 177 if (error || !promise) |
| 178 return; | 178 return; |
| 179 | 179 |
| 180 if (!this._target) | 180 if (!this._target) |
| 181 return; | 181 return; |
| 182 | 182 |
| 183 this._target.consoleAgent().setLastEvaluationResult(promise.objectId
); | 183 this._target.consoleAgent().setLastEvaluationResult(promise.objectId
); |
| 184 var message = new WebInspector.ConsoleMessage(this._target, | 184 var message = new WebInspector.ConsoleMessage(this._target, |
| 185 WebInspector.ConsoleMe
ssage.MessageSource.Other, | 185 WebInspector.ConsoleMe
ssage.MessageSource.Other, |
| 186 WebInspector.ConsoleMe
ssage.MessageLevel.Log, | 186 WebInspector.ConsoleMe
ssage.MessageLevel.Log, |
| 187 "", | 187 "", |
| 188 WebInspector.ConsoleMe
ssage.MessageType.Log, | 188 WebInspector.ConsoleMe
ssage.MessageType.Log, |
| 189 undefined, | 189 undefined, |
| 190 undefined, | 190 undefined, |
| 191 undefined, | 191 undefined, |
| 192 undefined, | 192 undefined, |
| 193 [promise]); | 193 [promise]); |
| 194 this._target.consoleModel.addMessage(message); | 194 this._target.consoleModel.addMessage(message); |
| 195 WebInspector.console.show(); | 195 WebInspector.console.show(); |
| 196 } | 196 } |
| 197 }, | 197 }, |
| 198 | 198 |
| 199 __proto__: WebInspector.VBox.prototype | 199 __proto__: WebInspector.VBox.prototype |
| 200 } | 200 } |
| 201 | |
| OLD | NEW |