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

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

Issue 211023002: DevTools: Remove event Console.messageRepeatCountUpdated (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
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 21 matching lines...) Expand all
32 * @constructor 32 * @constructor
33 * @extends {WebInspector.Object} 33 * @extends {WebInspector.Object}
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 /** @type {!Array.<!WebInspector.ConsoleMessage>} */ 38 /** @type {!Array.<!WebInspector.ConsoleMessage>} */
39 this.messages = []; 39 this.messages = [];
40 this.warnings = 0; 40 this.warnings = 0;
41 this.errors = 0; 41 this.errors = 0;
42 this._interruptRepeatCount = false;
43 this._target = target; 42 this._target = target;
44 this._consoleAgent = target.consoleAgent(); 43 this._consoleAgent = target.consoleAgent();
45 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this)); 44 target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this));
46 this._enableAgent(); 45 this._enableAgent();
47 } 46 }
48 47
49 WebInspector.ConsoleModel.Events = { 48 WebInspector.ConsoleModel.Events = {
50 ConsoleCleared: "ConsoleCleared", 49 ConsoleCleared: "ConsoleCleared",
51 MessageAdded: "MessageAdded", 50 MessageAdded: "MessageAdded",
52 RepeatCountUpdated: "RepeatCountUpdated",
53 CommandEvaluated: "CommandEvaluated", 51 CommandEvaluated: "CommandEvaluated",
54 } 52 }
55 53
56 WebInspector.ConsoleModel.prototype = { 54 WebInspector.ConsoleModel.prototype = {
57 _enableAgent: function() 55 _enableAgent: function()
58 { 56 {
59 if (WebInspector.settings.monitoringXHREnabled.get()) 57 if (WebInspector.settings.monitoringXHREnabled.get())
60 this._consoleAgent.setMonitoringXHREnabled(true); 58 this._consoleAgent.setMonitoringXHREnabled(true);
61 59
62 this._enablingConsole = true; 60 this._enablingConsole = true;
(...skipping 22 matching lines...) Expand all
85 */ 83 */
86 addMessage: function(msg, isFromBackend) 84 addMessage: function(msg, isFromBackend)
87 { 85 {
88 if (isFromBackend && WebInspector.SourceMap.hasSourceMapRequestHeader(ms g.request)) 86 if (isFromBackend && WebInspector.SourceMap.hasSourceMapRequestHeader(ms g.request))
89 return; 87 return;
90 88
91 msg.index = this.messages.length; 89 msg.index = this.messages.length;
92 this.messages.push(msg); 90 this.messages.push(msg);
93 this._incrementErrorWarningCount(msg); 91 this._incrementErrorWarningCount(msg);
94 92
95 if (isFromBackend)
96 this._previousMessage = msg;
97
98 this._interruptRepeatCount = !isFromBackend;
99
100 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAd ded, msg); 93 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.MessageAd ded, msg);
101 }, 94 },
102 95
103 /** 96 /**
104 * @param {string} text 97 * @param {string} text
105 * @param {boolean} useCommandLineAPI 98 * @param {boolean} useCommandLineAPI
106 */ 99 */
107 evaluateCommand: function(text, useCommandLineAPI) 100 evaluateCommand: function(text, useCommandLineAPI)
108 { 101 {
109 this.show(); 102 this.show();
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 this.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true); 160 this.log(error, WebInspector.ConsoleMessage.MessageLevel.Error, true);
168 }, 161 },
169 162
170 /** 163 /**
171 * @param {!WebInspector.ConsoleMessage} msg 164 * @param {!WebInspector.ConsoleMessage} msg
172 */ 165 */
173 _incrementErrorWarningCount: function(msg) 166 _incrementErrorWarningCount: function(msg)
174 { 167 {
175 switch (msg.level) { 168 switch (msg.level) {
176 case WebInspector.ConsoleMessage.MessageLevel.Warning: 169 case WebInspector.ConsoleMessage.MessageLevel.Warning:
177 this.warnings += msg.repeatDelta; 170 this.warnings += 1;
pfeldman 2014/03/25 13:09:32 ++
sergeyv 2014/03/25 13:42:56 Done.
178 break; 171 break;
179 case WebInspector.ConsoleMessage.MessageLevel.Error: 172 case WebInspector.ConsoleMessage.MessageLevel.Error:
180 this.errors += msg.repeatDelta; 173 this.errors += 1;
181 break; 174 break;
182 } 175 }
183 }, 176 },
184 177
185 requestClearMessages: function() 178 requestClearMessages: function()
186 { 179 {
187 this._consoleAgent.clearMessages(); 180 this._consoleAgent.clearMessages();
188 this.clearMessages(); 181 this.clearMessages();
189 }, 182 },
190 183
191 clearMessages: function() 184 clearMessages: function()
192 { 185 {
193 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCl eared); 186 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.ConsoleCl eared);
194 187
195 this.messages = []; 188 this.messages = [];
196 delete this._previousMessage;
197
198 this.errors = 0; 189 this.errors = 0;
199 this.warnings = 0; 190 this.warnings = 0;
200 }, 191 },
201 192
202 /**
203 * @param {number} count
204 */
205 _messageRepeatCountUpdated: function(count)
206 {
207 var msg = this._previousMessage;
208 if (!msg)
209 return;
210
211 var prevRepeatCount = msg.totalRepeatCount;
212
213 if (!this._interruptRepeatCount) {
214 msg.repeatDelta = count - prevRepeatCount;
215 msg.repeatCount = msg.repeatCount + msg.repeatDelta;
216 msg.totalRepeatCount = count;
217
218 this._incrementErrorWarningCount(msg);
219 this.dispatchEventToListeners(WebInspector.ConsoleModel.Events.Repea tCountUpdated, msg);
220 } else {
221 var msgCopy = msg.clone();
222 msgCopy.totalRepeatCount = count;
223 msgCopy.repeatCount = (count - prevRepeatCount) || 1;
224 msgCopy.repeatDelta = msgCopy.repeatCount;
225 this.addMessage(msgCopy, true);
226 }
227 },
228
229 __proto__: WebInspector.Object.prototype 193 __proto__: WebInspector.Object.prototype
230 } 194 }
231 195
232 /** 196 /**
233 * @constructor 197 * @constructor
234 * @param {string} source 198 * @param {string} source
235 * @param {?string} level 199 * @param {?string} level
236 * @param {string} messageText 200 * @param {string} messageText
237 * @param {string=} type 201 * @param {string=} type
238 * @param {?string=} url 202 * @param {?string=} url
239 * @param {number=} line 203 * @param {number=} line
240 * @param {number=} column 204 * @param {number=} column
241 * @param {number=} repeatCount
242 * @param {!NetworkAgent.RequestId=} requestId 205 * @param {!NetworkAgent.RequestId=} requestId
243 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters 206 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters
244 * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace 207 * @param {!Array.<!ConsoleAgent.CallFrame>=} stackTrace
245 * @param {boolean=} isOutdated 208 * @param {boolean=} isOutdated
246 */ 209 */
247 WebInspector.ConsoleMessage = function(source, level, messageText, type, url, li ne, column, repeatCount, requestId, parameters, stackTrace, isOutdated) 210 WebInspector.ConsoleMessage = function(source, level, messageText, type, url, li ne, column, requestId, parameters, stackTrace, isOutdated)
248 { 211 {
249 this.source = source; 212 this.source = source;
250 this.level = level; 213 this.level = level;
251 this.messageText = messageText; 214 this.messageText = messageText;
252 this.type = type || WebInspector.ConsoleMessage.MessageType.Log; 215 this.type = type || WebInspector.ConsoleMessage.MessageType.Log;
253 this.url = url || null; 216 this.url = url || null;
254 this.line = line || 0; 217 this.line = line || 0;
255 this.column = column || 0; 218 this.column = column || 0;
256 this.parameters = parameters; 219 this.parameters = parameters;
257 this.stackTrace = stackTrace; 220 this.stackTrace = stackTrace;
258 this.isOutdated = isOutdated; 221 this.isOutdated = isOutdated;
259
260 repeatCount = repeatCount || 1;
261 this.repeatCount = repeatCount;
262 this.repeatDelta = repeatCount;
263 this.totalRepeatCount = repeatCount;
264 this.request = requestId ? WebInspector.networkLog.requestForId(requestId) : null; 222 this.request = requestId ? WebInspector.networkLog.requestForId(requestId) : null;
265 } 223 }
266 224
267 WebInspector.ConsoleMessage.prototype = { 225 WebInspector.ConsoleMessage.prototype = {
226
268 /** 227 /**
269 * @return {boolean} 228 * @return {boolean}
270 */ 229 */
230 isGroupMessage: function()
231 {
232 return this.type === WebInspector.ConsoleMessage.MessageType.StartGroup ||
233 this.type === WebInspector.ConsoleMessage.MessageType.StartGroupColl apsed ||
234 this.type === WebInspector.ConsoleMessage.MessageType.EndGroup;
235 },
236
237 /**
238 * @return {boolean}
239 */
271 isErrorOrWarning: function() 240 isErrorOrWarning: function()
272 { 241 {
273 return (this.level === WebInspector.ConsoleMessage.MessageLevel.Warning || this.level === WebInspector.ConsoleMessage.MessageLevel.Error); 242 return (this.level === WebInspector.ConsoleMessage.MessageLevel.Warning || this.level === WebInspector.ConsoleMessage.MessageLevel.Error);
274 }, 243 },
275 244
276 /** 245 /**
277 * @return {!WebInspector.ConsoleMessage} 246 * @return {!WebInspector.ConsoleMessage}
278 */ 247 */
279 clone: function() 248 clone: function()
280 { 249 {
281 return new WebInspector.ConsoleMessage( 250 return new WebInspector.ConsoleMessage(
282 this.source, 251 this.source,
283 this.level, 252 this.level,
284 this.messageText, 253 this.messageText,
285 this.type, 254 this.type,
286 this.url, 255 this.url,
287 this.line, 256 this.line,
288 this.column, 257 this.column,
289 this.repeatCount,
290 this.request ? this.request.requestId : undefined, 258 this.request ? this.request.requestId : undefined,
291 this.parameters, 259 this.parameters,
292 this.stackTrace, 260 this.stackTrace,
293 this.isOutdated); 261 this.isOutdated);
294 }, 262 },
295 263
296 /** 264 /**
265 * @param {!Array.<!RuntimeAgent.RemoteObject>=} parameters
266 * @return {boolean}
267 */
268 _equalParameters: function(parameters)
269 {
270 if (!this.parameters && !parameters)
271 return true;
272
273 if (!this.parameters || !parameters || this.parameters.length !== parame ters.length)
274 return false;
275
276 for (var i = 0; i < parameters.length; ++i) {
277 // Never treat objects as equal - their properties might change over time.
278 if (this.parameters[i].type !== parameters[i].type || parameters[i]. type === "object" || this.parameters[i].value !== parameters[i].value)
279 return false;
280 }
281
282 return true;
283 },
284
285 /**
297 * @param {?WebInspector.ConsoleMessage} msg 286 * @param {?WebInspector.ConsoleMessage} msg
298 * @return {boolean} 287 * @return {boolean}
299 */ 288 */
300 isEqual: function(msg) 289 isEqual: function(msg)
301 { 290 {
302 if (!msg) 291 if (!msg)
303 return false; 292 return false;
304 293
305 if (this.stackTrace) { 294 if (this.stackTrace) {
306 if (!msg.stackTrace) 295 if (!msg.stackTrace)
(...skipping 10 matching lines...) Expand all
317 return false; 306 return false;
318 } 307 }
319 } 308 }
320 309
321 return (this.source === msg.source) 310 return (this.source === msg.source)
322 && (this.type === msg.type) 311 && (this.type === msg.type)
323 && (this.level === msg.level) 312 && (this.level === msg.level)
324 && (this.line === msg.line) 313 && (this.line === msg.line)
325 && (this.url === msg.url) 314 && (this.url === msg.url)
326 && (this.messageText === msg.messageText) 315 && (this.messageText === msg.messageText)
327 && (this.request === msg.request); 316 && (this.request === msg.request) && this._equalParameters(msg.param eters);
pfeldman 2014/03/25 13:09:32 inline.
sergeyv 2014/03/25 13:42:56 Done.
328 } 317 }
329 } 318 }
330 319
331 // Note: Keep these constants in sync with the ones in Console.h 320 // Note: Keep these constants in sync with the ones in Console.h
332 /** 321 /**
333 * @enum {string} 322 * @enum {string}
334 */ 323 */
335 WebInspector.ConsoleMessage.MessageSource = { 324 WebInspector.ConsoleMessage.MessageSource = {
336 XML: "xml", 325 XML: "xml",
337 JS: "javascript", 326 JS: "javascript",
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 messageAdded: function(payload) 383 messageAdded: function(payload)
395 { 384 {
396 var consoleMessage = new WebInspector.ConsoleMessage( 385 var consoleMessage = new WebInspector.ConsoleMessage(
397 payload.source, 386 payload.source,
398 payload.level, 387 payload.level,
399 payload.text, 388 payload.text,
400 payload.type, 389 payload.type,
401 payload.url, 390 payload.url,
402 payload.line, 391 payload.line,
403 payload.column, 392 payload.column,
404 payload.repeatCount,
405 payload.networkRequestId, 393 payload.networkRequestId,
406 payload.parameters, 394 payload.parameters,
407 payload.stackTrace, 395 payload.stackTrace,
408 this._console._enablingConsole); 396 this._console._enablingConsole);
409 this._console.addMessage(consoleMessage, true); 397 this._console.addMessage(consoleMessage, true);
410 }, 398 },
411 399
412 /** 400 /**
413 * @param {number} count 401 * @param {number} count
414 */ 402 */
415 messageRepeatCountUpdated: function(count) 403 messageRepeatCountUpdated: function(count){},
pfeldman 2014/03/25 13:09:32 ) { },
sergeyv 2014/03/25 13:42:56 Done.
416 {
417 this._console._messageRepeatCountUpdated(count);
418 },
419 404
420 messagesCleared: function() 405 messagesCleared: function()
421 { 406 {
422 if (!WebInspector.settings.preserveConsoleLog.get()) 407 if (!WebInspector.settings.preserveConsoleLog.get())
423 this._console.clearMessages(); 408 this._console.clearMessages();
424 } 409 }
425 } 410 }
426 411
427 /** 412 /**
428 * @type {!WebInspector.ConsoleModel} 413 * @type {!WebInspector.ConsoleModel}
429 */ 414 */
430 WebInspector.console; 415 WebInspector.console;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698