Commit 087f2421 authored by sergeyv@chromium.org's avatar sergeyv@chromium.org

DevTools: Show worker context in consoleView

BUG=

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

git-svn-id: svn://svn.chromium.org/blink/trunk@169855 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 67333eb2
......@@ -43,6 +43,7 @@ WebInspector.ConsoleModel = function(target)
this._target = target;
this._consoleAgent = target.consoleAgent();
target.registerConsoleDispatcher(new WebInspector.ConsoleDispatcher(this));
this._enableAgent();
}
WebInspector.ConsoleModel.Events = {
......@@ -53,7 +54,7 @@ WebInspector.ConsoleModel.Events = {
}
WebInspector.ConsoleModel.prototype = {
enableAgent: function()
_enableAgent: function()
{
if (WebInspector.settings.monitoringXHREnabled.get())
this._consoleAgent.setMonitoringXHREnabled(true);
......
......@@ -34,10 +34,11 @@
* @param {!WebInspector.ConsoleMessage} consoleMessage
* @param {?WebInspector.Linkifier} linkifier
*/
WebInspector.ConsoleViewMessage = function(consoleMessage, linkifier)
WebInspector.ConsoleViewMessage = function(target, consoleMessage, linkifier)
{
this._message = consoleMessage;
this._linkifier = linkifier;
this._target = target;
/** @type {!Array.<!WebInspector.DataGrid>} */
this._dataGrids = [];
......@@ -268,9 +269,9 @@ WebInspector.ConsoleViewMessage.prototype = {
continue;
if (typeof parameters[i] === "object")
parameters[i] = WebInspector.RemoteObject.fromPayload(parameters[i]);
parameters[i] = WebInspector.RemoteObject.fromPayload(parameters[i], this._target);
else
parameters[i] = WebInspector.RemoteObject.fromPrimitiveValue(parameters[i]);
parameters[i] = WebInspector.RemoteObject.fromPrimitiveValue(parameters[i], this._target);
}
// There can be string log and string eval result. We distinguish between them based on message type.
......
......@@ -368,8 +368,6 @@ WebInspector.Main.prototype = {
WebInspector.extensionServerProxy.setFrontendReady();
WebInspector.console.enableAgent();
WebInspector.databaseModel = new WebInspector.DatabaseModel();
WebInspector.domStorageModel = new WebInspector.DOMStorageModel();
WebInspector.cpuProfilerModel = new WebInspector.CPUProfilerModel();
......
......@@ -101,6 +101,11 @@ WebInspector.RemoteObject.prototype = {
* @param {function(*)} callback
*/
callFunctionJSON: function(functionDeclaration, args, callback)
{
throw "Not implemented";
},
target: function()
{
throw "Not implemented";
}
......@@ -114,6 +119,10 @@ WebInspector.RemoteObject.prototype = {
*/
WebInspector.RemoteObject.fromPrimitiveValue = function(value, target)
{
//FIXME: we should always pass non-undefined target
if (!target)
target = WebInspector.targetManager.mainTarget();
return new WebInspector.RemoteObjectImpl(target, undefined, typeof value, undefined, value);
}
......@@ -157,6 +166,10 @@ WebInspector.RemoteObject.resolveNode = function(node, objectGroup, callback)
*/
WebInspector.RemoteObject.fromPayload = function(payload, target)
{
//FIXME: we should always pass non-undefined target
if (!target)
target = WebInspector.targetManager.mainTarget();
console.assert(typeof payload === "object", "Remote object payload should only be an object");
return new WebInspector.RemoteObjectImpl(target, payload.objectId, payload.type, payload.subtype, payload.value, payload.description, payload.preview);
......@@ -209,7 +222,7 @@ WebInspector.RemoteObject.toCallArgument = function(remoteObject)
/**
* @constructor
* @extends {WebInspector.RemoteObject}
* @param {!WebInspector.Target|undefined} target
* @param {!WebInspector.Target} target
* @param {string|undefined} objectId
* @param {string} type
* @param {string|undefined} subtype
......@@ -220,14 +233,9 @@ WebInspector.RemoteObject.toCallArgument = function(remoteObject)
WebInspector.RemoteObjectImpl = function(target, objectId, type, subtype, value, description, preview)
{
WebInspector.RemoteObject.call(this);
if (target) {
this._target = target;
this._runtimeAgent = target.runtimeAgent();
this._domAgent = target.domModel;
} else {
//FIXME: remove this logic once every RemoteObjectImpl constructor call has non-undefined target
this._runtimeAgent = RuntimeAgent;
this._domAgent = WebInspector.domAgent;
}
this._type = type;
this._subtype = subtype;
......@@ -523,6 +531,14 @@ WebInspector.RemoteObjectImpl.prototype = {
return parseInt(matches[1], 10);
},
/**
* @return {!WebInspector.Target}
*/
target: function()
{
return this._target;
},
__proto__: WebInspector.RemoteObject.prototype
};
......@@ -598,7 +614,7 @@ WebInspector.RemoteObject.loadFromObjectPerProto = function(object, callback)
/**
* @constructor
* @extends {WebInspector.RemoteObjectImpl}
* @param {!WebInspector.Target|undefined} target
* @param {!WebInspector.Target} target
* @param {string|undefined} objectId
* @param {!WebInspector.ScopeRef} scopeRef
* @param {string} type
......@@ -612,8 +628,7 @@ WebInspector.ScopeRemoteObject = function(target, objectId, scopeRef, type, subt
WebInspector.RemoteObjectImpl.call(this, target, objectId, type, subtype, value, description, preview);
this._scopeRef = scopeRef;
this._savedScopeProperties = undefined;
//FIXME: remove this logic once every RemoteObjectImpl constructor call has non-undefined target
this._debuggerAgent = target ? target.debuggerAgent() : DebuggerAgent;
this._debuggerAgent = target.debuggerAgent();
};
/**
......@@ -624,6 +639,10 @@ WebInspector.ScopeRemoteObject = function(target, objectId, scopeRef, type, subt
*/
WebInspector.ScopeRemoteObject.fromPayload = function(payload, scopeRef, target)
{
//FIXME: we should always pass non-undefined target
if (!target)
target = WebInspector.targetManager.mainTarget();
if (scopeRef)
return new WebInspector.ScopeRemoteObject(target, payload.objectId, scopeRef, payload.type, payload.subtype, payload.value, payload.description, payload.preview);
else
......
......@@ -62,7 +62,7 @@ WebInspector.Target.prototype = {
if (!WebInspector.domAgent)
WebInspector.domAgent = this.domModel;
this.workerManager = new WebInspector.WorkerManager(this.isMainFrontend);
this.workerManager = new WebInspector.WorkerManager(this, this.isMainFrontend);
if (!WebInspector.workerManager)
WebInspector.workerManager = this.workerManager;
......@@ -93,13 +93,19 @@ WebInspector.Target.prototype = {
/**
* @constructor
* @extends {WebInspector.Object}
*/
WebInspector.TargetManager = function()
{
WebInspector.Object.call(this);
/** @type {!Array.<!WebInspector.Target>} */
this._targets = [];
}
WebInspector.TargetManager.Events = {
TargetAdded: "TargetAdded",
}
WebInspector.TargetManager.prototype = {
/**
......@@ -108,8 +114,43 @@ WebInspector.TargetManager.prototype = {
*/
createTarget: function(connection, callback)
{
var newTarget = new WebInspector.Target(connection, callback);
var target = new WebInspector.Target(connection, callbackWrapper.bind(this));
/**
* @this {WebInspector.TargetManager}
* @param newTarget
*/
function callbackWrapper(newTarget)
{
if (callback)
callback(newTarget);
this._targets.push(newTarget);
this.dispatchEventToListeners(WebInspector.TargetManager.Events.TargetAdded, newTarget);
}
},
/**
* @return {!Array.<!WebInspector.Target>}
*/
targets: function()
{
return this._targets;
},
/**
* @return {!WebInspector.Target}
*/
mainTarget: function()
{
return this._targets[0];
},
__proto__: WebInspector.Object.prototype
}
/**
* @type {!WebInspector.TargetManager}
*/
WebInspector.targetManager;
......@@ -33,10 +33,10 @@
* @extends {WebInspector.Object}
* @param {boolean} isMainFrontend
*/
WebInspector.WorkerManager = function(isMainFrontend)
WebInspector.WorkerManager = function(target, isMainFrontend)
{
this._reset();
InspectorBackend.registerWorkerDispatcher(new WebInspector.WorkerDispatcher(this));
target.registerWorkerDispatcher(new WebInspector.WorkerDispatcher(this));
if (isMainFrontend) {
WorkerAgent.enable();
WebInspector.resourceTreeModel.addEventListener(WebInspector.ResourceTreeModel.EventTypes.MainFrameNavigated, this._mainFrameNavigated, this);
......
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