Commit d0125b8f authored by eostroukhov's avatar eostroukhov Committed by Commit bot

[DevTools] Make log agent optional.

Non-browser targets (e.g. Node.js) do not have log domain.

BUG=

Review-Url: https://codereview.chromium.org/2297803002
Cr-Commit-Position: refs/heads/master@{#415450}
parent e1d19cbf
......@@ -32,8 +32,9 @@
* @constructor
* @extends {WebInspector.SDKModel}
* @param {!WebInspector.Target} target
* @param {?Protocol.LogAgent} logAgent
*/
WebInspector.ConsoleModel = function(target)
WebInspector.ConsoleModel = function(target, logAgent)
{
WebInspector.SDKModel.call(this, WebInspector.ConsoleModel, target);
......@@ -44,9 +45,9 @@ WebInspector.ConsoleModel = function(target)
this._warnings = 0;
this._errors = 0;
this._revokedErrors = 0;
this._logAgent = target.logAgent();
target.registerLogDispatcher(new WebInspector.LogDispatcher(this));
this._logAgent.enable();
this._logAgent = logAgent;
this._logAgent && this._logAgent.enable();
}
/** @enum {symbol} */
......@@ -134,7 +135,7 @@ WebInspector.ConsoleModel.prototype = {
requestClearMessages: function()
{
this._logAgent.clear();
this._logAgent && this._logAgent.clear();
this.clear();
},
......
......@@ -190,8 +190,10 @@ WebInspector.TargetManager.prototype = {
{
var target = new WebInspector.Target(this, name, capabilitiesMask, connection, parentTarget);
var logAgent = target.hasBrowserCapability() ? target.logAgent() : null;
/** @type {!WebInspector.ConsoleModel} */
target.consoleModel = new WebInspector.ConsoleModel(target);
target.consoleModel = new WebInspector.ConsoleModel(target, logAgent);
/** @type {!WebInspector.RuntimeModel} */
target.runtimeModel = new WebInspector.RuntimeModel(target);
......
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