| Index: third_party/WebKit/Source/devtools/front_end/sdk/TargetConnectionManager.js
|
| diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/TargetConnectionManager.js b/third_party/WebKit/Source/devtools/front_end/sdk/TargetConnectionManager.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..97af811b8c3d2940d47b35af8166757e6e2a261e
|
| --- /dev/null
|
| +++ b/third_party/WebKit/Source/devtools/front_end/sdk/TargetConnectionManager.js
|
| @@ -0,0 +1,97 @@
|
| +/*
|
| + * Copyright 2014 The Chromium Authors. All rights reserved.
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +/**
|
| + * @constructor
|
| + * @extends {WebInspector.Object}
|
| + */
|
| +WebInspector.TargetConnectionManager = function()
|
| +{
|
| + WebInspector.Object.call(this);
|
| +
|
| + /** @type {!Set<!WebInspector.TargetConnectionManager.Connection>} */
|
| + this._connections = new Set();
|
| +}
|
| +
|
| +/** @enum {symbol} */
|
| +WebInspector.TargetConnectionManager.Events = {
|
| + ConnectionAdded: Symbol("ConnectionAdded"),
|
| + ConnectionRemoved: Symbol("ConnectionAdded"),
|
| +}
|
| +
|
| +WebInspector.TargetConnectionManager.prototype = {
|
| + /**
|
| + * @return {!Array<!WebInspector.TargetConnectionManager.Connection>}
|
| + */
|
| + connections: function()
|
| + {
|
| + return Array.from(this._connections);
|
| + },
|
| +
|
| + /**
|
| + * @param {!WebInspector.TargetConnectionManager.Connection} connection
|
| + */
|
| + addConnection: function(connection)
|
| + {
|
| + this._connections.add(connection);
|
| + this.dispatchEventToListeners(WebInspector.TargetConnectionManager.Events.ConnectionAdded, connection);
|
| + },
|
| +
|
| + /**
|
| + * @param {!WebInspector.TargetConnectionManager.Connection} connection
|
| + */
|
| + removeConnection: function(connection)
|
| + {
|
| + connection.disconnect();
|
| + this._connections.delete(connection);
|
| + this.dispatchEventToListeners(WebInspector.TargetConnectionManager.Events.ConnectionRemoved, connection);
|
| + },
|
| +
|
| + __proto__: WebInspector.Object.prototype
|
| +}
|
| +
|
| +
|
| +/**
|
| + * @interface
|
| + */
|
| +WebInspector.TargetConnectionManager.Connection = function() { };
|
| +
|
| +WebInspector.TargetConnectionManager.Connection.prototype = {
|
| + /**
|
| + * @return {string}
|
| + */
|
| + id: function() { },
|
| +
|
| + /**
|
| + * @return {string}
|
| + */
|
| + name: function() { },
|
| +
|
| + /**
|
| + * @return {!Promise}
|
| + */
|
| + connect: function() { },
|
| +
|
| + /**
|
| + * @return {!Promise}
|
| + */
|
| + disconnect: function() { },
|
| +}
|
| +
|
| +WebInspector.TargetConnectionManager.Connection.symbol = Symbol("connection");
|
| +
|
| +/**
|
| + * @return {?WebInspector.TargetConnectionManager.Connection}
|
| + */
|
| +WebInspector.TargetConnectionManager.Connection.fromTarget = function(target)
|
| +{
|
| + return target[WebInspector.TargetConnectionManager.Connection.symbol];
|
| +}
|
| +
|
| +/**
|
| + * @type {!WebInspector.TargetConnectionManager}
|
| + */
|
| +WebInspector.targetConnectionManager = new WebInspector.TargetConnectionManager();
|
|
|