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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/WorkerManager.js

Issue 1692813002: Revert of [DevTools] Remove isRunRequired, replace autoConnectToWorkers with setWaitForDebuggerOnStart. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/sdk/WorkerManager.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/WorkerManager.js b/third_party/WebKit/Source/devtools/front_end/sdk/WorkerManager.js
index 9ebf30746d3319d655b4e4369bc77d44a5bb4ae5..cf198b92baa65f8e1dd725eb938ab766f5749176 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/WorkerManager.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/WorkerManager.js
@@ -86,30 +86,48 @@
_onSuspendStateChanged: function()
{
var suspended = WebInspector.targetManager.allTargetsSuspended();
- this.target().workerAgent().setWaitForDebuggerOnStart(!suspended);
+ this.target().workerAgent().setAutoconnectToWorkers(!suspended);
},
/**
* @param {string} workerId
* @param {string} url
- * @param {boolean} waitingForDebugger
- */
- _workerCreated: function(workerId, url, waitingForDebugger)
- {
- var connection = new WebInspector.WorkerConnection(this, workerId);
+ * @param {boolean} inspectorConnected
+ */
+ _workerCreated: function(workerId, url, inspectorConnected)
+ {
+ var connection = new WebInspector.WorkerConnection(this, workerId, inspectorConnected, onConnectionReady.bind(this));
this._connections.set(workerId, connection);
- var parsedURL = url.asParsedURL();
- var workerName = parsedURL ? parsedURL.lastPathComponentWithFragment() : "#" + (++this._lastAnonymousTargetId);
- var target = WebInspector.targetManager.createTarget(workerName, WebInspector.Target.Type.DedicatedWorker, connection, this.target());
- this._targetsByWorkerId.set(workerId, target);
-
- // Only pause new worker if debugging SW - we are going through the
- // pause on start checkbox.
- var mainIsServiceWorker = WebInspector.targetManager.mainTarget().isServiceWorker();
- if (mainIsServiceWorker && waitingForDebugger)
- target.debuggerAgent().pause();
- target.runtimeAgent().run();
+ /**
+ * @param {!InspectorBackendClass.Connection} connection
+ * @this {WebInspector.WorkerManager}
+ */
+ function onConnectionReady(connection)
+ {
+ var parsedURL = url.asParsedURL();
+ var workerName = parsedURL ? parsedURL.lastPathComponentWithFragment() : "#" + (++this._lastAnonymousTargetId);
+ var target = WebInspector.targetManager.createTarget(workerName, WebInspector.Target.Type.DedicatedWorker, connection, this.target());
+ this._targetsByWorkerId.set(workerId, target);
+
+ if (inspectorConnected)
+ target.runtimeAgent().isRunRequired(pauseInDebuggerAndRunIfRequired.bind(null, target));
+ }
+
+ /**
+ * @param {!WebInspector.Target} target
+ * @param {?Protocol.Error} error
+ * @param {boolean} required
+ */
+ function pauseInDebuggerAndRunIfRequired(target, error, required)
+ {
+ // Only pause new worker if debugging SW - we are going through the
+ // pause on start checkbox.
+ var mainIsServiceWorker = WebInspector.targetManager.mainTarget().isServiceWorker();
+ if (mainIsServiceWorker && required)
+ target.debuggerAgent().pause();
+ target.runtimeAgent().run();
+ }
},
/**
@@ -169,11 +187,11 @@
* @override
* @param {string} workerId
* @param {string} url
- * @param {boolean} waitingForDebugger
- */
- workerCreated: function(workerId, url, waitingForDebugger)
- {
- this._workerManager._workerCreated(workerId, url, waitingForDebugger);
+ * @param {boolean} inspectorConnected
+ */
+ workerCreated: function(workerId, url, inspectorConnected)
+ {
+ this._workerManager._workerCreated(workerId, url, inspectorConnected);
},
/**
@@ -201,14 +219,22 @@
* @extends {InspectorBackendClass.Connection}
* @param {!WebInspector.WorkerManager} workerManager
* @param {string} workerId
- */
-WebInspector.WorkerConnection = function(workerManager, workerId)
+ * @param {boolean} inspectorConnected
+ * @param {function(!InspectorBackendClass.Connection)} onConnectionReady
+ */
+WebInspector.WorkerConnection = function(workerManager, workerId, inspectorConnected, onConnectionReady)
{
InspectorBackendClass.Connection.call(this);
//FIXME: remove resourceTreeModel and others from worker targets
this.suppressErrorsForDomains(["Worker", "Page", "CSS", "DOM", "DOMStorage", "Database", "Network", "IndexedDB"]);
this._agent = workerManager.target().workerAgent();
this._workerId = workerId;
+
+
+ if (!inspectorConnected)
+ this._agent.connectToWorker(workerId, onConnectionReady.bind(null, this));
+ else
+ onConnectionReady.call(null, this);
}
WebInspector.WorkerConnection.prototype = {
« no previous file with comments | « third_party/WebKit/Source/core/workers/WorkerMessagingProxy.cpp ('k') | third_party/WebKit/Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698