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

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

Issue 2442083002: [DevTools] Merge Worker domain to Target, migrate clients. (Closed)
Patch Set: rebased all tests Created 4 years, 2 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
deleted file mode 100644
index 3a20f525f1035a0d4815fb7f5a8939adf5fc5d0d..0000000000000000000000000000000000000000
--- a/third_party/WebKit/Source/devtools/front_end/sdk/WorkerManager.js
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2011 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/**
- * @constructor
- * @extends {WebInspector.SDKObject}
- * @param {!WebInspector.Target} target
- */
-WebInspector.WorkerManager = function(target)
-{
- WebInspector.SDKObject.call(this, target);
- target.registerWorkerDispatcher(new WebInspector.WorkerDispatcher(this));
- this._lastAnonymousTargetId = 0;
- /** @type {!Map.<string, !WebInspector.WorkerConnection>} */
- this._connections = new Map();
-
- /** @type {!Map.<string, !WebInspector.Target>} */
- this._targetsByWorkerId = new Map();
-
- WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.SuspendStateChanged, this._onSuspendStateChanged, this);
- this._onSuspendStateChanged();
- this.enable();
-};
-
-WebInspector.WorkerManager.prototype = {
- enable: function()
- {
- if (this._enabled)
- return;
- this._enabled = true;
-
- this.target().workerAgent().enable();
- WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.MainFrameNavigated, this._mainFrameNavigated, this);
- },
-
- disable: function()
- {
- if (!this._enabled)
- return;
- this._enabled = false;
- this._reset();
- this.target().workerAgent().disable();
- WebInspector.targetManager.removeEventListener(WebInspector.TargetManager.Events.MainFrameNavigated, this._mainFrameNavigated, this);
- },
-
- dispose: function()
- {
- this._reset();
- },
-
- _reset: function()
- {
- for (var connection of this._connections.values())
- connection._onDisconnect.call(null, "reset");
- this._connections.clear();
- this._targetsByWorkerId.clear();
- },
-
- _onSuspendStateChanged: function()
- {
- var suspended = WebInspector.targetManager.allTargetsSuspended();
- this.target().workerAgent().setWaitForDebuggerOnStart(!suspended);
- },
-
- /**
- * @param {string} workerId
- * @param {string} url
- * @param {boolean} waitingForDebugger
- */
- _workerCreated: function(workerId, url, waitingForDebugger)
- {
- var capabilities = WebInspector.Target.Capability.JS | WebInspector.Target.Capability.Log;
- var parsedURL = url.asParsedURL();
- var workerName = parsedURL ? parsedURL.lastPathComponentWithFragment() : "#" + (++this._lastAnonymousTargetId);
- var target = WebInspector.targetManager.createTarget(workerName, capabilities, this._createConnection.bind(this, workerId), 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().hasWorkerCapability() && !WebInspector.targetManager.mainTarget().hasBrowserCapability();
- if (mainIsServiceWorker && waitingForDebugger)
- target.debuggerAgent().pause();
- target.runtimeAgent().runIfWaitingForDebugger();
- },
-
- /**
- * @param {string} workerId
- * @param {!InspectorBackendClass.Connection.Params} params
- * @return {!InspectorBackendClass.Connection}
- */
- _createConnection: function(workerId, params)
- {
- var connection = new WebInspector.WorkerConnection(this, workerId, params);
- this._connections.set(workerId, connection);
- return connection;
- },
-
- /**
- * @param {string} workerId
- */
- _workerTerminated: function(workerId)
- {
- var connection = this._connections.get(workerId);
- if (connection)
- connection._onDisconnect.call(null, "worker terminated");
- this._connections.delete(workerId);
- this._targetsByWorkerId.delete(workerId);
- },
-
- /**
- * @param {string} workerId
- * @param {string} message
- */
- _dispatchMessageFromWorker: function(workerId, message)
- {
- var connection = this._connections.get(workerId);
- if (connection)
- connection._onMessage.call(null, message);
- },
-
- /**
- * @param {!WebInspector.Event} event
- */
- _mainFrameNavigated: function(event)
- {
- if (event.data.target() !== this.target())
- return;
- this._reset(); // TODO (dgozman): Probably, unnecessary. Consider removal.
- },
-
- /**
- * @param {string} workerId
- * @return {?WebInspector.Target}
- */
- targetByWorkerId: function(workerId)
- {
- return this._targetsByWorkerId.get(workerId) || null;
- },
-
- __proto__: WebInspector.SDKObject.prototype
-};
-
-/**
- * @constructor
- * @implements {WorkerAgent.Dispatcher}
- */
-WebInspector.WorkerDispatcher = function(workerManager)
-{
- this._workerManager = workerManager;
-};
-
-WebInspector.WorkerDispatcher.prototype = {
- /**
- * @override
- * @param {string} workerId
- * @param {string} url
- * @param {boolean} waitingForDebugger
- */
- workerCreated: function(workerId, url, waitingForDebugger)
- {
- this._workerManager._workerCreated(workerId, url, waitingForDebugger);
- },
-
- /**
- * @override
- * @param {string} workerId
- */
- workerTerminated: function(workerId)
- {
- this._workerManager._workerTerminated(workerId);
- },
-
- /**
- * @override
- * @param {string} workerId
- * @param {string} message
- */
- dispatchMessageFromWorker: function(workerId, message)
- {
- this._workerManager._dispatchMessageFromWorker(workerId, message);
- }
-};
-
-/**
- * @constructor
- * @implements {InspectorBackendClass.Connection}
- * @param {!WebInspector.WorkerManager} workerManager
- * @param {string} workerId
- * @param {!InspectorBackendClass.Connection.Params} params
- */
-WebInspector.WorkerConnection = function(workerManager, workerId, params)
-{
- this._agent = workerManager.target().workerAgent();
- this._workerId = workerId;
- this._onMessage = params.onMessage;
- this._onDisconnect = params.onDisconnect;
-};
-
-WebInspector.WorkerConnection.prototype = {
- /**
- * @override
- * @param {string} message
- */
- sendMessage: function(message)
- {
- this._agent.sendMessageToWorker(this._workerId, message);
- },
-
- /**
- * @override
- * @return {!Promise}
- */
- disconnect: function()
- {
- throw new Error("Not implemented");
- },
-};

Powered by Google App Engine
This is Rietveld 408576698