Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: Source/devtools/front_end/ConsoleModel.js

Issue 222143003: DevTools: Make ConsoleMessage TargetAware (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@console-cpp-exec-context
Patch Set: Rebase Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Source/devtools/front_end/CPUProfileView.js ('k') | Source/devtools/front_end/ConsoleView.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 }, 95 },
96 96
97 /** 97 /**
98 * @param {string} text 98 * @param {string} text
99 * @param {boolean} useCommandLineAPI 99 * @param {boolean} useCommandLineAPI
100 */ 100 */
101 evaluateCommand: function(text, useCommandLineAPI) 101 evaluateCommand: function(text, useCommandLineAPI)
102 { 102 {
103 this.show(); 103 this.show();
104 104
105 var commandMessage = new WebInspector.ConsoleMessage(WebInspector.Consol eMessage.MessageSource.JS, null, text, WebInspector.ConsoleMessage.MessageType.C ommand); 105 var commandMessage = new WebInspector.ConsoleMessage(this.target(), WebI nspector.ConsoleMessage.MessageSource.JS, null, text, WebInspector.ConsoleMessag e.MessageType.Command);
106 this.addMessage(commandMessage); 106 this.addMessage(commandMessage);
107 107
108 /** 108 /**
109 * @param {?WebInspector.RemoteObject} result 109 * @param {?WebInspector.RemoteObject} result
110 * @param {boolean} wasThrown 110 * @param {boolean} wasThrown
111 * @param {?RuntimeAgent.RemoteObject=} valueResult 111 * @param {?RuntimeAgent.RemoteObject=} valueResult
112 * @this {WebInspector.ConsoleModel} 112 * @this {WebInspector.ConsoleModel}
113 */ 113 */
114 function printResult(result, wasThrown, valueResult) 114 function printResult(result, wasThrown, valueResult)
115 { 115 {
(...skipping 21 matching lines...) Expand all
137 }, 137 },
138 138
139 /** 139 /**
140 * @param {string} messageText 140 * @param {string} messageText
141 * @param {!WebInspector.ConsoleMessage.MessageLevel=} messageLevel 141 * @param {!WebInspector.ConsoleMessage.MessageLevel=} messageLevel
142 * @param {boolean=} showConsole 142 * @param {boolean=} showConsole
143 */ 143 */
144 log: function(messageText, messageLevel, showConsole) 144 log: function(messageText, messageLevel, showConsole)
145 { 145 {
146 var message = new WebInspector.ConsoleMessage( 146 var message = new WebInspector.ConsoleMessage(
147 this.target(),
147 WebInspector.ConsoleMessage.MessageSource.Other, 148 WebInspector.ConsoleMessage.MessageSource.Other,
148 messageLevel || WebInspector.ConsoleMessage.MessageLevel.Debug, 149 messageLevel || WebInspector.ConsoleMessage.MessageLevel.Debug,
149 messageText); 150 messageText);
150 151
151 this.addMessage(message); 152 this.addMessage(message);
152 if (showConsole) 153 if (showConsole)
153 this.show(); 154 this.show();
154 }, 155 },
155 156
156 /** 157 /**
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 this.messages = []; 190 this.messages = [];
190 this.errors = 0; 191 this.errors = 0;
191 this.warnings = 0; 192 this.warnings = 0;
192 }, 193 },
193 194
194 __proto__: WebInspector.TargetAwareObject.prototype 195 __proto__: WebInspector.TargetAwareObject.prototype
195 } 196 }
196 197
197 /** 198 /**
198 * @constructor 199 * @constructor
200 * @extends {WebInspector.TargetAware}
201 * @param {!WebInspector.Target} target
199 * @param {string} source 202 * @param {string} source
200 * @param {?string} level 203 * @param {?string} level
201 * @param {string} messageText 204 * @param {string} messageText
202 * @param {string=} type 205 * @param {string=} type
203 * @param {?string=} url 206 * @param {?string=} url
204 * @param {number=} line 207 * @param {number=} line
205 * @param {number=} column 208 * @param {number=} column
206 * @param {!NetworkAgent.RequestId=} requestId 209 * @param {!NetworkAgent.RequestId=} requestId
207 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters 210 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters
208 * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace 211 * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace
209 * @param {number=} timestamp 212 * @param {number=} timestamp
210 * @param {boolean=} isOutdated 213 * @param {boolean=} isOutdated
211 * @param {!RuntimeAgent.ExecutionContextId=} executionContextId 214 * @param {!RuntimeAgent.ExecutionContextId=} executionContextId
212 */ 215 */
213 216 WebInspector.ConsoleMessage = function(target, source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, isOutdated, ex ecutionContextId)
214 WebInspector.ConsoleMessage = function(source, level, messageText, type, url, li ne, column, requestId, parameters, stackTrace, timestamp, isOutdated, executionC ontextId)
215 { 217 {
218 WebInspector.TargetAware.call(this, target);
216 this.source = source; 219 this.source = source;
217 this.level = level; 220 this.level = level;
218 this.messageText = messageText; 221 this.messageText = messageText;
219 this.type = type || WebInspector.ConsoleMessage.MessageType.Log; 222 this.type = type || WebInspector.ConsoleMessage.MessageType.Log;
220 this.url = url || null; 223 this.url = url || null;
221 this.line = line || 0; 224 this.line = line || 0;
222 this.column = column || 0; 225 this.column = column || 0;
223 this.parameters = parameters; 226 this.parameters = parameters;
224 this.stackTrace = stackTrace; 227 this.stackTrace = stackTrace;
225 this.timestamp = timestamp || Date.now(); 228 this.timestamp = timestamp || Date.now();
(...skipping 22 matching lines...) Expand all
248 { 251 {
249 return (this.level === WebInspector.ConsoleMessage.MessageLevel.Warning || this.level === WebInspector.ConsoleMessage.MessageLevel.Error); 252 return (this.level === WebInspector.ConsoleMessage.MessageLevel.Warning || this.level === WebInspector.ConsoleMessage.MessageLevel.Error);
250 }, 253 },
251 254
252 /** 255 /**
253 * @return {!WebInspector.ConsoleMessage} 256 * @return {!WebInspector.ConsoleMessage}
254 */ 257 */
255 clone: function() 258 clone: function()
256 { 259 {
257 return new WebInspector.ConsoleMessage( 260 return new WebInspector.ConsoleMessage(
261 this.target(),
258 this.source, 262 this.source,
259 this.level, 263 this.level,
260 this.messageText, 264 this.messageText,
261 this.type, 265 this.type,
262 this.url, 266 this.url,
263 this.line, 267 this.line,
264 this.column, 268 this.column,
265 this.request ? this.request.requestId : undefined, 269 this.request ? this.request.requestId : undefined,
266 this.parameters, 270 this.parameters,
267 this.stackTrace, 271 this.stackTrace,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 307 }
304 } 308 }
305 309
306 return (this.source === msg.source) 310 return (this.source === msg.source)
307 && (this.type === msg.type) 311 && (this.type === msg.type)
308 && (this.level === msg.level) 312 && (this.level === msg.level)
309 && (this.line === msg.line) 313 && (this.line === msg.line)
310 && (this.url === msg.url) 314 && (this.url === msg.url)
311 && (this.messageText === msg.messageText) 315 && (this.messageText === msg.messageText)
312 && (this.request === msg.request); 316 && (this.request === msg.request);
313 } 317 },
318
319 __proto__: WebInspector.TargetAware.prototype
314 } 320 }
315 321
316 // Note: Keep these constants in sync with the ones in Console.h 322 // Note: Keep these constants in sync with the ones in Console.h
317 /** 323 /**
318 * @enum {string} 324 * @enum {string}
319 */ 325 */
320 WebInspector.ConsoleMessage.MessageSource = { 326 WebInspector.ConsoleMessage.MessageSource = {
321 XML: "xml", 327 XML: "xml",
322 JS: "javascript", 328 JS: "javascript",
323 Network: "network", 329 Network: "network",
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 this._console = console; 378 this._console = console;
373 } 379 }
374 380
375 WebInspector.ConsoleDispatcher.prototype = { 381 WebInspector.ConsoleDispatcher.prototype = {
376 /** 382 /**
377 * @param {!ConsoleAgent.ConsoleMessage} payload 383 * @param {!ConsoleAgent.ConsoleMessage} payload
378 */ 384 */
379 messageAdded: function(payload) 385 messageAdded: function(payload)
380 { 386 {
381 var consoleMessage = new WebInspector.ConsoleMessage( 387 var consoleMessage = new WebInspector.ConsoleMessage(
388 this._console.target(),
382 payload.source, 389 payload.source,
383 payload.level, 390 payload.level,
384 payload.text, 391 payload.text,
385 payload.type, 392 payload.type,
386 payload.url, 393 payload.url,
387 payload.line, 394 payload.line,
388 payload.column, 395 payload.column,
389 payload.networkRequestId, 396 payload.networkRequestId,
390 payload.parameters, 397 payload.parameters,
391 payload.stackTrace, 398 payload.stackTrace,
(...skipping 14 matching lines...) Expand all
406 { 413 {
407 if (!WebInspector.settings.preserveConsoleLog.get()) 414 if (!WebInspector.settings.preserveConsoleLog.get())
408 this._console.clearMessages(); 415 this._console.clearMessages();
409 } 416 }
410 } 417 }
411 418
412 /** 419 /**
413 * @type {!WebInspector.ConsoleModel} 420 * @type {!WebInspector.ConsoleModel}
414 */ 421 */
415 WebInspector.console; 422 WebInspector.console;
OLDNEW
« no previous file with comments | « Source/devtools/front_end/CPUProfileView.js ('k') | Source/devtools/front_end/ConsoleView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698