Commit 4405a06d authored by sergeyv@chromium.org's avatar sergeyv@chromium.org

DevTools: Make ConsoleMessage TargetAware

BUG=
R=pfeldman@chromium.org

Review URL: https://codereview.chromium.org/222143003

git-svn-id: svn://svn.chromium.org/blink/trunk@170667 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent b25d76e3
......@@ -5,7 +5,7 @@
<script>
function test()
{
WebInspector.console.addMessage(new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.Other, WebInspector.ConsoleMessage.MessageLevel.Log, "PASS"));
WebInspector.console.addMessage(new WebInspector.ConsoleMessage(WebInspector.console.target(), WebInspector.ConsoleMessage.MessageSource.Other, WebInspector.ConsoleMessage.MessageLevel.Log, "PASS"));
WebInspector.settings.preserveConsoleLog.set(true);
InspectorTest.reloadPage(function() {
InspectorTest.dumpConsoleMessages();
......
......@@ -11,6 +11,7 @@ function test()
function addMessageWithFixedTimestamp(messageText, timestamp)
{
var message = new WebInspector.ConsoleMessage(
WebInspector.console.target(),
WebInspector.ConsoleMessage.MessageSource.Other, // source
WebInspector.ConsoleMessage.MessageLevel.Log, // level
messageText,
......
......@@ -722,6 +722,7 @@ WebInspector.CPUProfileType.prototype = {
{
var script = scriptLocation.script();
var message = new WebInspector.ConsoleMessage(
WebInspector.console.target(),
WebInspector.ConsoleMessage.MessageSource.ConsoleAPI,
WebInspector.ConsoleMessage.MessageLevel.Debug,
messageText,
......
......@@ -102,7 +102,7 @@ WebInspector.ConsoleModel.prototype = {
{
this.show();
var commandMessage = new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.JS, null, text, WebInspector.ConsoleMessage.MessageType.Command);
var commandMessage = new WebInspector.ConsoleMessage(this.target(), WebInspector.ConsoleMessage.MessageSource.JS, null, text, WebInspector.ConsoleMessage.MessageType.Command);
this.addMessage(commandMessage);
/**
......@@ -144,6 +144,7 @@ WebInspector.ConsoleModel.prototype = {
log: function(messageText, messageLevel, showConsole)
{
var message = new WebInspector.ConsoleMessage(
this.target(),
WebInspector.ConsoleMessage.MessageSource.Other,
messageLevel || WebInspector.ConsoleMessage.MessageLevel.Debug,
messageText);
......@@ -196,6 +197,8 @@ WebInspector.ConsoleModel.prototype = {
/**
* @constructor
* @extends {WebInspector.TargetAware}
* @param {!WebInspector.Target} target
* @param {string} source
* @param {?string} level
* @param {string} messageText
......@@ -210,9 +213,9 @@ WebInspector.ConsoleModel.prototype = {
* @param {boolean=} isOutdated
* @param {!RuntimeAgent.ExecutionContextId=} executionContextId
*/
WebInspector.ConsoleMessage = function(source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, isOutdated, executionContextId)
WebInspector.ConsoleMessage = function(target, source, level, messageText, type, url, line, column, requestId, parameters, stackTrace, timestamp, isOutdated, executionContextId)
{
WebInspector.TargetAware.call(this, target);
this.source = source;
this.level = level;
this.messageText = messageText;
......@@ -255,6 +258,7 @@ WebInspector.ConsoleMessage.prototype = {
clone: function()
{
return new WebInspector.ConsoleMessage(
this.target(),
this.source,
this.level,
this.messageText,
......@@ -310,7 +314,9 @@ WebInspector.ConsoleMessage.prototype = {
&& (this.url === msg.url)
&& (this.messageText === msg.messageText)
&& (this.request === msg.request);
}
},
__proto__: WebInspector.TargetAware.prototype
}
// Note: Keep these constants in sync with the ones in Console.h
......@@ -379,6 +385,7 @@ WebInspector.ConsoleDispatcher.prototype = {
messageAdded: function(payload)
{
var consoleMessage = new WebInspector.ConsoleMessage(
this._console.target(),
payload.source,
payload.level,
payload.text,
......
......@@ -135,10 +135,10 @@ WebInspector.ConsoleView.prototype = {
*/
targetAdded: function(target)
{
target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._onConsoleMessageAdded.bind(this, target), this);
target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.MessageAdded, this._onConsoleMessageAdded, this);
target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.ConsoleCleared, this._consoleCleared, this);
target.consoleModel.addEventListener(WebInspector.ConsoleModel.Events.CommandEvaluated, this._commandEvaluated, this);
target.consoleModel.messages.forEach(this._consoleMessageAdded.bind(this, target));
target.consoleModel.messages.forEach(this._consoleMessageAdded, this);
/**
* @param {!WebInspector.ExecutionContextList} contextList
......@@ -429,7 +429,7 @@ WebInspector.ConsoleView.prototype = {
/**
* @param {!WebInspector.ConsoleMessage} message
*/
_consoleMessageAdded: function(target, message)
_consoleMessageAdded: function(message)
{
if (this._urlToMessageCount[message.url])
this._urlToMessageCount[message.url]++;
......@@ -444,7 +444,7 @@ WebInspector.ConsoleView.prototype = {
}
this._consoleMessages.push(message);
var viewMessage = this._createViewMessage(target, message);
var viewMessage = this._createViewMessage(message);
if (this._filter.shouldBeVisible(viewMessage))
this._showConsoleMessage(viewMessage);
......@@ -455,10 +455,10 @@ WebInspector.ConsoleView.prototype = {
/**
* @param {!WebInspector.Event} event
*/
_onConsoleMessageAdded: function(target, event)
_onConsoleMessageAdded: function(event)
{
var message = /** @type {!WebInspector.ConsoleMessage} */ (event.data);
this._consoleMessageAdded(target, message);
this._consoleMessageAdded(message);
},
/**
......@@ -499,15 +499,15 @@ WebInspector.ConsoleView.prototype = {
* @param {!WebInspector.ConsoleMessage} message
* @return {!WebInspector.ConsoleViewMessage}
*/
_createViewMessage: function(target, message)
_createViewMessage: function(message)
{
var viewMessage = this._messageToViewMessage.get(message);
if (viewMessage)
return viewMessage;
if (message.type === WebInspector.ConsoleMessage.MessageType.Command)
viewMessage = new WebInspector.ConsoleCommand(target, message);
viewMessage = new WebInspector.ConsoleCommand(message);
else
viewMessage = new WebInspector.ConsoleViewMessage(target, message, this._linkifier);
viewMessage = new WebInspector.ConsoleViewMessage(message, this._linkifier);
this._messageToViewMessage.put(message, viewMessage);
return viewMessage;
},
......@@ -1000,9 +1000,9 @@ WebInspector.ConsoleViewFilter.prototype = {
* @extends {WebInspector.ConsoleViewMessage}
* @param {!WebInspector.ConsoleMessage} message
*/
WebInspector.ConsoleCommand = function(target, message)
WebInspector.ConsoleCommand = function(message)
{
WebInspector.ConsoleViewMessage.call(this, target, message, null);
WebInspector.ConsoleViewMessage.call(this, message, null);
}
WebInspector.ConsoleCommand.prototype = {
......@@ -1075,8 +1075,8 @@ WebInspector.ConsoleCommand.prototype = {
}
/**
* @extends {WebInspector.ConsoleViewMessage}
* @constructor
* @extends {WebInspector.ConsoleViewMessage}
* @param {!WebInspector.RemoteObject} result
* @param {boolean} wasThrown
* @param {?WebInspector.ConsoleCommand} originatingCommand
......@@ -1089,9 +1089,8 @@ WebInspector.ConsoleCommandResult = function(result, wasThrown, originatingComma
{
this.originatingCommand = originatingCommand;
var level = wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log;
var message = new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.JS, level, "", WebInspector.ConsoleMessage.MessageType.Result, url, lineNumber, columnNumber, undefined, [result]);
WebInspector.ConsoleViewMessage.call(this, /** @type {!WebInspector.Target} */ (result.target()), message, linkifier);
var message = new WebInspector.ConsoleMessage(/** @type {!WebInspector.Target} */ (result.target()), WebInspector.ConsoleMessage.MessageSource.JS, level, "", WebInspector.ConsoleMessage.MessageType.Result, url, lineNumber, columnNumber, undefined, [result]);
WebInspector.ConsoleViewMessage.call(this, message, linkifier);
}
WebInspector.ConsoleCommandResult.prototype = {
......
......@@ -31,13 +31,12 @@
/**
* @constructor
* @extends {WebInspector.TargetAware}
* @param {!WebInspector.Target} target
* @param {!WebInspector.ConsoleMessage} consoleMessage
* @param {?WebInspector.Linkifier} linkifier
*/
WebInspector.ConsoleViewMessage = function(target, consoleMessage, linkifier)
WebInspector.ConsoleViewMessage = function(consoleMessage, linkifier)
{
WebInspector.TargetAware.call(this, target);
WebInspector.TargetAware.call(this, consoleMessage.target());
this._message = consoleMessage;
this._linkifier = linkifier;
this._repeatCount = 1;
......
......@@ -417,6 +417,7 @@ WebInspector.ExtensionServer.prototype = {
return this._status.E_BADARG("message.severity", message.severity);
var consoleMessage = new WebInspector.ConsoleMessage(
WebInspector.console.target(),
WebInspector.ConsoleMessage.MessageSource.JS,
level,
message.text,
......
......@@ -193,7 +193,8 @@ WebInspector.NetworkDispatcher.prototype = {
networkRequest.timing = response.timing;
if (!this._mimeTypeIsConsistentWithType(networkRequest)) {
this._manager._target.consoleModel.addMessage(new WebInspector.ConsoleMessage(WebInspector.ConsoleMessage.MessageSource.Network,
var consoleModel = this._manager._target.consoleModel;
consoleModel.addMessage(new WebInspector.ConsoleMessage(consoleModel.target(), WebInspector.ConsoleMessage.MessageSource.Network,
WebInspector.ConsoleMessage.MessageLevel.Log,
WebInspector.UIString("Resource interpreted as %s but transferred with MIME type %s: \"%s\".", networkRequest.type.title(), networkRequest.mimeType, networkRequest.url),
WebInspector.ConsoleMessage.MessageType.Log,
......
......@@ -223,6 +223,7 @@ WebInspector.ScriptSnippetModel.prototype = {
if (!scriptId) {
var consoleMessage = new WebInspector.ConsoleMessage(
WebInspector.console.target(),
WebInspector.ConsoleMessage.MessageSource.JS,
WebInspector.ConsoleMessage.MessageLevel.Error,
syntaxErrorMessage || "");
......@@ -269,7 +270,7 @@ WebInspector.ScriptSnippetModel.prototype = {
_printRunScriptResult: function(result, wasThrown)
{
var level = (wasThrown ? WebInspector.ConsoleMessage.MessageLevel.Error : WebInspector.ConsoleMessage.MessageLevel.Log);
var message = new WebInspector.ConsoleMessage(
var message = new WebInspector.ConsoleMessage(WebInspector.console.target(),
WebInspector.ConsoleMessage.MessageSource.JS,
level,
"",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment