| OLD | NEW |
| (Empty) | |
| 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. |
| 5 */ |
| 6 |
| 7 /** |
| 8 * @constructor |
| 9 * @extends {WebInspector.Object} |
| 10 */ |
| 11 WebInspector.TargetConnectionManager = function() |
| 12 { |
| 13 WebInspector.Object.call(this); |
| 14 |
| 15 /** @type {!Set<!WebInspector.TargetConnectionManager.Connection>} */ |
| 16 this._connections = new Set(); |
| 17 } |
| 18 |
| 19 /** @enum {symbol} */ |
| 20 WebInspector.TargetConnectionManager.Events = { |
| 21 ConnectionAdded: Symbol("ConnectionAdded"), |
| 22 ConnectionRemoved: Symbol("ConnectionAdded"), |
| 23 } |
| 24 |
| 25 WebInspector.TargetConnectionManager.prototype = { |
| 26 /** |
| 27 * @return {!Array<!WebInspector.TargetConnectionManager.Connection>} |
| 28 */ |
| 29 connections: function() |
| 30 { |
| 31 return Array.from(this._connections); |
| 32 }, |
| 33 |
| 34 /** |
| 35 * @param {!WebInspector.TargetConnectionManager.Connection} connection |
| 36 */ |
| 37 addConnection: function(connection) |
| 38 { |
| 39 this._connections.add(connection); |
| 40 this.dispatchEventToListeners(WebInspector.TargetConnectionManager.Event
s.ConnectionAdded, connection); |
| 41 }, |
| 42 |
| 43 /** |
| 44 * @param {!WebInspector.TargetConnectionManager.Connection} connection |
| 45 */ |
| 46 removeConnection: function(connection) |
| 47 { |
| 48 connection.disconnect(); |
| 49 this._connections.delete(connection); |
| 50 this.dispatchEventToListeners(WebInspector.TargetConnectionManager.Event
s.ConnectionRemoved, connection); |
| 51 }, |
| 52 |
| 53 __proto__: WebInspector.Object.prototype |
| 54 } |
| 55 |
| 56 |
| 57 /** |
| 58 * @interface |
| 59 */ |
| 60 WebInspector.TargetConnectionManager.Connection = function() { }; |
| 61 |
| 62 WebInspector.TargetConnectionManager.Connection.prototype = { |
| 63 /** |
| 64 * @return {string} |
| 65 */ |
| 66 id: function() { }, |
| 67 |
| 68 /** |
| 69 * @return {string} |
| 70 */ |
| 71 name: function() { }, |
| 72 |
| 73 /** |
| 74 * @return {!Promise} |
| 75 */ |
| 76 connect: function() { }, |
| 77 |
| 78 /** |
| 79 * @return {!Promise} |
| 80 */ |
| 81 disconnect: function() { }, |
| 82 } |
| 83 |
| 84 WebInspector.TargetConnectionManager.Connection.symbol = Symbol("connection"); |
| 85 |
| 86 /** |
| 87 * @return {?WebInspector.TargetConnectionManager.Connection} |
| 88 */ |
| 89 WebInspector.TargetConnectionManager.Connection.fromTarget = function(target) |
| 90 { |
| 91 return target[WebInspector.TargetConnectionManager.Connection.symbol]; |
| 92 } |
| 93 |
| 94 /** |
| 95 * @type {!WebInspector.TargetConnectionManager} |
| 96 */ |
| 97 WebInspector.targetConnectionManager = new WebInspector.TargetConnectionManager(
); |
| OLD | NEW |