mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 885982 - Part 4: Remove all traces of JS implementation. r=asuth
This commit is contained in:
parent
fbb088e702
commit
2d0398ffa7
@ -679,11 +679,6 @@
|
||||
@RESPATH@/components/ActivityWrapper.js
|
||||
@RESPATH@/components/ActivityMessageConfigurator.js
|
||||
|
||||
@RESPATH@/components/TCPSocket.js
|
||||
@RESPATH@/components/TCPServerSocket.js
|
||||
@RESPATH@/components/TCPSocketParentIntermediary.js
|
||||
@RESPATH@/components/TCPSocket.manifest
|
||||
|
||||
@RESPATH@/components/Payment.js
|
||||
@RESPATH@/components/PaymentFlowInfo.js
|
||||
@RESPATH@/components/PaymentProvider.js
|
||||
|
@ -567,11 +567,6 @@
|
||||
@RESPATH@/components/InterAppMessagePort.js
|
||||
#endif
|
||||
|
||||
@RESPATH@/components/TCPSocket.js
|
||||
@RESPATH@/components/TCPServerSocket.js
|
||||
@RESPATH@/components/TCPSocketParentIntermediary.js
|
||||
@RESPATH@/components/TCPSocket.manifest
|
||||
|
||||
#ifdef MOZ_ACTIVITIES
|
||||
@RESPATH@/components/SystemMessageCache.js
|
||||
@RESPATH@/components/SystemMessageInternal.js
|
||||
|
@ -1,187 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
const Cr = Components.results;
|
||||
const CC = Components.Constructor;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
const ServerSocket = CC(
|
||||
'@mozilla.org/network/server-socket;1', 'nsIServerSocket', 'init'),
|
||||
TCPSocketInternal = Cc[
|
||||
'@mozilla.org/tcp-socket;1'].createInstance(Ci.nsITCPSocketInternal);
|
||||
|
||||
/*
|
||||
* Debug logging function
|
||||
*/
|
||||
|
||||
var debug = true;
|
||||
function LOG(msg) {
|
||||
if (debug) {
|
||||
dump("TCPServerSocket: " + msg + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* nsIDOMTCPServerSocket object
|
||||
*/
|
||||
|
||||
function TCPServerSocket() {
|
||||
this._localPort = 0;
|
||||
this._binaryType = null;
|
||||
|
||||
this._onconnect = null;
|
||||
this._onerror = null;
|
||||
|
||||
this._inChild = false;
|
||||
this._neckoTCPServerSocket = null;
|
||||
this._serverBridge = null;
|
||||
this.useWin = null;
|
||||
}
|
||||
|
||||
// When this API moves to WebIDL and these __exposedProps__ go away, remove
|
||||
// this call here and remove the API from XPConnect.
|
||||
Cu.skipCOWCallableChecks();
|
||||
|
||||
TCPServerSocket.prototype = {
|
||||
__exposedProps__: {
|
||||
localPort: 'r',
|
||||
onconnect: 'rw',
|
||||
onerror: 'rw'
|
||||
},
|
||||
get localPort() {
|
||||
return this._localPort;
|
||||
},
|
||||
get onconnect() {
|
||||
return this._onconnect;
|
||||
},
|
||||
set onconnect(f) {
|
||||
this._onconnect = f;
|
||||
},
|
||||
get onerror() {
|
||||
return this._onerror;
|
||||
},
|
||||
set onerror(f) {
|
||||
this._onerror = f;
|
||||
},
|
||||
|
||||
_callListenerAcceptCommon: function tss_callListenerAcceptCommon(socket) {
|
||||
if (this._onconnect) {
|
||||
try {
|
||||
this["onconnect"].call(null, socket);
|
||||
} catch (e) {
|
||||
socket.close();
|
||||
}
|
||||
}
|
||||
else {
|
||||
socket.close();
|
||||
dump("Received unexpected connection!");
|
||||
}
|
||||
},
|
||||
init: function tss_init(aWindowObj) {
|
||||
this.useWin = aWindowObj;
|
||||
},
|
||||
|
||||
/* nsITCPServerSocketInternal method */
|
||||
listen: function tss_listen(localPort, options, backlog) {
|
||||
this._inChild = Cc["@mozilla.org/xre/app-info;1"].getService(Ci.nsIXULRuntime)
|
||||
.processType != Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT;
|
||||
this._binaryType = options.binaryType;
|
||||
|
||||
if (this._inChild) {
|
||||
if (this._serverBridge == null) {
|
||||
this._serverBridge = Cc["@mozilla.org/tcp-server-socket-child;1"]
|
||||
.createInstance(Ci.nsITCPServerSocketChild);
|
||||
this._serverBridge.listen(this, localPort, backlog, options.binaryType);
|
||||
}
|
||||
else {
|
||||
throw new Error("Child TCPServerSocket has already listening. \n");
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (this._neckoTCPServerSocket == null) {
|
||||
this._neckoTCPServerSocket = new ServerSocket(localPort, false, backlog);
|
||||
this._localPort = this._neckoTCPServerSocket.port;
|
||||
this._neckoTCPServerSocket.asyncListen(this);
|
||||
}
|
||||
else {
|
||||
throw new Error("Parent TCPServerSocket has already listening. \n");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
callListenerAccept: function tss_callListenerSocket(socketChild) {
|
||||
// this method is called at child process when the socket is accepted at parent process.
|
||||
let socket = TCPSocketInternal.createAcceptedChild(socketChild, this._binaryType, this.useWin);
|
||||
this._callListenerAcceptCommon(socket);
|
||||
},
|
||||
|
||||
callListenerError: function tss_callListenerError(message, filename, lineNumber, columnNumber) {
|
||||
if (this._onerror) {
|
||||
var type = "error";
|
||||
var error = new Error(message, filename, lineNumber, columnNumber);
|
||||
|
||||
this["onerror"].call(null, new TCPSocketEvent(type, this, error));
|
||||
}
|
||||
},
|
||||
/* end nsITCPServerSocketInternal method */
|
||||
|
||||
close: function tss_close() {
|
||||
if (this._inChild) {
|
||||
this._serverBridge.close();
|
||||
return;
|
||||
}
|
||||
|
||||
/* Close ServerSocket */
|
||||
if (this._neckoTCPServerSocket) {
|
||||
this._neckoTCPServerSocket.close();
|
||||
}
|
||||
},
|
||||
|
||||
// nsIServerSocketListener (Triggered by _neckoTCPServerSocket.asyncListen)
|
||||
onSocketAccepted: function tss_onSocketAccepted(server, trans) {
|
||||
// precondition: this._inChild == false
|
||||
try {
|
||||
let that = TCPSocketInternal.createAcceptedParent(trans, this._binaryType,
|
||||
this.useWin);
|
||||
this._callListenerAcceptCommon(that);
|
||||
}
|
||||
catch(e) {
|
||||
trans.close(Cr.NS_BINDING_ABORTED);
|
||||
}
|
||||
},
|
||||
|
||||
// nsIServerSocketListener (Triggered by _neckoTCPServerSocket.asyncListen)
|
||||
onStopListening: function tss_onStopListening(server, status) {
|
||||
if (status != Cr.NS_BINDING_ABORTED) {
|
||||
throw new Error("Server socket was closed by unexpected reason.");
|
||||
}
|
||||
this._neckoTCPServerSocket = null;
|
||||
},
|
||||
|
||||
classID: Components.ID("{73065eae-27dc-11e2-895a-000c29987aa2}"),
|
||||
|
||||
classInfo: XPCOMUtils.generateCI({
|
||||
classID: Components.ID("{73065eae-27dc-11e2-895a-000c29987aa2}"),
|
||||
classDescription: "Server TCP Socket",
|
||||
interfaces: [
|
||||
Ci.nsIDOMTCPServerSocket,
|
||||
Ci.nsISupportsWeakReference
|
||||
],
|
||||
flags: Ci.nsIClassInfo.DOM_OBJECT,
|
||||
}),
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsIDOMTCPServerSocket,
|
||||
Ci.nsITCPServerSocketInternal,
|
||||
Ci.nsISupportsWeakReference
|
||||
])
|
||||
}
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TCPServerSocket]);
|
@ -10,7 +10,6 @@
|
||||
#include "mozilla/net/NeckoChild.h"
|
||||
#include "mozilla/dom/PBrowserChild.h"
|
||||
#include "mozilla/dom/TabChild.h"
|
||||
#include "nsIDOMTCPSocket.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "jsfriendapi.h"
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +0,0 @@
|
||||
# TCPSocket.js
|
||||
component {cda91b22-6472-11e1-aa11-834fec09cd0a} TCPSocket.js
|
||||
contract @mozilla.org/tcp-socket;1 {cda91b22-6472-11e1-aa11-834fec09cd0a}
|
||||
category JavaScript-navigator-property mozTCPSocket @mozilla.org/tcp-socket;1
|
||||
|
||||
# TCPSocketParentIntermediary.js
|
||||
component {afa42841-a6cb-4a91-912f-93099f6a3d18} TCPSocketParentIntermediary.js
|
||||
contract @mozilla.org/tcp-socket-intermediary;1 {afa42841-a6cb-4a91-912f-93099f6a3d18}
|
||||
|
||||
# TCPServerSocket.js
|
||||
component {73065eae-27dc-11e2-895a-000c29987aa2} TCPServerSocket.js
|
||||
contract @mozilla.org/tcp-server-socket;1 {73065eae-27dc-11e2-895a-000c29987aa2}
|
@ -8,7 +8,6 @@
|
||||
#include "jsapi.h"
|
||||
#include "jsfriendapi.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsIDOMTCPSocket.h"
|
||||
#include "mozilla/unused.h"
|
||||
#include "mozilla/AppProcessChecker.h"
|
||||
#include "mozilla/net/NeckoCommon.h"
|
||||
|
@ -9,10 +9,8 @@
|
||||
|
||||
#include "mozilla/dom/TCPSocketBinding.h"
|
||||
#include "mozilla/net/PTCPSocketParent.h"
|
||||
#include "nsITCPSocketParent.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDOMTCPSocket.h"
|
||||
#include "js/TypeDecls.h"
|
||||
#include "mozilla/net/OfflineObserver.h"
|
||||
|
||||
|
@ -1,117 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
||||
function TCPSocketParentIntermediary() {
|
||||
}
|
||||
|
||||
TCPSocketParentIntermediary.prototype = {
|
||||
_setCallbacks: function(aParentSide, socket) {
|
||||
aParentSide.initJS(this);
|
||||
this._socket = socket;
|
||||
|
||||
// Create handlers for every possible callback that attempt to trigger
|
||||
// corresponding callbacks on the child object.
|
||||
// ondrain event is not forwarded, since the decision of firing ondrain
|
||||
// is made in child.
|
||||
["open", "data", "error", "close"].forEach(
|
||||
function(p) {
|
||||
socket["on" + p] = function(data) {
|
||||
aParentSide.sendEvent(p, data.data, socket.readyState,
|
||||
socket.bufferedAmount);
|
||||
};
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
_onUpdateBufferedAmountHandler: function(aParentSide, aBufferedAmount, aTrackingNumber) {
|
||||
aParentSide.sendUpdateBufferedAmount(aBufferedAmount, aTrackingNumber);
|
||||
},
|
||||
|
||||
open: function(aParentSide, aHost, aPort, aUseSSL, aBinaryType,
|
||||
aAppId, aInBrowser) {
|
||||
let baseSocket = Cc["@mozilla.org/tcp-socket;1"].createInstance(Ci.nsIDOMTCPSocket);
|
||||
let socket = baseSocket.open(aHost, aPort, {useSecureTransport: aUseSSL, binaryType: aBinaryType});
|
||||
if (!socket)
|
||||
return null;
|
||||
|
||||
let socketInternal = socket.QueryInterface(Ci.nsITCPSocketInternal);
|
||||
socketInternal.setAppId(aAppId);
|
||||
socketInternal.setInBrowser(aInBrowser);
|
||||
|
||||
// Handle parent's request to update buffered amount.
|
||||
socketInternal.setOnUpdateBufferedAmountHandler(
|
||||
this._onUpdateBufferedAmountHandler.bind(this, aParentSide));
|
||||
|
||||
// Handlers are set to the JS-implemented socket object on the parent side.
|
||||
this._setCallbacks(aParentSide, socket);
|
||||
return socket;
|
||||
},
|
||||
|
||||
listen: function(aTCPServerSocketParent, aLocalPort, aBacklog, aBinaryType,
|
||||
aAppId, aInBrowser) {
|
||||
let baseSocket = Cc["@mozilla.org/tcp-socket;1"].createInstance(Ci.nsIDOMTCPSocket);
|
||||
let serverSocket = baseSocket.listen(aLocalPort, { binaryType: aBinaryType }, aBacklog);
|
||||
if (!serverSocket)
|
||||
return null;
|
||||
|
||||
let localPort = serverSocket.localPort;
|
||||
|
||||
serverSocket["onconnect"] = function(socket) {
|
||||
var socketParent = Cc["@mozilla.org/tcp-socket-parent;1"]
|
||||
.createInstance(Ci.nsITCPSocketParent);
|
||||
var intermediary = new TCPSocketParentIntermediary();
|
||||
|
||||
let socketInternal = socket.QueryInterface(Ci.nsITCPSocketInternal);
|
||||
socketInternal.setAppId(aAppId);
|
||||
socketInternal.setInBrowser(aInBrowser);
|
||||
socketInternal.setOnUpdateBufferedAmountHandler(
|
||||
intermediary._onUpdateBufferedAmountHandler.bind(intermediary, socketParent));
|
||||
|
||||
// Handlers are set to the JS-implemented socket object on the parent side,
|
||||
// so that the socket parent object can communicate data
|
||||
// with the corresponding socket child object through IPC.
|
||||
intermediary._setCallbacks(socketParent, socket);
|
||||
// The members in the socket parent object are set with arguments,
|
||||
// so that the socket parent object can communicate data
|
||||
// with the JS socket object on the parent side via the intermediary object.
|
||||
socketParent.setSocketAndIntermediary(socket, intermediary);
|
||||
aTCPServerSocketParent.sendCallbackAccept(socketParent);
|
||||
};
|
||||
|
||||
serverSocket["onerror"] = function(data) {
|
||||
var error = data.data;
|
||||
|
||||
aTCPServerSocketParent.sendCallbackError(error.message, error.filename,
|
||||
error.lineNumber, error.columnNumber);
|
||||
};
|
||||
|
||||
return serverSocket;
|
||||
},
|
||||
|
||||
onRecvSendString: function(aData, aTrackingNumber) {
|
||||
let socketInternal = this._socket.QueryInterface(Ci.nsITCPSocketInternal);
|
||||
return socketInternal.onRecvSendFromChild(aData, 0, 0, aTrackingNumber);
|
||||
},
|
||||
|
||||
onRecvSendArrayBuffer: function(aData, aTrackingNumber) {
|
||||
let socketInternal = this._socket.QueryInterface(Ci.nsITCPSocketInternal);
|
||||
return socketInternal.onRecvSendFromChild(aData, 0, aData.byteLength,
|
||||
aTrackingNumber);
|
||||
},
|
||||
|
||||
classID: Components.ID("{afa42841-a6cb-4a91-912f-93099f6a3d18}"),
|
||||
QueryInterface: XPCOMUtils.generateQI([
|
||||
Ci.nsITCPSocketIntermediary
|
||||
])
|
||||
};
|
||||
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([TCPSocketParentIntermediary]);
|
@ -5,13 +5,7 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIDOMTCPServerSocket.idl',
|
||||
'nsIDOMTCPSocket.idl',
|
||||
'nsIMozNavigatorNetwork.idl',
|
||||
'nsITCPServerSocketChild.idl',
|
||||
'nsITCPServerSocketParent.idl',
|
||||
'nsITCPSocketChild.idl',
|
||||
'nsITCPSocketParent.idl',
|
||||
'nsIUDPSocketChild.idl',
|
||||
]
|
||||
|
||||
|
@ -1,92 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
#include "nsITCPSocketChild.idl"
|
||||
|
||||
// Bug 797561 - Expose a server tcp socket API to web applications
|
||||
/**
|
||||
* nsIDOMTCPServerSocket
|
||||
*
|
||||
* An interface to a server socket that can accept incoming connections for gaia apps.
|
||||
*/
|
||||
[scriptable, uuid(821638a1-5327-416d-8031-668764f2ec04)]
|
||||
interface nsIDOMTCPServerSocket : nsISupports
|
||||
{
|
||||
/**
|
||||
* The port of this server socket object.
|
||||
*/
|
||||
readonly attribute unsigned short localPort;
|
||||
|
||||
/**
|
||||
* The onconnect event handler is called when a client connection is accepted.
|
||||
* The data attribute of the event passed to the onconnect handler will be a TCPSocket
|
||||
* instance, which is used for communication between client and server.
|
||||
*/
|
||||
attribute jsval onconnect;
|
||||
|
||||
/**
|
||||
* The onerror handler will be called when the listen of a server socket is aborted.
|
||||
* The data attribute of the event passed to the onerror handler will have a
|
||||
* description of the kind of error.
|
||||
*/
|
||||
attribute jsval onerror;
|
||||
|
||||
/**
|
||||
* Close the server socket.
|
||||
*/
|
||||
void close();
|
||||
};
|
||||
|
||||
/**
|
||||
* Internal interfaces for use in cross-process server-socket implementation.
|
||||
* Needed to account for multiple possible types that can be provided to
|
||||
* the socket callbacks as arguments.
|
||||
*
|
||||
* These interfaces are for calling each method from the server socket object
|
||||
* on the parent and child side for an IPC protocol implementation.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(b64b1e68-4efa-497c-b0d8-69f067ad5ec8)]
|
||||
interface nsITCPServerSocketInternal : nsISupports
|
||||
{
|
||||
/**
|
||||
* Initialization after creating a TCP server socket object.
|
||||
*
|
||||
* @param windowVal
|
||||
* An object to create ArrayBuffer for this window. See Bug 831107.
|
||||
*/
|
||||
void init(in jsval windowVal);
|
||||
|
||||
/**
|
||||
* Listen on a port
|
||||
*
|
||||
* @param localPort
|
||||
* The port of the server socket. Pass -1 to indicate no preference,
|
||||
* and a port will be selected automatically.
|
||||
* @param options
|
||||
* An object specifying one or more parameters which
|
||||
* determine the details of the socket.
|
||||
*
|
||||
* binaryType: "arraybuffer" to use UInt8 array
|
||||
* instances in the ondata callback and as the argument
|
||||
* to send. Defaults to "string", to use JavaScript strings.
|
||||
* @param backlog
|
||||
* The maximum length the queue of pending connections may grow to.
|
||||
* This parameter may be silently limited by the operating system.
|
||||
* Pass -1 to use the default value.
|
||||
*/
|
||||
void listen(in unsigned short localPort, in jsval options, in unsigned short backlog);
|
||||
|
||||
/**
|
||||
* Listener for receiving an accepted socket.
|
||||
*/
|
||||
void callListenerAccept(in nsITCPSocketChild socketChild);
|
||||
|
||||
/**
|
||||
* Listener for handling an error caused in chrome process.
|
||||
*/
|
||||
void callListenerError(in DOMString message, in DOMString filename,
|
||||
in uint32_t lineNumber, in uint32_t columnNumber);
|
||||
};
|
@ -1,333 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/**
|
||||
* MozTCPSocket exposes a TCP client and server sockets
|
||||
* to highly privileged apps. It provides a buffered, non-blocking
|
||||
* interface for sending. For receiving, it uses an asynchronous,
|
||||
* event handler based interface.
|
||||
*/
|
||||
|
||||
#include "domstubs.idl"
|
||||
#include "nsIDOMEvent.idl"
|
||||
#include "nsITCPSocketChild.idl"
|
||||
#include "nsIDOMTCPServerSocket.idl"
|
||||
|
||||
interface nsISocketTransport;
|
||||
|
||||
// Bug 731746 - Allow chrome JS object to implement nsIDOMEventTarget
|
||||
// nsITCPSocket should be an nsIEventTarget but js objects
|
||||
// cannot be an nsIEventTarget yet
|
||||
// #include "nsIEventTarget.idl"
|
||||
|
||||
// Bug 723206 - Constructors implemented in JS from IDL should be
|
||||
// allowed to have arguments
|
||||
//
|
||||
// Once bug 723206 will be fixed, this method could be replaced by
|
||||
// arguments when instantiating a TCPSocket object. For example it will
|
||||
// be possible to do (similarly to the WebSocket API):
|
||||
// var s = new MozTCPSocket(host, port);
|
||||
|
||||
// Bug 797561 - Expose a server tcp socket API to web applications
|
||||
|
||||
|
||||
[scriptable, uuid(65f6d2c8-4be6-4695-958d-0735e8935289)]
|
||||
interface nsIDOMTCPSocket : nsISupports
|
||||
{
|
||||
/**
|
||||
* Create and return a socket object which will attempt to connect to
|
||||
* the given host and port.
|
||||
*
|
||||
* @param host The hostname of the server to connect to.
|
||||
* @param port The port to connect to.
|
||||
* @param options An object specifying one or more parameters which
|
||||
* determine the details of the socket.
|
||||
*
|
||||
* useSecureTransport: true to create an SSL socket. Defaults to false.
|
||||
*
|
||||
* binaryType: "arraybuffer" to use ArrayBuffer
|
||||
* instances in the ondata callback and as the argument
|
||||
* to send. Defaults to "string", to use JavaScript strings.
|
||||
*
|
||||
* @return The new TCPSocket instance.
|
||||
*/
|
||||
nsIDOMTCPSocket open(in DOMString host, in unsigned short port, [optional] in jsval options);
|
||||
|
||||
/**
|
||||
* Listen on a port
|
||||
*
|
||||
* @param localPort The port of the server socket. Pass -1 to indicate no preference,
|
||||
* and a port will be selected automatically.
|
||||
* @param options An object specifying one or more parameters which
|
||||
* determine the details of the socket.
|
||||
*
|
||||
* binaryType: "arraybuffer" to use ArrayBuffer
|
||||
* instances in the ondata callback and as the argument
|
||||
* to send. Defaults to "string", to use JavaScript strings.
|
||||
* @param backlog The maximum length the queue of pending connections may grow to.
|
||||
* This parameter may be silently limited by the operating system.
|
||||
* Pass -1 to use the default value.
|
||||
*
|
||||
* @return The new TCPServerSocket instance.
|
||||
*/
|
||||
nsIDOMTCPServerSocket listen(in unsigned short localPort, [optional] in jsval options,
|
||||
[optional] in unsigned short backlog);
|
||||
|
||||
/**
|
||||
* Enable secure on channel.
|
||||
*/
|
||||
void upgradeToSecure();
|
||||
|
||||
/**
|
||||
* The host of this socket object.
|
||||
*/
|
||||
readonly attribute DOMString host;
|
||||
|
||||
/**
|
||||
* The port of this socket object.
|
||||
*/
|
||||
readonly attribute unsigned short port;
|
||||
|
||||
/**
|
||||
* True if this socket object is an SSL socket.
|
||||
*/
|
||||
readonly attribute boolean ssl;
|
||||
|
||||
/**
|
||||
* The number of bytes which have previously been buffered by calls to
|
||||
* send on this socket.
|
||||
*/
|
||||
readonly attribute unsigned long bufferedAmount;
|
||||
|
||||
/**
|
||||
* Pause reading incoming data and invocations of the ondata handler until
|
||||
* resume is called.
|
||||
*/
|
||||
void suspend();
|
||||
|
||||
/**
|
||||
* Resume reading incoming data and invoking ondata as usual.
|
||||
*/
|
||||
void resume();
|
||||
|
||||
/**
|
||||
* Close the socket.
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Write data to the socket.
|
||||
*
|
||||
* @param data The data to write to the socket. If
|
||||
* binaryType: "arraybuffer" was passed in the options
|
||||
* object, then this object should be an ArrayBuffer instance.
|
||||
* If binaryType: "string" was passed, or if no binaryType
|
||||
* option was specified, then this object should be an
|
||||
* ordinary JavaScript string.
|
||||
* @param byteOffset The offset within the data from which to begin writing.
|
||||
* Has no effect on non-ArrayBuffer data.
|
||||
* @param byteLength The number of bytes to write. Has no effect on
|
||||
* non-ArrayBuffer data.
|
||||
*
|
||||
* @return Send returns true or false as a hint to the caller that
|
||||
* they may either continue sending more data immediately, or
|
||||
* may want to wait until the other side has read some of the
|
||||
* data which has already been written to the socket before
|
||||
* buffering more. If send returns true, then less than 64k
|
||||
* has been buffered and it's safe to immediately write more.
|
||||
* If send returns false, then more than 64k has been buffered,
|
||||
* and the caller may wish to wait until the ondrain event
|
||||
* handler has been called before buffering more data by more
|
||||
* calls to send.
|
||||
*/
|
||||
boolean send(in jsval data, [optional] in unsigned long byteOffset, [optional] in unsigned long byteLength);
|
||||
|
||||
/**
|
||||
* The readyState attribute indicates which state the socket is currently
|
||||
* in. The state will be either "connecting", "open", "closing", or "closed".
|
||||
*/
|
||||
readonly attribute DOMString readyState;
|
||||
|
||||
/**
|
||||
* The binaryType attribute indicates which mode this socket uses for
|
||||
* sending and receiving data. If the binaryType: "arraybuffer" option
|
||||
* was passed to the open method that created this socket, binaryType
|
||||
* will be "arraybuffer". Otherwise, it will be "string".
|
||||
*/
|
||||
readonly attribute DOMString binaryType;
|
||||
|
||||
/**
|
||||
* The onopen event handler is called when the connection to the server
|
||||
* has been established. If the connection is refused, onerror will be
|
||||
* called, instead.
|
||||
*/
|
||||
attribute jsval onopen;
|
||||
|
||||
/**
|
||||
* After send has buffered more than 64k of data, it returns false to
|
||||
* indicate that the client should pause before sending more data, to
|
||||
* avoid accumulating large buffers. This is only advisory, and the client
|
||||
* is free to ignore it and buffer as much data as desired, but if reducing
|
||||
* the size of buffers is important (especially for a streaming application)
|
||||
* ondrain will be called once the previously-buffered data has been written
|
||||
* to the network, at which point the client can resume calling send again.
|
||||
*/
|
||||
attribute jsval ondrain;
|
||||
|
||||
/**
|
||||
* The ondata handler will be called repeatedly and asynchronously after
|
||||
* onopen has been called, every time some data was available from the server
|
||||
* and was read. If binaryType: "arraybuffer" was passed to open, the data
|
||||
* attribute of the event object will be an ArrayBuffer. If not, it will be a
|
||||
* normal JavaScript string.
|
||||
*
|
||||
* At any time, the client may choose to pause reading and receiving ondata
|
||||
* callbacks, by calling the socket's suspend() method. Further invocations
|
||||
* of ondata will be paused until resume() is called.
|
||||
*/
|
||||
attribute jsval ondata;
|
||||
|
||||
/**
|
||||
* The onerror handler will be called when there is an error. The data
|
||||
* attribute of the event passed to the onerror handler will have a
|
||||
* description of the kind of error.
|
||||
*
|
||||
* If onerror is called before onopen, the error was connection refused,
|
||||
* and onclose will not be called. If onerror is called after onopen,
|
||||
* the connection was lost, and onclose will be called after onerror.
|
||||
*/
|
||||
attribute jsval onerror;
|
||||
|
||||
/**
|
||||
* The onclose handler is called once the underlying network socket
|
||||
* has been closed, either by the server, or by the client calling
|
||||
* close.
|
||||
*
|
||||
* If onerror was not called before onclose, then either side cleanly
|
||||
* closed the connection.
|
||||
*/
|
||||
attribute jsval onclose;
|
||||
};
|
||||
|
||||
/*
|
||||
* This interface is implemented in TCPSocket.js as an internal interfaces
|
||||
* for use in cross-process socket implementation.
|
||||
* Needed to account for multiple possible types that can be provided to
|
||||
* the socket callbacks as arguments.
|
||||
*/
|
||||
[scriptable, uuid(ac2c4b69-cb79-4767-b1ce-bcf62945cd39)]
|
||||
interface nsITCPSocketInternal : nsISupports {
|
||||
// Trigger the callback for |type| and provide a DOMError() object with the given data
|
||||
void callListenerError(in DOMString type, in DOMString name);
|
||||
|
||||
// Trigger the callback for |type| and provide a string argument
|
||||
void callListenerData(in DOMString type, in DOMString data);
|
||||
|
||||
// Trigger the callback for |type| and provide an ArrayBuffer argument
|
||||
void callListenerArrayBuffer(in DOMString type, in jsval data);
|
||||
|
||||
// Trigger the callback for |type| with no argument
|
||||
void callListenerVoid(in DOMString type);
|
||||
|
||||
// Update the DOM object's readyState.
|
||||
// @param readyState
|
||||
// new ready state to be set to TCPSocket.
|
||||
void updateReadyState(in DOMString readyState);
|
||||
|
||||
// Update the DOM object's bufferedAmount value with a tracking number to
|
||||
// ensure the update request is sent after child's send() invocation.
|
||||
// @param bufferedAmount
|
||||
// TCPSocket parent's bufferedAmount.
|
||||
// @param trackingNumber
|
||||
// A number to ensure the bufferedAmount is updated after data
|
||||
// from child are sent to parent.
|
||||
void updateBufferedAmount(in uint32_t bufferedAmount,
|
||||
in uint32_t trackingNumber);
|
||||
|
||||
// Create a socket object on the parent side.
|
||||
// This is called in accepting any open request on the parent side.
|
||||
//
|
||||
// @param transport
|
||||
// The accepted socket transport.
|
||||
// @param binaryType
|
||||
// "arraybuffer" to use ArrayBuffer instances
|
||||
// in the ondata callback and as the argument to send.
|
||||
// @param window
|
||||
// An object to create ArrayBuffer for this window. See Bug 831107.
|
||||
nsIDOMTCPSocket createAcceptedParent(in nsISocketTransport transport,
|
||||
in DOMString binaryType,
|
||||
in nsIDOMWindow window);
|
||||
|
||||
// Create a DOM socket on the child side
|
||||
// This is called when the socket is accepted on the parent side.
|
||||
//
|
||||
// @param socketChild
|
||||
// The socket child object for the IPC implementation.
|
||||
// @param binaryType
|
||||
// "arraybuffer" to use ArrayBuffer instances
|
||||
// in the ondata callback and as the argument to send.
|
||||
// @param window
|
||||
// An object to create ArrayBuffer for this window. See Bug 831107.
|
||||
nsIDOMTCPSocket createAcceptedChild(in nsITCPSocketChild socketChild,
|
||||
in DOMString binaryType,
|
||||
in nsIDOMWindow window);
|
||||
|
||||
// Set App ID.
|
||||
void setAppId(in unsigned long appId);
|
||||
|
||||
// Set inBrowser.
|
||||
void setInBrowser(in boolean inBrowser);
|
||||
|
||||
// Set a callback that handles the request from a TCP socket parent when that
|
||||
// socket parent wants to notify that its bufferedAmount is updated.
|
||||
void setOnUpdateBufferedAmountHandler(in jsval handler);
|
||||
|
||||
// Providing child process with ability to pass more arguments to parent's
|
||||
// send() function.
|
||||
// @param trackingNumber
|
||||
// To ensure the request to update bufferedAmount in child is after
|
||||
// lastest send() invocation from child.
|
||||
void onRecvSendFromChild(in jsval data, in unsigned long byteOffset,
|
||||
in unsigned long byteLength, in unsigned long trackingNumber);
|
||||
};
|
||||
|
||||
/**
|
||||
* nsITCPSocketEvent is the event object which is passed as the
|
||||
* first argument to all the event handler callbacks. It contains
|
||||
* the socket that was associated with the event, the type of event,
|
||||
* and the data associated with the event (if any).
|
||||
*/
|
||||
|
||||
[scriptable, uuid(0f2abcca-b483-4539-a3e8-345707f75c44)]
|
||||
interface nsITCPSocketEvent : nsISupports {
|
||||
/**
|
||||
* The socket object which produced this event.
|
||||
*/
|
||||
readonly attribute nsIDOMTCPSocket target;
|
||||
|
||||
/**
|
||||
* The type of this event. One of:
|
||||
*
|
||||
* open
|
||||
* error
|
||||
* data
|
||||
* drain
|
||||
* close
|
||||
*/
|
||||
readonly attribute DOMString type;
|
||||
|
||||
/**
|
||||
* The data related to this event, if any. In the ondata callback,
|
||||
* data will be the bytes read from the network; if the binaryType
|
||||
* of the socket was "arraybuffer", this value will be of type ArrayBuffer;
|
||||
* otherwise, it will be a normal JavaScript string.
|
||||
*
|
||||
* In the onerror callback, data will be a string with a description
|
||||
* of the error.
|
||||
*
|
||||
* In the other callbacks, data will be an empty string.
|
||||
*/
|
||||
readonly attribute jsval data;
|
||||
};
|
||||
|
@ -1,39 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
#include "nsIDOMTCPServerSocket.idl"
|
||||
|
||||
interface nsITCPServerSocketInternal;
|
||||
|
||||
/**
|
||||
* Interface to allow the content process server socket to reach the IPC bridge.
|
||||
* It is used in the server socket implementation on the child side.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(41a77ec8-fd86-409e-aea9-af2ca407ef8e)]
|
||||
interface nsITCPServerSocketChild : nsISupports
|
||||
{
|
||||
/**
|
||||
* Tell the chrome process to listen on the port with the given parameters.
|
||||
*
|
||||
* @param serverSocket
|
||||
* The server socket generated in the listen of nsIDOMTCPSocket
|
||||
* on the child side.
|
||||
* @param port
|
||||
* The port of the server socket.
|
||||
* @param backlog
|
||||
* The maximum length the queue of pending connections may grow to.
|
||||
* @param binaryType
|
||||
* "arraybuffer" to use UInt8 array instances or "string" to use String.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
void listen(in nsITCPServerSocketInternal serverSocket, in unsigned short port,
|
||||
in unsigned short backlog, in DOMString binaryType);
|
||||
|
||||
/**
|
||||
* Tell the chrome process to close the server socket.
|
||||
*/
|
||||
void close();
|
||||
};
|
@ -1,42 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
#include "nsITCPSocketParent.idl"
|
||||
|
||||
interface nsIDOMTCPServerSocket;
|
||||
|
||||
/**
|
||||
* Interface required to allow the TCP server-socket object in the parent process
|
||||
* to talk to the parent IPC actor.
|
||||
* It is used in the server socket implementation on the parent side.
|
||||
*/
|
||||
[scriptable, uuid(161ffc9f-54d3-4f21-a536-4166003d0e1d)]
|
||||
interface nsITCPServerSocketParent : nsISupports
|
||||
{
|
||||
/**
|
||||
* Trigger a callback in the content process when the socket accepts any request.
|
||||
*
|
||||
* @param socket
|
||||
* The socket generated in accepting any open request on the parent side.
|
||||
*/
|
||||
void sendCallbackAccept(in nsITCPSocketParent socket);
|
||||
|
||||
/**
|
||||
* Trigger a callback in the content process when an error occurs.
|
||||
*
|
||||
* @param message
|
||||
* The error message.
|
||||
* @param filename
|
||||
* The file name in which the error occured.
|
||||
* @param lineNumber
|
||||
* The line number in which the error occured.
|
||||
* @param columnNumber
|
||||
* The column number in which the error occured.
|
||||
*/
|
||||
void sendCallbackError(in DOMString message,
|
||||
in DOMString filename,
|
||||
in uint32_t lineNumber,
|
||||
in uint32_t columnNumber);
|
||||
};
|
@ -1,50 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsITCPSocketInternal;
|
||||
interface nsIDOMWindow;
|
||||
|
||||
// Interface to allow the content process socket to reach the IPC bridge.
|
||||
// Implemented in C++ as TCPSocketChild, referenced as _socketBridge in TCPSocket.js
|
||||
[scriptable, uuid(4277aff0-4c33-11e3-8f96-0800200c9a66)]
|
||||
interface nsITCPSocketChild : nsISupports
|
||||
{
|
||||
// Tell the chrome process to open a corresponding connection with the given parameters
|
||||
[implicit_jscontext]
|
||||
void sendOpen(in nsITCPSocketInternal socket, in DOMString host,
|
||||
in unsigned short port, in boolean ssl, in DOMString binaryType,
|
||||
in nsIDOMWindow window, in jsval windowVal);
|
||||
|
||||
// Tell the chrome process to perform send and update the tracking number.
|
||||
[implicit_jscontext]
|
||||
void sendSend(in jsval data, in unsigned long byteOffset,
|
||||
in unsigned long byteLength, in unsigned long trackingNumber);
|
||||
|
||||
// Tell the chrome process to perform equivalent operations to all following methods
|
||||
void sendResume();
|
||||
void sendSuspend();
|
||||
void sendClose();
|
||||
void sendStartTLS();
|
||||
|
||||
/**
|
||||
* Initialize the TCP socket on the child side for IPC. It is called from the child side,
|
||||
* which is generated in receiving a notification of accepting any open request
|
||||
* on the parent side. We use single implementation that works on a child process
|
||||
* as well as in the single process model.
|
||||
*
|
||||
* @param socket
|
||||
* The TCP socket on the child side.
|
||||
* This instance is connected with the child IPC side of the IPC bridge.
|
||||
* @param windowVal
|
||||
* The window object on the child side to create data
|
||||
* as "jsval" for deserialization.
|
||||
*/
|
||||
[implicit_jscontext]
|
||||
void setSocketAndWindow(in nsITCPSocketInternal socket, in jsval windowVal);
|
||||
|
||||
readonly attribute DOMString host;
|
||||
readonly attribute unsigned short port;
|
||||
};
|
@ -1,89 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
interface nsIDOMTCPSocket;
|
||||
interface nsIDOMTCPServerSocket;
|
||||
interface nsITCPServerSocketParent;
|
||||
interface nsITCPSocketIntermediary;
|
||||
|
||||
// Interface required to allow the TCP socket object (TCPSocket.js) in the
|
||||
// parent process to talk to the parent IPC actor, TCPSocketParent, which
|
||||
// is written in C++.
|
||||
[scriptable, uuid(6f040bf0-6852-11e3-949a-0800200c9a66)]
|
||||
interface nsITCPSocketParent : nsISupports
|
||||
{
|
||||
[implicit_jscontext] void initJS(in jsval intermediary);
|
||||
|
||||
// Trigger a callback in the content process for |type|, providing a serialized
|
||||
// argument of |data|, and update the child's readyState value with the given
|
||||
// values.
|
||||
//
|
||||
// @param type
|
||||
// Event type: 'onopen', 'ondata', 'onerror' or 'onclose'. 'odrain' is
|
||||
// controlled by child.
|
||||
// @param data
|
||||
// Serialized data that is passed to event handler.
|
||||
// @param readyState
|
||||
// Current ready state.
|
||||
[implicit_jscontext] void sendEvent(in DOMString type,
|
||||
in jsval data,
|
||||
in DOMString readyState);
|
||||
|
||||
// Initialize a parent socket object. It is called from the parent side socket,
|
||||
// which is generated in accepting any open request on the parent side.
|
||||
// The socket after being initialized will be established.
|
||||
//
|
||||
// @param socket
|
||||
// The socket on the parent side.
|
||||
// @param intermediary
|
||||
// Intermediate class object. See nsITCPSocketIntermediary.
|
||||
[implicit_jscontext] void setSocketAndIntermediary(in nsIDOMTCPSocket socket,
|
||||
in nsITCPSocketIntermediary intermediary);
|
||||
|
||||
// When parent's buffered amount is updated and it wants to inform child to
|
||||
// update the bufferedAmount as well.
|
||||
//
|
||||
// @param bufferedAmount
|
||||
// The new value of bufferedAmount that is going to be set to child's
|
||||
// bufferedAmount.
|
||||
// @param trackingNumber
|
||||
// Parent's current tracking number, reflecting the number of calls to
|
||||
// send() on the child process. This number is sent back to the child
|
||||
// to make sure the bufferedAmount updated on the child will correspond
|
||||
// to the latest call of send().
|
||||
void sendUpdateBufferedAmount(in uint32_t bufferedAmount, in uint32_t trackingNumber);
|
||||
|
||||
readonly attribute DOMString host;
|
||||
readonly attribute unsigned short port;
|
||||
};
|
||||
|
||||
// Intermediate class to handle sending multiple possible data types
|
||||
// and kicking off the chrome process socket object's connection.
|
||||
// This interface is the bridge of TCPSocketParent, which is written in C++,
|
||||
// and TCPSocket, which is written in Javascript. TCPSocketParentIntermediary
|
||||
// implements nsITCPSocketIntermediary in Javascript.
|
||||
[scriptable, uuid(aa9bd46d-26bf-4ba8-9c18-ba02482c02f0)]
|
||||
interface nsITCPSocketIntermediary : nsISupports {
|
||||
// Open the connection to the server with the given parameters
|
||||
nsIDOMTCPSocket open(in nsITCPSocketParent parent,
|
||||
in DOMString host, in unsigned short port,
|
||||
in boolean useSSL, in DOMString binaryType,
|
||||
in unsigned long appId,
|
||||
in boolean inBrowser);
|
||||
|
||||
// Listen on a port
|
||||
nsIDOMTCPServerSocket listen(in nsITCPServerSocketParent parent,
|
||||
in unsigned short port, in unsigned short backlog,
|
||||
in DOMString binaryType,
|
||||
in unsigned long appId,
|
||||
in boolean inBrowser);
|
||||
|
||||
// Called when received a child request to send a string.
|
||||
void onRecvSendString(in DOMString data, in uint32_t trackingNumber);
|
||||
|
||||
// Called when received a child request to send an array buffer.
|
||||
void onRecvSendArrayBuffer(in jsval data, in uint32_t trackingNumber);
|
||||
};
|
@ -48,16 +48,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
'NetworkStatsService.jsm',
|
||||
]
|
||||
|
||||
EXTRA_COMPONENTS += [
|
||||
'TCPServerSocket.js',
|
||||
'TCPSocket.manifest',
|
||||
'TCPSocketParentIntermediary.js',
|
||||
]
|
||||
|
||||
EXTRA_PP_COMPONENTS += [
|
||||
'TCPSocket.js',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
EXTRA_COMPONENTS += [
|
||||
'NetworkStatsManager.js',
|
||||
|
@ -19,7 +19,7 @@ SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({"set": [['dom.mozTCPSocket.enabled', true]]}, runTest);
|
||||
function runTest() {
|
||||
is('TCPSocket' in this, false, "TCPSocket should not be accessible if dom.mozTCPSocket.enabled is true");
|
||||
is('mozTCPSocket' in navigator, true, "mozTCPSocket should be accessible if dom.mozTCPSocket.enabled is true");
|
||||
is('mozTCPSocket' in navigator, false, "mozTCPSocket should be accessible if dom.mozTCPSocket.enabled is true");
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
@ -423,11 +423,6 @@
|
||||
@BINPATH@/components/ActivityWrapper.js
|
||||
@BINPATH@/components/ActivityMessageConfigurator.js
|
||||
|
||||
@BINPATH@/components/TCPSocket.js
|
||||
@BINPATH@/components/TCPSocketParentIntermediary.js
|
||||
@BINPATH@/components/TCPServerSocket.js
|
||||
@BINPATH@/components/TCPSocket.manifest
|
||||
|
||||
#ifdef MOZ_WEBRTC
|
||||
@BINPATH@/components/PeerConnection.js
|
||||
@BINPATH@/components/PeerConnection.manifest
|
||||
|
@ -425,11 +425,6 @@
|
||||
@BINPATH@/components/SystemMessageCache.js
|
||||
@BINPATH@/components/SystemMessageManager.manifest
|
||||
|
||||
@BINPATH@/components/TCPSocket.js
|
||||
@BINPATH@/components/TCPSocketParentIntermediary.js
|
||||
@BINPATH@/components/TCPServerSocket.js
|
||||
@BINPATH@/components/TCPSocket.manifest
|
||||
|
||||
#ifdef MOZ_WEBRTC
|
||||
@BINPATH@/components/PeerConnection.js
|
||||
@BINPATH@/components/PeerConnection.manifest
|
||||
|
Loading…
Reference in New Issue
Block a user