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 26 matching lines...) Expand all Loading... |
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._messageByExceptionId = 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._logAgent = target.logAgent(); |
48 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this)); | 48 target.registerLogDispatcher(new WebInspector.LogDispatcher(this)); |
49 this._enableAgent(); | 49 this._logAgent.enable(); |
50 } | 50 } |
51 | 51 |
52 WebInspector.ConsoleModel.Events = { | 52 WebInspector.ConsoleModel.Events = { |
53 ConsoleCleared: "ConsoleCleared", | 53 ConsoleCleared: "ConsoleCleared", |
54 MessageAdded: "MessageAdded", | 54 MessageAdded: "MessageAdded", |
55 MessageUpdated: "MessageUpdated", | 55 MessageUpdated: "MessageUpdated", |
56 CommandEvaluated: "CommandEvaluated", | 56 CommandEvaluated: "CommandEvaluated", |
57 } | 57 } |
58 | 58 |
59 WebInspector.ConsoleModel.prototype = { | 59 WebInspector.ConsoleModel.prototype = { |
60 _enableAgent: function() | |
61 { | |
62 this._enablingConsole = true; | |
63 | |
64 /** | |
65 * @this {WebInspector.ConsoleModel} | |
66 */ | |
67 function callback() | |
68 { | |
69 delete this._enablingConsole; | |
70 } | |
71 this._consoleAgent.enable(callback.bind(this)); | |
72 }, | |
73 | |
74 /** | 60 /** |
75 * @param {!WebInspector.ConsoleMessage} msg | 61 * @param {!WebInspector.ConsoleMessage} msg |
76 */ | 62 */ |
77 addMessage: function(msg) | 63 addMessage: function(msg) |
78 { | 64 { |
79 if (this._isBlacklisted(msg)) | 65 if (this._isBlacklisted(msg)) |
80 return; | 66 return; |
81 | 67 |
82 if (msg.source === WebInspector.ConsoleMessage.MessageSource.Worker && m
sg.target().workerManager && msg.target().workerManager.targetByWorkerId(msg.wor
kerId)) | 68 if (msg.source === WebInspector.ConsoleMessage.MessageSource.Worker && m
sg.target().workerManager && msg.target().workerManager.targetByWorkerId(msg.wor
kerId)) |
83 return; | 69 return; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 /** | 126 /** |
141 * @return {!Array.<!WebInspector.ConsoleMessage>} | 127 * @return {!Array.<!WebInspector.ConsoleMessage>} |
142 */ | 128 */ |
143 messages: function() | 129 messages: function() |
144 { | 130 { |
145 return this._messages; | 131 return this._messages; |
146 }, | 132 }, |
147 | 133 |
148 requestClearMessages: function() | 134 requestClearMessages: function() |
149 { | 135 { |
150 this._consoleAgent.clearMessages(); | 136 this._logAgent.clear(); |
151 this.clear(); | 137 this.clear(); |
152 }, | 138 }, |
153 | 139 |
154 clear: function() | 140 clear: function() |
155 { | 141 { |
156 this._messages = []; | 142 this._messages = []; |
157 this._messageByExceptionId.clear(); | 143 this._messageByExceptionId.clear(); |
158 this._errors = 0; | 144 this._errors = 0; |
159 this._revokedErrors = 0; | 145 this._revokedErrors = 0; |
160 this._warnings = 0; | 146 this._warnings = 0; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 230 } |
245 } | 231 } |
246 | 232 |
247 if (looksLikeAnObjectLiteral(text)) | 233 if (looksLikeAnObjectLiteral(text)) |
248 text = "(" + text + ")"; | 234 text = "(" + text + ")"; |
249 | 235 |
250 executionContext.evaluate(text, "console", !!useCommandLineAPI, false, false
, true, true, printResult); | 236 executionContext.evaluate(text, "console", !!useCommandLineAPI, false, false
, true, true, printResult); |
251 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Console
Evaluated); | 237 WebInspector.userMetrics.actionTaken(WebInspector.UserMetrics.Action.Console
Evaluated); |
252 } | 238 } |
253 | 239 |
254 WebInspector.ConsoleModel.clearConsole = function() | |
255 { | |
256 var targets = WebInspector.targetManager.targets(); | |
257 for (var i = 0; i < targets.length; ++i) | |
258 targets[i].consoleModel.requestClearMessages(); | |
259 } | |
260 | |
261 | |
262 /** | 240 /** |
263 * @constructor | 241 * @constructor |
264 * @param {?WebInspector.Target} target | 242 * @param {?WebInspector.Target} target |
265 * @param {string} source | 243 * @param {string} source |
266 * @param {?string} level | 244 * @param {?string} level |
267 * @param {string} messageText | 245 * @param {string} messageText |
268 * @param {string=} type | 246 * @param {string=} type |
269 * @param {?string=} url | 247 * @param {?string=} url |
270 * @param {number=} line | 248 * @param {number=} line |
271 * @param {number=} column | 249 * @param {number=} column |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
516 * @param {!WebInspector.ConsoleMessage} b | 494 * @param {!WebInspector.ConsoleMessage} b |
517 * @return {number} | 495 * @return {number} |
518 */ | 496 */ |
519 WebInspector.ConsoleMessage.timestampComparator = function(a, b) | 497 WebInspector.ConsoleMessage.timestampComparator = function(a, b) |
520 { | 498 { |
521 return a.timestamp - b.timestamp; | 499 return a.timestamp - b.timestamp; |
522 } | 500 } |
523 | 501 |
524 /** | 502 /** |
525 * @constructor | 503 * @constructor |
526 * @implements {ConsoleAgent.Dispatcher} | 504 * @implements {LogAgent.Dispatcher} |
527 * @param {!WebInspector.ConsoleModel} console | 505 * @param {!WebInspector.ConsoleModel} console |
528 */ | 506 */ |
529 WebInspector.ConsoleDispatcher = function(console) | 507 WebInspector.LogDispatcher = function(console) |
530 { | 508 { |
531 this._console = console; | 509 this._console = console; |
532 } | 510 } |
533 | 511 |
534 WebInspector.ConsoleDispatcher.prototype = { | 512 WebInspector.LogDispatcher.prototype = { |
535 /** | 513 /** |
536 * @override | 514 * @override |
537 * @param {!ConsoleAgent.ConsoleMessage} payload | 515 * @param {!LogAgent.LogEntry} payload |
538 */ | 516 */ |
539 messageAdded: function(payload) | 517 entryAdded: function(payload) |
540 { | 518 { |
541 if (payload.source === WebInspector.ConsoleMessage.MessageSource.Console
API) | |
542 return; | |
543 var consoleMessage = new WebInspector.ConsoleMessage( | 519 var consoleMessage = new WebInspector.ConsoleMessage( |
544 this._console.target(), | 520 this._console.target(), |
545 payload.source, | 521 payload.source, |
546 payload.level, | 522 payload.level, |
547 payload.text, | 523 payload.text, |
548 payload.type, | 524 undefined, |
549 payload.url, | 525 payload.url, |
550 payload.line, | 526 typeof payload.lineNumber === "undefined" ? undefined : payload.line
Number + 1, |
551 payload.column, | 527 undefined, |
552 payload.networkRequestId, | 528 payload.networkRequestId, |
553 payload.parameters, | 529 undefined, |
554 payload.stack, | 530 payload.stackTrace, |
555 payload.timestamp, | 531 payload.timestamp, |
556 payload.executionContextId, | 532 undefined, |
557 payload.scriptId, | 533 undefined, |
558 payload.workerId); | 534 payload.workerId); |
559 this._console.addMessage(consoleMessage); | 535 this._console.addMessage(consoleMessage); |
560 }, | |
561 | |
562 /** | |
563 * @override | |
564 * @param {number} count | |
565 */ | |
566 messageRepeatCountUpdated: function(count) | |
567 { | |
568 }, | |
569 | |
570 /** | |
571 * @override | |
572 */ | |
573 messagesCleared: function() | |
574 { | |
575 } | 536 } |
576 } | 537 } |
577 | 538 |
578 /** | 539 /** |
579 * @constructor | 540 * @constructor |
580 * @extends {WebInspector.Object} | 541 * @extends {WebInspector.Object} |
581 * @implements {WebInspector.TargetManager.Observer} | 542 * @implements {WebInspector.TargetManager.Observer} |
582 */ | 543 */ |
583 WebInspector.MultitargetConsoleModel = function() | 544 WebInspector.MultitargetConsoleModel = function() |
584 { | 545 { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv
aluated, event.data); | 615 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.CommandEv
aluated, event.data); |
655 }, | 616 }, |
656 | 617 |
657 __proto__: WebInspector.Object.prototype | 618 __proto__: WebInspector.Object.prototype |
658 } | 619 } |
659 | 620 |
660 /** | 621 /** |
661 * @type {!WebInspector.MultitargetConsoleModel} | 622 * @type {!WebInspector.MultitargetConsoleModel} |
662 */ | 623 */ |
663 WebInspector.multitargetConsoleModel; | 624 WebInspector.multitargetConsoleModel; |
OLD | NEW |