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 22 matching lines...) Expand all Loading... |
33 * @extends {WebInspector.SDKModel} | 33 * @extends {WebInspector.SDKModel} |
34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
35 */ | 35 */ |
36 WebInspector.ConsoleModel = function(target) | 36 WebInspector.ConsoleModel = function(target) |
37 { | 37 { |
38 WebInspector.SDKModel.call(this, WebInspector.ConsoleModel, target); | 38 WebInspector.SDKModel.call(this, WebInspector.ConsoleModel, target); |
39 | 39 |
40 /** @type {!Array.<!WebInspector.ConsoleMessage>} */ | 40 /** @type {!Array.<!WebInspector.ConsoleMessage>} */ |
41 this._messages = []; | 41 this._messages = []; |
42 /** @type {!Map<number, !WebInspector.ConsoleMessage>} */ | 42 /** @type {!Map<number, !WebInspector.ConsoleMessage>} */ |
43 this._messageById = new Map(); | 43 this._messageByExceptionId = new Map(); |
44 this._warnings = 0; | 44 this._warnings = 0; |
45 this._errors = 0; | 45 this._errors = 0; |
46 this._revokedErrors = 0; | 46 this._revokedErrors = 0; |
47 this._consoleAgent = target.consoleAgent(); | 47 this._consoleAgent = target.consoleAgent(); |
48 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this)); | 48 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this)); |
49 this._enableAgent(); | 49 this._enableAgent(); |
50 } | 50 } |
51 | 51 |
52 WebInspector.ConsoleModel.Events = { | 52 WebInspector.ConsoleModel.Events = { |
53 ConsoleCleared: "ConsoleCleared", | 53 ConsoleCleared: "ConsoleCleared", |
(...skipping 18 matching lines...) Expand all Loading... |
72 }, | 72 }, |
73 | 73 |
74 /** | 74 /** |
75 * @param {!WebInspector.ConsoleMessage} msg | 75 * @param {!WebInspector.ConsoleMessage} msg |
76 */ | 76 */ |
77 addMessage: function(msg) | 77 addMessage: function(msg) |
78 { | 78 { |
79 if (this._isBlacklisted(msg)) | 79 if (this._isBlacklisted(msg)) |
80 return; | 80 return; |
81 | 81 |
82 if (msg.level === WebInspector.ConsoleMessage.MessageLevel.RevokedError
&& msg._relatedMessageId) { | 82 if (msg.level === WebInspector.ConsoleMessage.MessageLevel.RevokedError
&& msg._revokedExceptionId) { |
83 var relatedMessage = this._messageById.get(msg._relatedMessageId); | 83 var exceptionMessage = this._messageByExceptionId.get(msg._revokedEx
ceptionId); |
84 if (!relatedMessage) | 84 if (!exceptionMessage) |
85 return; | 85 return; |
86 this._errors--; | 86 this._errors--; |
87 this._revokedErrors++; | 87 this._revokedErrors++; |
88 relatedMessage.level = WebInspector.ConsoleMessage.MessageLevel.Revo
kedError; | 88 exceptionMessage.level = WebInspector.ConsoleMessage.MessageLevel.Re
vokedError; |
89 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.Messa
geUpdated, relatedMessage); | 89 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.Messa
geUpdated, exceptionMessage); |
90 return; | 90 return; |
91 } | 91 } |
92 | 92 |
93 this._messages.push(msg); | 93 this._messages.push(msg); |
94 if (msg._messageId) | 94 if (msg._exceptionId) |
95 this._messageById.set(msg._messageId, msg); | 95 this._messageByExceptionId.set(msg._exceptionId, msg); |
96 this._incrementErrorWarningCount(msg); | 96 this._incrementErrorWarningCount(msg); |
97 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAd
ded, msg); | 97 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAd
ded, msg); |
98 }, | 98 }, |
99 | 99 |
100 /** | 100 /** |
101 * @param {!WebInspector.ConsoleMessage} msg | 101 * @param {!WebInspector.ConsoleMessage} msg |
102 */ | 102 */ |
103 _incrementErrorWarningCount: function(msg) | 103 _incrementErrorWarningCount: function(msg) |
104 { | 104 { |
105 switch (msg.level) { | 105 switch (msg.level) { |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 | 141 |
142 requestClearMessages: function() | 142 requestClearMessages: function() |
143 { | 143 { |
144 this._consoleAgent.clearMessages(); | 144 this._consoleAgent.clearMessages(); |
145 this._messagesCleared(); | 145 this._messagesCleared(); |
146 }, | 146 }, |
147 | 147 |
148 _messagesCleared: function() | 148 _messagesCleared: function() |
149 { | 149 { |
150 this._messages = []; | 150 this._messages = []; |
151 this._messageById.clear(); | 151 this._messageByExceptionId.clear(); |
152 this._errors = 0; | 152 this._errors = 0; |
153 this._revokedErrors = 0; | 153 this._revokedErrors = 0; |
154 this._warnings = 0; | 154 this._warnings = 0; |
155 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCl
eared); | 155 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCl
eared); |
156 }, | 156 }, |
157 | 157 |
158 /** | 158 /** |
159 * @return {number} | 159 * @return {number} |
160 */ | 160 */ |
161 errors: function() | 161 errors: function() |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 * @param {string=} type | 237 * @param {string=} type |
238 * @param {?string=} url | 238 * @param {?string=} url |
239 * @param {number=} line | 239 * @param {number=} line |
240 * @param {number=} column | 240 * @param {number=} column |
241 * @param {!NetworkAgent.RequestId=} requestId | 241 * @param {!NetworkAgent.RequestId=} requestId |
242 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters | 242 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters |
243 * @param {!RuntimeAgent.StackTrace=} stackTrace | 243 * @param {!RuntimeAgent.StackTrace=} stackTrace |
244 * @param {number=} timestamp | 244 * @param {number=} timestamp |
245 * @param {!RuntimeAgent.ExecutionContextId=} executionContextId | 245 * @param {!RuntimeAgent.ExecutionContextId=} executionContextId |
246 * @param {?string=} scriptId | 246 * @param {?string=} scriptId |
247 * @param {number=} messageId | |
248 * @param {number=} relatedMessageId | |
249 */ | 247 */ |
250 WebInspector.ConsoleMessage = function(target, source, level, messageText, type,
url, line, column, requestId, parameters, stackTrace, timestamp, executionConte
xtId, scriptId, messageId, relatedMessageId) | 248 WebInspector.ConsoleMessage = function(target, source, level, messageText, type,
url, line, column, requestId, parameters, stackTrace, timestamp, executionConte
xtId, scriptId) |
251 { | 249 { |
252 this._target = target; | 250 this._target = target; |
253 this.source = source; | 251 this.source = source; |
254 this.level = level; | 252 this.level = level; |
255 this.messageText = messageText; | 253 this.messageText = messageText; |
256 this.type = type || WebInspector.ConsoleMessage.MessageType.Log; | 254 this.type = type || WebInspector.ConsoleMessage.MessageType.Log; |
257 /** @type {string|undefined} */ | 255 /** @type {string|undefined} */ |
258 this.url = url || undefined; | 256 this.url = url || undefined; |
259 /** @type {number} */ | 257 /** @type {number} */ |
260 this.line = line || 0; | 258 this.line = line || 0; |
261 /** @type {number} */ | 259 /** @type {number} */ |
262 this.column = column || 0; | 260 this.column = column || 0; |
263 this.parameters = parameters; | 261 this.parameters = parameters; |
264 /** @type {!RuntimeAgent.StackTrace|undefined} */ | 262 /** @type {!RuntimeAgent.StackTrace|undefined} */ |
265 this.stackTrace = stackTrace; | 263 this.stackTrace = stackTrace; |
266 this.timestamp = timestamp || Date.now(); | 264 this.timestamp = timestamp || Date.now(); |
267 this.executionContextId = executionContextId || 0; | 265 this.executionContextId = executionContextId || 0; |
268 this.scriptId = scriptId || null; | 266 this.scriptId = scriptId || null; |
269 this._messageId = messageId || 0; | |
270 this._relatedMessageId = relatedMessageId || 0; | |
271 | 267 |
272 this.request = requestId ? target.networkLog.requestForId(requestId) : null; | 268 this.request = requestId ? target.networkLog.requestForId(requestId) : null; |
273 | 269 |
274 if (this.request) { | 270 if (this.request) { |
275 var initiator = this.request.initiator(); | 271 var initiator = this.request.initiator(); |
276 if (initiator) { | 272 if (initiator) { |
277 this.stackTrace = initiator.stack || undefined; | 273 this.stackTrace = initiator.stack || undefined; |
278 if (initiator.url) { | 274 if (initiator.url) { |
279 this.url = initiator.url; | 275 this.url = initiator.url; |
280 this.line = initiator.lineNumber || 0; | 276 this.line = initiator.lineNumber || 0; |
(...skipping 22 matching lines...) Expand all Loading... |
303 | 299 |
304 /** | 300 /** |
305 * @param {!RuntimeAgent.ExecutionContextId} executionContextId | 301 * @param {!RuntimeAgent.ExecutionContextId} executionContextId |
306 */ | 302 */ |
307 setExecutionContextId: function(executionContextId) | 303 setExecutionContextId: function(executionContextId) |
308 { | 304 { |
309 this.executionContextId = executionContextId; | 305 this.executionContextId = executionContextId; |
310 }, | 306 }, |
311 | 307 |
312 /** | 308 /** |
| 309 * @param {number} exceptionId |
| 310 */ |
| 311 setExceptionId: function(exceptionId) |
| 312 { |
| 313 this._exceptionId = exceptionId; |
| 314 }, |
| 315 |
| 316 /** |
| 317 * @param {number} revokedExceptionId |
| 318 */ |
| 319 setRevokedExceptionId: function(revokedExceptionId) |
| 320 { |
| 321 this._revokedExceptionId = revokedExceptionId; |
| 322 }, |
| 323 |
| 324 /** |
313 * @return {?WebInspector.ConsoleMessage} | 325 * @return {?WebInspector.ConsoleMessage} |
314 */ | 326 */ |
315 originatingMessage: function() | 327 originatingMessage: function() |
316 { | 328 { |
317 return this._originatingConsoleMessage; | 329 return this._originatingConsoleMessage; |
318 }, | 330 }, |
319 | 331 |
320 /** | 332 /** |
321 * @return {boolean} | 333 * @return {boolean} |
322 */ | 334 */ |
(...skipping 23 matching lines...) Expand all Loading... |
346 | 358 |
347 /** | 359 /** |
348 * @param {?WebInspector.ConsoleMessage} msg | 360 * @param {?WebInspector.ConsoleMessage} msg |
349 * @return {boolean} | 361 * @return {boolean} |
350 */ | 362 */ |
351 isEqual: function(msg) | 363 isEqual: function(msg) |
352 { | 364 { |
353 if (!msg) | 365 if (!msg) |
354 return false; | 366 return false; |
355 | 367 |
356 if (this._messageId || msg._messageId) | 368 if (this._exceptionId || msg._exceptionId) |
357 return false; | 369 return false; |
358 if (this._relatedMessageId || msg._relatedMessageId) | 370 if (this._revokedExceptionId || msg._revokedExceptionId) |
359 return false; | 371 return false; |
360 | 372 |
361 if (!this._isEqualStackTraces(this.stackTrace, msg.stackTrace)) | 373 if (!this._isEqualStackTraces(this.stackTrace, msg.stackTrace)) |
362 return false; | 374 return false; |
363 | 375 |
364 if (this.parameters) { | 376 if (this.parameters) { |
365 if (!msg.parameters || this.parameters.length !== msg.parameters.len
gth) | 377 if (!msg.parameters || this.parameters.length !== msg.parameters.len
gth) |
366 return false; | 378 return false; |
367 | 379 |
368 for (var i = 0; i < msg.parameters.length; ++i) { | 380 for (var i = 0; i < msg.parameters.length; ++i) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 462 |
451 /** | 463 /** |
452 * @enum {string} | 464 * @enum {string} |
453 */ | 465 */ |
454 WebInspector.ConsoleMessage.MessageLevel = { | 466 WebInspector.ConsoleMessage.MessageLevel = { |
455 Log: "log", | 467 Log: "log", |
456 Info: "info", | 468 Info: "info", |
457 Warning: "warning", | 469 Warning: "warning", |
458 Error: "error", | 470 Error: "error", |
459 Debug: "debug", | 471 Debug: "debug", |
460 RevokedError: "revokedError" | 472 RevokedError: "revokedError" // This is frontend-only level, used to put ex
ceptions to console. |
461 }; | 473 }; |
462 | 474 |
463 /** | 475 /** |
464 * @param {!WebInspector.ConsoleMessage} a | 476 * @param {!WebInspector.ConsoleMessage} a |
465 * @param {!WebInspector.ConsoleMessage} b | 477 * @param {!WebInspector.ConsoleMessage} b |
466 * @return {number} | 478 * @return {number} |
467 */ | 479 */ |
468 WebInspector.ConsoleMessage.timestampComparator = function(a, b) | 480 WebInspector.ConsoleMessage.timestampComparator = function(a, b) |
469 { | 481 { |
470 return a.timestamp - b.timestamp; | 482 return a.timestamp - b.timestamp; |
(...skipping 23 matching lines...) Expand all Loading... |
494 payload.text, | 506 payload.text, |
495 payload.type, | 507 payload.type, |
496 payload.url, | 508 payload.url, |
497 payload.line, | 509 payload.line, |
498 payload.column, | 510 payload.column, |
499 payload.networkRequestId, | 511 payload.networkRequestId, |
500 payload.parameters, | 512 payload.parameters, |
501 payload.stack, | 513 payload.stack, |
502 payload.timestamp * 1000, // Convert to ms. | 514 payload.timestamp * 1000, // Convert to ms. |
503 payload.executionContextId, | 515 payload.executionContextId, |
504 payload.scriptId, | 516 payload.scriptId); |
505 payload.messageId, | |
506 payload.relatedMessageId); | |
507 this._console.addMessage(consoleMessage); | 517 this._console.addMessage(consoleMessage); |
508 }, | 518 }, |
509 | 519 |
510 /** | 520 /** |
511 * @override | 521 * @override |
512 * @param {number} count | 522 * @param {number} count |
513 */ | 523 */ |
514 messageRepeatCountUpdated: function(count) | 524 messageRepeatCountUpdated: function(count) |
515 { | 525 { |
516 }, | 526 }, |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
604 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv
aluated, event.data); | 614 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv
aluated, event.data); |
605 }, | 615 }, |
606 | 616 |
607 __proto__: WebInspector.Object.prototype | 617 __proto__: WebInspector.Object.prototype |
608 } | 618 } |
609 | 619 |
610 /** | 620 /** |
611 * @type {!WebInspector.MultitargetConsoleModel} | 621 * @type {!WebInspector.MultitargetConsoleModel} |
612 */ | 622 */ |
613 WebInspector.multitargetConsoleModel; | 623 WebInspector.multitargetConsoleModel; |
OLD | NEW |