mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 12:51:06 +00:00
Bug 1348272 - Mark nsIInputStream and nsIOutputStream as builtinclass, r=xpcom-reviewers,necko-reviewers,barret,valentin
Differential Revision: https://phabricator.services.mozilla.com/D156893
This commit is contained in:
parent
5e56f89141
commit
449e73f1c7
@ -67,13 +67,17 @@ function runTest(parser, serializer) {
|
||||
is(serializer.serializeToString(parser.parseFromString(t.input, t.type)), t.expected,
|
||||
"parseFromString test for " + t.type);
|
||||
|
||||
let ostream = {
|
||||
write: function(buf, count) { this.data += buf; return count; }
|
||||
};
|
||||
for (let charset of [null, "UTF-8"]) {
|
||||
ostream.data = "";
|
||||
let pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
|
||||
pipe.init(false, false, 0, 0xffffffff, null);
|
||||
let ostream = pipe.outputStream;
|
||||
serializer.serializeToStream(parser.parseFromString(t.input, t.type), ostream, charset);
|
||||
is(ostream.data, t.expected,
|
||||
let istream = Cc["@mozilla.org/scriptableinputstream;1"].createInstance(
|
||||
Ci.nsIScriptableInputStream
|
||||
);
|
||||
istream.init(pipe.inputStream);
|
||||
let data = istream.read(0xffffffff);
|
||||
is(data, t.expected,
|
||||
"serializeToStream test for " + t.type + ", charset=" + charset);
|
||||
}
|
||||
|
||||
|
@ -44,21 +44,11 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1352882
|
||||
ok(str, "encodingToStringWithMaxLength should be successful after calling init again");
|
||||
|
||||
encoder = getEncoder();
|
||||
var stream = {
|
||||
close() {
|
||||
},
|
||||
|
||||
flush() {
|
||||
},
|
||||
|
||||
write(buffer, length) {
|
||||
return length;
|
||||
},
|
||||
|
||||
writeFrom(buffer, length) {
|
||||
return length;
|
||||
},
|
||||
};
|
||||
const UINT32_MAX = 4294967295;
|
||||
let pipe = SpecialPowers.Cc["@mozilla.org/pipe;1"].createInstance(SpecialPowers.Ci.nsIPipe);
|
||||
pipe.init(true, true, 0, UINT32_MAX, null);
|
||||
let stream = pipe.outputStream;
|
||||
|
||||
encoder.setCharset("utf-8");
|
||||
encoder.encodeToStream(stream);
|
||||
|
@ -10,7 +10,7 @@
|
||||
/**
|
||||
* imgIEncoder interface
|
||||
*/
|
||||
[scriptable, uuid(4baa2d6e-fee7-42df-ae3f-5fbebc0c267c)]
|
||||
[scriptable, builtinclass, uuid(4baa2d6e-fee7-42df-ae3f-5fbebc0c267c)]
|
||||
interface imgIEncoder : nsIAsyncInputStream
|
||||
{
|
||||
// Possible values for outputOptions. Multiple values are semicolon-separated.
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Provides scriptable methods for initializing a nsIInputStream
|
||||
* implementation with an ArrayBuffer.
|
||||
*/
|
||||
[scriptable, uuid(3014dde6-aa1c-41db-87d0-48764a3710f6)]
|
||||
[scriptable, builtinclass, uuid(3014dde6-aa1c-41db-87d0-48764a3710f6)]
|
||||
interface nsIArrayBufferInputStream : nsIInputStream
|
||||
{
|
||||
/**
|
||||
|
@ -9,7 +9,7 @@
|
||||
* An input stream that reads ahead and keeps a buffer coming from another input
|
||||
* stream so that fewer accesses to the underlying stream are necessary.
|
||||
*/
|
||||
[scriptable, uuid(616f5b48-da09-11d3-8cda-0060b0fc14a3)]
|
||||
[scriptable, builtinclass, uuid(616f5b48-da09-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsIBufferedInputStream : nsIInputStream
|
||||
{
|
||||
/**
|
||||
@ -30,7 +30,7 @@ interface nsIBufferedInputStream : nsIInputStream
|
||||
* and does the entire write only when the buffer is full, so that fewer writes
|
||||
* to the underlying output stream are necessary.
|
||||
*/
|
||||
[scriptable, uuid(6476378a-da09-11d3-8cda-0060b0fc14a3)]
|
||||
[scriptable, builtinclass, uuid(6476378a-da09-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsIBufferedOutputStream : nsIOutputStream
|
||||
{
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ struct PRFileDesc;
|
||||
/**
|
||||
* An input stream that allows you to read from a file.
|
||||
*/
|
||||
[scriptable, uuid(e3d56a20-c7ec-11d3-8cda-0060b0fc14a3)]
|
||||
[scriptable, builtinclass, uuid(e3d56a20-c7ec-11d3-8cda-0060b0fc14a3)]
|
||||
interface nsIFileInputStream : nsIInputStream
|
||||
{
|
||||
/**
|
||||
@ -85,7 +85,7 @@ interface nsIFileInputStream : nsIInputStream
|
||||
/**
|
||||
* An output stream that lets you stream to a file.
|
||||
*/
|
||||
[scriptable, uuid(e734cac9-1295-4e6f-9684-3ac4e1f91063)]
|
||||
[scriptable, builtinclass, uuid(e734cac9-1295-4e6f-9684-3ac4e1f91063)]
|
||||
interface nsIFileOutputStream : nsIOutputStream
|
||||
{
|
||||
/**
|
||||
@ -132,7 +132,7 @@ interface nsIFileOutputStream : nsIOutputStream
|
||||
/**
|
||||
* A stream that allows you to read from a file or stream to a file.
|
||||
*/
|
||||
[scriptable, uuid(82cf605a-8393-4550-83ab-43cd5578e006)]
|
||||
[scriptable, builtinclass, uuid(82cf605a-8393-4550-83ab-43cd5578e006)]
|
||||
interface nsIFileStream : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -185,7 +185,7 @@ interface nsIFileStream : nsISupports
|
||||
* happen when using RemoteLazyInputStream with an underlying file stream, for
|
||||
* example.
|
||||
*/
|
||||
[scriptable, uuid(07f679e4-9601-4bd1-b510-cd3852edb881)]
|
||||
[scriptable, builtinclass, uuid(07f679e4-9601-4bd1-b510-cd3852edb881)]
|
||||
interface nsIFileMetadata : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -207,7 +207,7 @@ interface nsIFileMetadata : nsISupports
|
||||
[noscript] PRFileDescPtr getFileDescriptor();
|
||||
};
|
||||
|
||||
[scriptable, uuid(de15b80b-29ba-4b7f-9220-a3d75b17ae8c)]
|
||||
[scriptable, builtinclass, uuid(de15b80b-29ba-4b7f-9220-a3d75b17ae8c)]
|
||||
interface nsIAsyncFileMetadata : nsIFileMetadata
|
||||
{
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@
|
||||
* automatic creation of the content-length header.
|
||||
*/
|
||||
|
||||
[scriptable, uuid(dcbce63c-1dd1-11b2-b94d-91f6d49a3161)]
|
||||
[scriptable, builtinclass, uuid(dcbce63c-1dd1-11b2-b94d-91f6d49a3161)]
|
||||
interface nsIMIMEInputStream : nsIInputStream
|
||||
{
|
||||
/**
|
||||
|
@ -701,11 +701,6 @@ function CustomPipe(name) {
|
||||
waiter.eventTarget.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
}
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
"nsIAsyncInputStream",
|
||||
"nsIInputStream",
|
||||
]),
|
||||
});
|
||||
|
||||
/** The output end of this pipe. */
|
||||
@ -1050,11 +1045,6 @@ function CustomPipe(name) {
|
||||
waiter.eventTarget.dispatch(event, Ci.nsIThread.DISPATCH_NORMAL);
|
||||
}
|
||||
},
|
||||
|
||||
QueryInterface: ChromeUtils.generateQI([
|
||||
"nsIAsyncOutputStream",
|
||||
"nsIOutputStream",
|
||||
]),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ interface nsIEventTarget;
|
||||
* necessary that a non-blocking nsIInputStream implementation also implement
|
||||
* nsIAsyncInputStream.
|
||||
*/
|
||||
[scriptable, uuid(a5f255ab-4801-4161-8816-277ac92f6ad1)]
|
||||
[scriptable, builtinclass, uuid(a5f255ab-4801-4161-8816-277ac92f6ad1)]
|
||||
interface nsIAsyncInputStream : nsIInputStream
|
||||
{
|
||||
/**
|
||||
|
@ -19,7 +19,7 @@ interface nsIEventTarget;
|
||||
* necessary that a non-blocking nsIOutputStream implementation also implement
|
||||
* nsIAsyncOutputStream.
|
||||
*/
|
||||
[scriptable, uuid(beb632d3-d77a-4e90-9134-f9ece69e8200)]
|
||||
[scriptable, builtinclass, uuid(beb632d3-d77a-4e90-9134-f9ece69e8200)]
|
||||
interface nsIAsyncOutputStream : nsIOutputStream
|
||||
{
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@
|
||||
* @See nsIBinaryOutputStream
|
||||
*/
|
||||
|
||||
[scriptable, uuid(899b826b-2eb3-469c-8b31-4c29f5d341a6)]
|
||||
[scriptable, builtinclass, uuid(899b826b-2eb3-469c-8b31-4c29f5d341a6)]
|
||||
interface nsIBinaryInputStream : nsIInputStream {
|
||||
void setInputStream(in nsIInputStream aInputStream);
|
||||
|
||||
|
@ -11,7 +11,7 @@ interface nsIOutputStream;
|
||||
* This interface allows writing strings to a stream, doing automatic
|
||||
* character encoding conversion.
|
||||
*/
|
||||
[scriptable, uuid(4b71113a-cb0d-479f-8ed5-01daeba2e8d4)]
|
||||
[scriptable, builtinclass, uuid(4b71113a-cb0d-479f-8ed5-01daeba2e8d4)]
|
||||
interface nsIConverterOutputStream : nsIUnicharOutputStream
|
||||
{
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ interface nsIOutputStream;
|
||||
/**
|
||||
* nsIIOUtil provdes various xpcom/io-related utility methods.
|
||||
*/
|
||||
[scriptable, uuid(e8152f7f-4209-4c63-ad23-c3d2aa0c5a49)]
|
||||
[scriptable, builtinclass, uuid(e8152f7f-4209-4c63-ad23-c3d2aa0c5a49)]
|
||||
interface nsIIOUtil : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -56,7 +56,7 @@ native nsWriteSegmentFun(nsWriteSegmentFun);
|
||||
* the case that a blocking input stream should be implemented using thread-
|
||||
* safe AddRef and Release.
|
||||
*/
|
||||
[scriptable, uuid(53cdbc97-c2d7-4e30-b2c3-45b2ee79db18)]
|
||||
[scriptable, builtinclass, uuid(53cdbc97-c2d7-4e30-b2c3-45b2ee79db18)]
|
||||
interface nsIInputStream : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ interface nsIEventTarget;
|
||||
* reads the specified amount of data from its |source| and copies that
|
||||
* data to its |sink|. |sink| must be a blocking output stream.
|
||||
*/
|
||||
[scriptable, uuid(90a9d790-3bca-421e-a73b-98f68e13c917)]
|
||||
[scriptable, builtinclass, uuid(90a9d790-3bca-421e-a73b-98f68e13c917)]
|
||||
interface nsIInputStreamTee : nsIInputStream
|
||||
{
|
||||
attribute nsIInputStream source;
|
||||
|
@ -50,7 +50,7 @@ native nsReadSegmentFun(nsReadSegmentFun);
|
||||
* generally the case that a blocking output stream should be implemented using
|
||||
* thread- safe AddRef and Release.
|
||||
*/
|
||||
[scriptable, uuid(0d0acd2a-61b4-11d4-9877-00c04fa0cf4a)]
|
||||
[scriptable, builtinclass, uuid(0d0acd2a-61b4-11d4-9877-00c04fa0cf4a)]
|
||||
interface nsIOutputStream : nsISupports
|
||||
{
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user