aboutsummaryrefslogtreecommitdiff
path: root/lib/internal
diff options
context:
space:
mode:
authorSam Roberts <vieuxtech@gmail.com>2018-12-19 14:14:57 -0800
committerSam Roberts <vieuxtech@gmail.com>2018-12-28 12:57:46 -0800
commit00944c7cc25f391c3fbeba1e054a56a62cf0de12 (patch)
treeed5909000282156186e90a55c4a4696c628069c6 /lib/internal
parent03e23a3d10ba66141ff32d668e02a6ce1cdb6b46 (diff)
downloadandroid-node-v8-00944c7cc25f391c3fbeba1e054a56a62cf0de12.tar.gz
android-node-v8-00944c7cc25f391c3fbeba1e054a56a62cf0de12.tar.bz2
android-node-v8-00944c7cc25f391c3fbeba1e054a56a62cf0de12.zip
src: use consistent names for JSStream
Its confusing to call a js class with a handle a "Wrap", usually it's the C++ handle that is called a Wrap (tcp_wrap, tls_wrap, ...). Its derived from Socket, and makes a JS stream look like a Socket, so call it that. Also, remove use of lib/_stream_wrap.js so it can be deprecated some time. PR-URL: https://github.com/nodejs/node/pull/25153 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Diffstat (limited to 'lib/internal')
-rw-r--r--lib/internal/http2/core.js4
-rw-r--r--lib/internal/js_stream_socket.js (renamed from lib/internal/wrap_js_stream.js)15
2 files changed, 10 insertions, 9 deletions
diff --git a/lib/internal/http2/core.js b/lib/internal/http2/core.js
index f33ec48ff2..2bca31e24a 100644
--- a/lib/internal/http2/core.js
+++ b/lib/internal/http2/core.js
@@ -22,7 +22,7 @@ const util = require('util');
const { kIncomingMessage } = require('_http_common');
const { kServerResponse } = require('_http_server');
-const { StreamWrap } = require('_stream_wrap');
+const JSStreamSocket = require('internal/js_stream_socket');
const {
defaultTriggerAsyncIdScope,
@@ -935,7 +935,7 @@ class Http2Session extends EventEmitter {
super();
if (!socket._handle || !socket._handle._externalStream) {
- socket = new StreamWrap(socket);
+ socket = new JSStreamSocket(socket);
}
// No validation is performed on the input parameters because this
diff --git a/lib/internal/wrap_js_stream.js b/lib/internal/js_stream_socket.js
index cf8f45aa45..8343b6c264 100644
--- a/lib/internal/wrap_js_stream.js
+++ b/lib/internal/js_stream_socket.js
@@ -5,7 +5,7 @@ const util = require('util');
const { Socket } = require('net');
const { JSStream } = internalBinding('js_stream');
const uv = internalBinding('uv');
-const debug = util.debuglog('stream_wrap');
+const debug = util.debuglog('stream_socket');
const { owner_symbol } = require('internal/async_hooks').symbols;
const { ERR_STREAM_WRAP } = require('internal/errors').codes;
@@ -29,9 +29,9 @@ function onwrite(req, bufs) { return this[owner_symbol].doWrite(req, bufs); }
* can skip going through the JS layer and let TLS access the raw C++ handle
* of a net.Socket. The flipside of this is that, to maintain composability,
* we need a way to create "fake" net.Socket instances that call back into a
- * "real" JavaScript stream. JSStreamWrap is exactly this.
+ * "real" JavaScript stream. JSStreamSocket is exactly this.
*/
-class JSStreamWrap extends Socket {
+class JSStreamSocket extends Socket {
constructor(stream) {
const handle = new JSStream();
handle.close = (cb) => {
@@ -39,7 +39,7 @@ class JSStreamWrap extends Socket {
this.doClose(cb);
};
// Inside of the following functions, `this` refers to the handle
- // and `this[owner_symbol]` refers to this JSStreamWrap instance.
+ // and `this[owner_symbol]` refers to this JSStreamSocket instance.
handle.isClosing = isClosing;
handle.onreadstart = onreadstart;
handle.onreadstop = onreadstop;
@@ -88,9 +88,10 @@ class JSStreamWrap extends Socket {
this.read(0);
}
- // Legacy
+ // Allow legacy requires in the test suite to keep working:
+ // const { StreamWrap } = require('internal/js_stream_socket')
static get StreamWrap() {
- return JSStreamWrap;
+ return JSStreamSocket;
}
isClosing() {
@@ -223,4 +224,4 @@ class JSStreamWrap extends Socket {
}
}
-module.exports = JSStreamWrap;
+module.exports = JSStreamSocket;