Граф коммитов

3218 Коммитов

Автор SHA1 Сообщение Дата
Barret Rennie 6d359be1d0 Bug 1786608 - Add nsIFile::accessTime{,OfLink} r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D155926
2022-11-06 18:33:22 +00:00
Barret Rennie 6d99f6fc5c Bug 1786608 - Do not set atime on Windows in nsLocalFile::SetModifiedTime r=xpcom-reviewers,kmag
Differential Revision: https://phabricator.services.mozilla.com/D155925
2022-11-06 18:33:22 +00:00
Jan Varga b1ffbdb845 Bug 1791734 - Add nsIRandomAccessStream serialization support; r=ipc-reviewers,necko-reviewers,dom-storage-reviewers,nika,jesup
Only nsFileRandomAccessStream is supported for now.

Differential Revision: https://phabricator.services.mozilla.com/D157794
2022-10-27 16:12:30 +00:00
Jan Varga b03f79878a Bug 1791729 - Expose StreamBufferSource implementations; r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D157791
2022-10-26 18:01:48 +00:00
Jan Varga 8747eec0d4 Bug 1791725 - Add FixedBufferOutputStream; r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D157790
2022-10-26 15:56:38 +00:00
Robert Longson a546daf2d8 Bug 1795568 Part 1 - Remove plugin support code r=emilio
Differential Revision: https://phabricator.services.mozilla.com/D159465
2022-10-24 18:56:41 +00:00
Jari Jalkanen cc27d88b5d Bug 1746894 - Handle GetTemporaryStorageLimit failures with upper limit. r=dom-storage-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D140990
2022-10-24 15:15:33 +00:00
Cristian Tuns 165dbe266b Backed out changeset 02f4220a827c (bug 1746894) for causing mochitest failures on antitracking_head.js CLOSED TREE 2022-10-20 12:43:25 -04:00
Jari Jalkanen e99f516901 Bug 1746894 - Handle GetTemporaryStorageLimit failures with upper limit. r=dom-storage-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D140990
2022-10-20 15:35:50 +00:00
Cristian Tuns b81c0c9725 Backed out changeset 47a5cc9cd2f6 (bug 1746894) for causing build bustages on ActorsParent.cpp CLOSED TREE 2022-10-20 06:59:31 -04:00
Jari Jalkanen 5731f46ef8 Bug 1746894 - Handle GetTemporaryStorageLimit failures with upper limit. r=dom-storage-reviewers,jesup
Differential Revision: https://phabricator.services.mozilla.com/D140990
2022-10-20 10:42:16 +00:00
Alexandre Lissy f955bb9c1e Bug 1785278 - Reading AutoConfig from /etc/firefox when running under Snap r=mkaply,xpcom-reviewers,barret
Differential Revision: https://phabricator.services.mozilla.com/D159059
2022-10-18 21:06:43 +00:00
Emilio Cobos Álvarez 633b70954e Bug 1791029 - Deal with lstat potentially lying in nsLocalFileUnix. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D158796
2022-10-06 23:29:18 +00:00
Jens Stutte ec8b482d3b Bug 1792041 - Add a value for DEL to kBase64URLDecodeTable and have static asserts for lookup tables' length. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D158239
2022-09-29 21:56:28 +00:00
Andrew McCreight 2da84b8ac4 Bug 1792574, part 3 - Don't include nsMemory where it isn't needed. r=xpcom-reviewers,necko-reviewers,valentin,nika
There are only 3 places where nsMemory.h is still needed (image/RasterImage.cpp,
gfx/thebes/gfxFT2FontList.cpp, and nsMemory.cpp). Remove the rest.

Differential Revision: https://phabricator.services.mozilla.com/D158213
2022-09-28 15:17:46 +00:00
Andrew McCreight 8b86b655f6 Bug 1792574, part 1 - Move nsAssignmentType to nsStringStream.h. r=xpcom-reviewers,nika
That's the only place it is used.

Differential Revision: https://phabricator.services.mozilla.com/D158211
2022-09-28 15:17:45 +00:00
Jan Varga a82e48e896 Bug 1791721 - Create a dedicated interface for read write (input output) streams; r=xpcom-reviewers,necko-reviewers,nika,valentin
Differential Revision: https://phabricator.services.mozilla.com/D157786
2022-09-23 05:36:24 +00:00
Nika Layzell 449e73f1c7 Bug 1348272 - Mark nsIInputStream and nsIOutputStream as builtinclass, r=xpcom-reviewers,necko-reviewers,barret,valentin
Differential Revision: https://phabricator.services.mozilla.com/D156893
2022-09-09 18:22:36 +00:00
Marian-Vasile Laza 78b100abc0 Backed out changeset 10ea141649b6 (bug 1348272) for causing mochitest failures on test_domparsing.xhtml. CLOSED TREE 2022-09-09 19:21:48 +03:00
Nika Layzell b24f79de71 Bug 1348272 - Mark nsIInputStream and nsIOutputStream as builtinclass, r=xpcom-reviewers,necko-reviewers,barret,valentin
Differential Revision: https://phabricator.services.mozilla.com/D156893
2022-09-09 13:29:30 +00:00
Nika Layzell aef919f890 Bug 1170668 - Improve short read handling in nsConverterInputStream, r=hsivonen
This patch changes how nsConverterInputStream handles passing data
through to the underlying unicode converter in order to make it more
reliably handle propagating errors and deal with short reads from the
underlying input stream.

This was done by making the code continuously read within the Fill
method until at least one character has been decoded from the input
stream, so that we don't spuriously communicate an EOF to the caller due
to a short read not producing enough bytes for the decoder to produce a
UTF-16 character.

In addition, while making this change it became easier to signal to
the decoder about the final read from the input stream, meaning that
partial characters at the end of the stream will now generate a
replacement character, rather than being ignored.

Differential Revision: https://phabricator.services.mozilla.com/D152682
2022-08-11 17:37:20 +00:00
Norisz Fay 948922a968 Backed out changeset 2c6bb36b0667 (bug 1170668) for causing build bustages on TestShortRead.cpp CLOSED TREE 2022-08-11 00:01:03 +03:00
Nika Layzell 1972b3b710 Bug 1170668 - Improve short read handling in nsConverterInputStream, r=hsivonen
This patch changes how nsConverterInputStream handles passing data
through to the underlying unicode converter in order to make it more
reliably handle propagating errors and deal with short reads from the
underlying input stream.

This was done by making the code continuously read within the Fill
method until at least one character has been decoded from the input
stream, so that we don't spuriously communicate an EOF to the caller due
to a short read not producing enough bytes for the decoder to produce a
UTF-16 character.

In addition, while making this change it became easier to signal to
the decoder about the final read from the input stream, meaning that
partial characters at the end of the stream will now generate a
replacement character, rather than being ignored.

Differential Revision: https://phabricator.services.mozilla.com/D152682
2022-08-10 19:44:41 +00:00
Nika Layzell 512a0022d1 Bug 1782181 - Part 2: Notify nsMultiplexInputStream callbacks if AsyncWait fails, r=asuth
When `nsMultiplexInputStream` calls `AsyncWait` from within
`OnInputStreamReady`, it is possible for those calls to fail. In that case, we
will fail to notify AsyncWait listeners, which could lead to leaks or stream
hangs. This patch changes the error handling in this situation to instead fire
a pending stream callback after an error when re-dispatching `AsyncWait`.

Depends on D153628

Differential Revision: https://phabricator.services.mozilla.com/D153629
2022-08-03 19:36:29 +00:00
Nika Layzell b7b9c6816e Bug 1782181 - Part 1: Support canceling AsyncWait in nsMultiplexInputStream, r=asuth
Previously nsMultiplexInputStream would not call `AsyncWait` again when the
callback was cleared, meaning that the underlying wait wouldn't actually be
cancelled. This patch changes the behaviour to more consistently forward the
cancelling call to the underlying stream.

There are still some cases where the call will not be cancelled if a read or
other event caused the stream cursor to advance before canceling, however those
should generally be uncommon.

Differential Revision: https://phabricator.services.mozilla.com/D153628
2022-08-03 19:36:29 +00:00
Fabrice Desré c50cb528fc Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-03 16:39:41 +00:00
Andreea Pavel 3ccd75af8d Backed out changeset b9d2965591b9 (bug 1761040) for landing with wrong author CLOSED TREE DONTBUILD 2022-08-03 18:55:00 +03:00
Andreea Pavel fdb7cb2ecd Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-03 15:27:43 +00:00
Andreea Pavel 89d63c91e6 Backed out changeset a907159a482f (bug 1761040) for causing build bustages on a CLOSED TREE 2022-08-02 04:59:08 +03:00
Fabrice Desré 0f4ac7ad97 Bug 1761040 - Prefix thread safety macros with MOZ_ r=geckoview-reviewers,media-playback-reviewers,alwu,jesup,m_kato
Differential Revision: https://phabricator.services.mozilla.com/D152575
2022-08-02 00:49:41 +00:00
Nika Layzell c15823d075 Bug 1772006 - Part 5: Simplify and move the string searching APIs from ns[T]StringObsolete, r=xpcom-reviewers,necko-reviewers,eeejay,dragana,barret
The biggest set of APIs from ns[T]StringObsolete which are still heavily used
are the string searching APIs. It appears the intention was for these to be
replaced by the `FindInReadable` APIs, however that doesn't appear to have
happened.

In addition, the APIs have some quirks around their handling of mixed character
widths. These APIs generally supported both narrow strings and the native
string type, probably because char16_t string literals weren't available until
c++11. Finally they also used easy-to-confuse unlabeled boolean and integer
optional arguments to control behaviour.

These patches do the following major changes to the searching APIs:

1. The ASCII case-insensitive search method was split out as
   LowerCaseFindASCII, rather than using a boolean. This should be less
   error-prone and more explicit, and allows the method to continue to use
   narrow string literals for all string types (as only ASCII is supported).
2. The other [R]Find methods were restricted to only support arguments with
   matching character types. I considered adding a FindASCII method which would
   use narrow string literals for both wide and narrow strings but it would've
   been the same amount of work as changing all of the literals to unicode
   literals.
   This ends up being the bulk of the changes in the patch.
3. All find methods were re-implemented using std::basic_string_view's find
   algorithm or stl algorithms to reduce code complexity, and avoid the need to
   carry around the logic from nsStringObsolete.cpp.
4. The implementations were moved to nsTStringRepr.cpp.
5. An overload of Find was added to try to catch callers which previously
   called `Find(..., false)` or `Find(..., true)` to set case-sensitivity, due
   to booleans normally implicitly coercing to `index_type`. This should
   probably be removed at some point, but may be useful during the transition.

Differential Revision: https://phabricator.services.mozilla.com/D148300
2022-07-30 00:12:48 +00:00
Nika Layzell 997047e2a4 Bug 1772006 - Part 4: Simplify and move the string comparison APIs from ns[T]StringObsolete, r=xpcom-reviewers,necko-reviewers,dragana,barret
This patch moves EqualsIgnoreCase to ns[T]StringObsolete, and removes
the aCount argument, instead migrating callers to use `StringBeginsWith`
with a case-insensitive comparator.

In addition, nsTStringRepr::Compare was removed and replaced with either
calls to methods like `StringBeginsWith` or the global `Compare` method.

These changes required some modifications at call-sites but should make
the behaviour less surprising and more consistent.

Differential Revision: https://phabricator.services.mozilla.com/D148299
2022-07-30 00:12:48 +00:00
Nika Layzell f71f45508c Bug 1780054 - Part 2: Double-check notified stream in nsMultiplexInputStream, r=asuth
Previously, we could end up in situations where nsMultiplexInputStream
would receive a callback for a previously notified stream after it had
already advanced to the next stream due to the async nature of
notifications. This could cause us to skip a stream accidentally. This
changes the logic to re-call AsyncWait in that situation on the correct
stream rather than skipping streams.

Differential Revision: https://phabricator.services.mozilla.com/D152930
2022-07-28 15:01:49 +00:00
Jan Rio Krause b2f117c4d5 Bug 1690326 - Map Windows error `ERROR_NO_SYSTEM_RESOURCES` (0x5AA) to `NS_ERROR_OUT_OF_MEMORY`. r=xpcom-reviewers,kmag
Differential Revision: https://phabricator.services.mozilla.com/D151736
2022-07-14 18:52:33 +00:00
serge-sans-paille 580a244ae7 Bug 1774864 - Cleanup xpcom/ includes r=sylvestre
Differential Revision: https://phabricator.services.mozilla.com/D149671
2022-06-24 07:13:59 +00:00
Jan Rio Krause ceb9221d80 Bug 1690326 - Map Windows error `ERROR_DEV_NOT_EXIST` (0x37) to `NS_ERROR_FILE_DEVICE_FAILURE`. r=xpcom-reviewers,barret
Differential Revision: https://phabricator.services.mozilla.com/D149904
2022-06-22 16:44:36 +00:00
criss c6b2c5db61 Backed out 9 changesets (bug 1772006) causing build bustages on nsTString.cpp. CLOSED TREE
Backed out changeset f17c7565707b (bug 1772006)
Backed out changeset c725fe1f5882 (bug 1772006)
Backed out changeset d19663161261 (bug 1772006)
Backed out changeset b6611ab002d9 (bug 1772006)
Backed out changeset 790f42b64af9 (bug 1772006)
Backed out changeset 79a734b4e4d9 (bug 1772006)
Backed out changeset 42730aae16ea (bug 1772006)
Backed out changeset b2542aef3054 (bug 1772006)
Backed out changeset 962bfea4a309 (bug 1772006)
2022-06-11 01:13:42 +03:00
Nika Layzell b3c13bf114 Bug 1772006 - Part 6: Simplify and move the string searching APIs from ns[T]StringObsolete, r=xpcom-reviewers,necko-reviewers,eeejay,dragana,barret
The biggest set of APIs from ns[T]StringObsolete which are still heavily used
are the string searching APIs. It appears the intention was for these to be
replaced by the `FindInReadable` APIs, however that doesn't appear to have
happened.

In addition, the APIs have some quirks around their handling of mixed character
widths. These APIs generally supported both narrow strings and the native
string type, probably because char16_t string literals weren't available until
c++11. Finally they also used easy-to-confuse unlabeled boolean and integer
optional arguments to control behaviour.

These patches do the following major changes to the searching APIs:

1. The ASCII case-insensitive search method was split out as
   LowerCaseFindASCII, rather than using a boolean. This should be less
   error-prone and more explicit, and allows the method to continue to use
   narrow string literals for all string types (as only ASCII is supported).
2. The other [R]Find methods were restricted to only support arguments with
   matching character types. I considered adding a FindASCII method which would
   use narrow string literals for both wide and narrow strings but it would've
   been the same amount of work as changing all of the literals to unicode
   literals.
   This ends up being the bulk of the changes in the patch.
3. All find methods were re-implemented using std::basic_string_view's find
   algorithm or stl algorithms to reduce code complexity, and avoid the need to
   carry around the logic from nsStringObsolete.cpp.
4. The implementations were moved to nsTStringRepr.cpp.
5. An overload of Find was added to try to catch callers which previously
   called `Find(..., false)` or `Find(..., true)` to set case-sensitivity, due
   to booleans normally implicitly coercing to `index_type`. This should
   probably be removed at some point, but may be useful during the transition.

Differential Revision: https://phabricator.services.mozilla.com/D148300
2022-06-10 21:12:08 +00:00
Gijs Kruitbosch a3f9a3f4e2 Bug 1707462 - expose Windows' localized file display names through XPCOM, r=mhowell
Differential Revision: https://phabricator.services.mozilla.com/D143480
2022-05-23 21:57:02 +00:00
Barret Rennie 868f461b18 Bug 1769094 - nsLocalFile::Append{,RelativePath} should throw when appending .. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D146228
2022-05-21 23:03:51 +00:00
Chris Peterson c686ea7b47 Bug 1770107 - Disambiguate char16_t* operator== overloads in MinGW build for C++23. r=xpcom-reviewers,nika
C++23 is stricer about matching operator== overloads than C++17 and char16ptr_t's implicit constructor causes some overload confusion. We can disambigutate the operator== overloads by adding typed local variables without needing type casts.

xpcom/io/nsLinebreakConverter.cpp:447:17: error: use of overloaded operator '!=' is ambiguous (with operand types 'nsTSubstring<char16_t>::iterator' (aka 'char16_t *') and 'typename raw_type<char16_t, int>::type' (aka 'char16ptr_t'))
 if (stringBuf != aIoString.get()) {
     ~~~~~~~~~ ^  ~~~~~~~~~~~~~~~
mozilla/Char16.h:95:8: note: candidate function (with reversed parameter order)
 bool operator==(const char16ptr_t& aOther) const {
      ^
xpcom/io/nsLinebreakConverter.cpp:447:17: note: built-in candidate operator!=(const char16_t *, const char16_t *)
 if (stringBuf != aIoString.get()) {
               ^
xpcom/io/nsLinebreakConverter.cpp:447:17: note: built-in candidate operator!=(const volatile char16_t *, const volatile char16_t *)
xpcom/io/nsLinebreakConverter.cpp:447:17: note: built-in candidate operator!=(const void *, const void *)
xpcom/io/nsLinebreakConverter.cpp:447:17: note: built-in candidate operator!=(const volatile void *, const volatile void *)

Differential Revision: https://phabricator.services.mozilla.com/D146772
2022-05-20 06:06:19 +00:00
Butkovits Atila 7bbda20470 Backed out changeset 37142ab92a09 (bug 1769094) for causing gecko view failures at TestFilePreferencesUnix. CLOSED TREE 2022-05-20 08:25:24 +03:00
Barret Rennie f32c9fbea0 Bug 1769094 - nsLocalFile::Append{,RelativePath} should throw when appending .. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D146228
2022-05-20 03:03:27 +00:00
Iulian Moraru 4f7b7b518b Backed out changeset 6f5cd18d3b57 (bug 1769094) for causing gtest failures on TestFilePreferencesUnix.Simple. 2022-05-18 20:41:06 +03:00
Barret Rennie 06c8e5da3d Bug 1769094 - nsLocalFile::Append{,RelativePath} should throw when appending .. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D146228
2022-05-18 16:45:44 +00:00
Andrew McCreight fa8bfd1245 Bug 1514936, part 2 - Drop the outer arguments from static components. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D146457
2022-05-17 20:24:19 +00:00
Nika Layzell 59f3f40567 Bug 1767517 - Part 2: Annotate nsPipe for the thread safety analysis, r=jesup,xpcom-reviewers,KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D145394
2022-05-16 20:40:49 +00:00
Randell Jesup 00859f1620 Bug 1762959 - xpcom/io thread-safety annotations r=nika
Differential Revision: https://phabricator.services.mozilla.com/D142066
2022-05-16 13:54:05 +00:00
Randell Jesup d3b15de2f1 Bug 1762920: remove whitelist from xpcom/crashreporter r=nika,gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D142843
2022-05-16 01:37:39 +00:00
Iulian Moraru 8cfdac9a59 Backed out changeset eb32954c1f4c (bug 1769094) for causing multiple failures. 2022-05-13 21:00:50 +03:00
Emilio Cobos Álvarez 87ff5a5d8d Bug 1768418 - Move various methods from nsTString to nsTSubstring/nsTStringRepr. r=xpcom-reviewers,nika
No reason these don't work on substrings.

Remove StripChars since it has an existing nsTSubstring version. Make
callers use rightly-typed characters for those.

Differential Revision: https://phabricator.services.mozilla.com/D145864
2022-05-13 15:39:19 +00:00
Barret Rennie 9dea84af2a Bug 1769094 - nsLocalFile::Append{,RelativePath} should throw when appending .. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D146228
2022-05-13 15:08:47 +00:00
Nika Layzell 873e958e4f Bug 1754004 - Part 18: Ensure AsyncWait callbacks are cleared when NS_AsyncCopy completes, r=xpcom-reviewers,mccr8
When the NS_AsyncCopy completes, there may still be outstanding
AsyncWait callbacks which have not been invoked yet, due to two
AsyncWait callbacks being registered each time Process() yields (one to
wait for the blocked stream, and the other with WAIT_CLOSURE_ONLY to
handle errors), and only one callback being needed to resume processing.

This change ensures that any outstanding AsyncWait callbacks are
cancelled, breaking references from the streams to the
nsAStreamCallback. Some streams (such as nsPipe and DataPipe) may also
leak if there are oustanding AsyncWait callbacks, due to the need to
keep the stream alive so it can be passed into the callback, which this
helps avoid.

Previously leaks were largely avoided due to the call to `Close()`
cancelling the callbacks for us, however not all callsites specify to
close the source/sink.

This should also help avoid an unnecessary dispatch after the copy
completes due to our AsyncWait callback being invoked when the
source/sink stream is closed.

Differential Revision: https://phabricator.services.mozilla.com/D146130
2022-05-13 14:16:16 +00:00
Nika Layzell b82512de01 Bug 1754004 - Part 17: Keep pipe streams alive so long as there's a callback registered, r=asuth
If we don't do this, we can encounter issues where we'll spuriously close the
stream when the last reference to the input stream is dropped while an
AsyncWait is still pending.

Differential Revision: https://phabricator.services.mozilla.com/D145672
2022-05-13 14:16:16 +00:00
Nika Layzell d5fa382918 Bug 1754004 - Part 15: Don't track mOriginalInput in nsPipe, r=asuth
As discovered by TSan, this member could be raced on in some edge-cases if
cloned pipe streams raced on multiple threads to be destroyed. This change
instead moves the `nsIPipe` implementation to be on a seperate type from
`nsPipe`, allowing `mOriginalInput` to no longer need to be tracked.

This technically has slightly different behaviour than the previous
implementation for JS code, as code keeping the `nsIPipe` alive will now also
be keeping the output stream reference alive directly, rather than only holding
the `nsIPipe`, meaning that `pipe.outputStream` can be read multiple times
independently without implicitly closing the underlying stream. Based on a
quick read of the few remaining uses of `nsIPipe` in JS code, I don't think
this will be an issue, and it may actually be more intuitive and consistent.

Differential Revision: https://phabricator.services.mozilla.com/D145362
2022-05-13 14:16:15 +00:00
Nika Layzell ae579d351c Bug 1754004 - Part 14: Fix potential skipping of async streams in nsMultiplexInputStream, r=asuth
Before this change, we could run into issues when an async stream
accepts new data and queues a runnable to notify the stream listener,
but before that stream listener's runnable is run, the target thread
reads data from the async stream, emptying it of any available data.
This would mean that the stream appears empty in
nsMultiplexInputStream::OnInputStreamReady, and the rest of the stream
is skipped.

This patch changes the logic in OnInputStreamReady to re-call AsyncWait
in those situations and avoid skipping over the empty stream, preventing
data loss.

This situation came up when running some HTTP tests under rr with the
socket process enabled, as the upload stream can both be read due to an
OnInputStreamReady callback and due to other calls in the HTTP
machinery, leading to this potential race. With the socket process
enabled, it is possible for the upload stream to be an async pipe, which
doesn't happen in the parent process due to stream normalization.

This change makes an assumption about the behaviour of streams
implementing `nsIAsyncInputStream` which I believe is correct right now,
and has been documented. I originally had other patches which modified
`Available()`'s definition to add an extra outparameter or added extra
methods, but this seemed much simpler and accurate based on my memory of
having read the Available() implementations for async streams in-tree.

A gtest was added for the failing situation using both nsPipe and DataPipe.

Differential Revision: https://phabricator.services.mozilla.com/D144451
2022-05-13 14:16:14 +00:00
Nika Layzell 1aa11ffed6 Bug 1754004 - Part 11: Simplify the IPCStream serialization API, r=asuth,necko-reviewers,kershaw
As serializing IPCStream no longer requires a manager or FileDescriptor array,
the arguments are no longer necessary, and can be removed. The AutoIPCStream
helper can also be removed, as managed actors are no longer used for
serialization, so a delayed start callback is not necessary.

The delayed start parameter is also removed from nsIIPCSerializableInputStream
instances, but is still present as `aAllowLazy` on the toplevel serialization
methods.

Differential Revision: https://phabricator.services.mozilla.com/D141048
2022-05-13 14:16:13 +00:00
Nika Layzell 89567e0ee9 Bug 1754004 - Part 8: Remove SeekableStreamWrapper, r=asuth,necko-reviewers,kershaw
This type is no longer necessary, and has various issues due to behaving
incorrectly when used with async streams or streams which are not nsIPipe.

Differential Revision: https://phabricator.services.mozilla.com/D141045
2022-05-13 14:16:12 +00:00
Nika Layzell 76b98a65e4 Bug 1754004 - Part 7: Consistently normalize upload streams passed to HTTP channels, r=asuth,necko-reviewers,dragana
Unfortunately, upload streams used by necko have various odd behaviours
and requirements which happened to be usually preserved by the previous
IPC serialization logic, but were not consistently preserved. This
includes requiring the stream to be synchronous (as some consumers such
as WebExtensions and DevTools appear to read it assuming Available() is
the stream length), seekable (as it needs to be rewound in various
places), and cloneable (as the stream information is often handed out to
other components).

In addition, the WebExtension WebRequest code makes assumptions about
the specific topology of the input stream for optimization purposes,
meaning that nsMultiplexInputStreams need to be preserved.

The way this was previously handled was by copying the entire payload
into a nsStorageStream as an async operation. This happened very
infrequently in out test suite, however, and had some issues. It could
lead to data loss if the stream was a nsMIMEInputStream (as the metadata
would be lost), and would destroy the topology required by WebRequest.

This patch changes the code to instead manually walk and replace streams
in the input stream's data structure, to efficiently copy only the
required data, preserve the invariants, and make the type seekable
before AsyncOpen continues. This helps keep the complexity of the
invariants HTTPChannel depends on out of generic input stream handling
code.

In addition, due to how early this happens, it replaces the need for
PartiallySeekableInputStream which will be removed a later part.

Differential Revision: https://phabricator.services.mozilla.com/D141044
2022-05-13 14:16:11 +00:00
Nika Layzell caacb618c0 Bug 1759572 - AsyncLengthWaitHelper should be threadsafe, r=asuth
This works only because the only implementation of nsIAsyncInputStreamLength
happened to only run on the current thread. Bug 1754004, changes this, and requires the reference to be threadsafe.

Differential Revision: https://phabricator.services.mozilla.com/D141037
2022-05-13 14:16:08 +00:00
Nika Layzell 7fb91b57a3 Bug 1759563 - Add SerializedComplexity to limit the complexity of serialized IPCStream instances, r=asuth,necko-reviewers,dragana
This will improve the efficiency of serializing large data pipes, which in bad
cases can end up serializing very small amounts of data in individual pipes
over IPC, and acts as a compliment to the existing logic for limiting
serialized message sizes. It is also necessary for the changes in bug 1754004,
which require the ability to include FileDescriptor inline in the message,
which could blow out our FileDescriptor count limits if pipe creation was
unlimited.

In some tests, this change reduces the number of pipes required to serialize a
nsIInputStream from over 5000 to 1.

Differential Revision: https://phabricator.services.mozilla.com/D141036
2022-05-13 14:16:08 +00:00
Nika Layzell 366aafadae Bug 1759569 - Retain nsIInputStreamLength through NS_CloneInputStream, r=asuth
This will help in bug 1754004 as in some cases we will want to clone a
DataPipe, which is non-cloneable, and without this change length information
would be lost.

In the future it might be worth making a more generic mechanism for efficiently
cloning wrapper input streams with a fallback rather than hard-coding this
interface.

Differential Revision: https://phabricator.services.mozilla.com/D141035
2022-05-13 14:16:08 +00:00
Nika Layzell a906eaf6b2 Bug 1754031 - AsyncWait implementations should support updating flags on an existing listener, r=asuth,necko-reviewers,dragana
This operation is often performed by nsAStreamCopier when switching
between the source and sink streams, in order to enable or disable the
WAIT_CLOSURE_ONLY flag. Failing to reset the wait flags can lead to a
NS_AsyncCopy hanging until the source or sink are closed when is
alternating between waiting on input and output streams. This patch
relaxes the incorrect checks on various input streams.

Differential Revision: https://phabricator.services.mozilla.com/D141034
2022-05-13 14:16:07 +00:00
Butkovits Atila d5e0f927a0 Backed out changeset 9d6d0af194af (bug 1762920) for causing failures at test_crash_manager. CLOSED TREE 2022-05-13 01:44:55 +03:00
Randell Jesup e4786a68a6 Bug 1762920: remove whitelist from xpcom/crashreporter r=nika,gsvelto
Differential Revision: https://phabricator.services.mozilla.com/D142843
2022-05-12 21:07:25 +00:00
Noemi Erli 45276205df Backed out 22 changesets (bug 1696894, bug 1759569, bug 1754031, bug 1759563, bug 1759572, bug 1754004) for causing leack failures CLOSED TREE
Backed out changeset 673ecd5337e1 (bug 1754004)
Backed out changeset ecbf5f3c51de (bug 1754004)
Backed out changeset fc6c39f56d21 (bug 1754004)
Backed out changeset 5b3d58fbaf9d (bug 1696894)
Backed out changeset 2e56c89cf55d (bug 1754004)
Backed out changeset b7723490f025 (bug 1754004)
Backed out changeset 1dfbf61ff5dd (bug 1754004)
Backed out changeset e73abb071bb3 (bug 1754004)
Backed out changeset f9abe4fbf501 (bug 1754004)
Backed out changeset ee7aeb631cd9 (bug 1754004)
Backed out changeset d66aacfcf983 (bug 1754004)
Backed out changeset 5c2872ad6912 (bug 1754004)
Backed out changeset e1ae48f30d2c (bug 1754004)
Backed out changeset 849b63707d7f (bug 1754004)
Backed out changeset 36563e3b1e04 (bug 1754004)
Backed out changeset ccb4be659107 (bug 1754004)
Backed out changeset 659581d4159b (bug 1754004)
Backed out changeset 611ea76d7a9c (bug 1754004)
Backed out changeset 9b24b561698c (bug 1759572)
Backed out changeset f820e0f209ff (bug 1759563)
Backed out changeset 8d82066fa181 (bug 1759569)
Backed out changeset a2835afab1ad (bug 1754031)
2022-05-11 06:16:25 +03:00
Nika Layzell d55bc07275 Bug 1754004 - Part 17: Keep pipe streams alive so long as there's a callback registered, r=asuth
If we don't do this, we can encounter issues where we'll spuriously close the
stream when the last reference to the input stream is dropped while an
AsyncWait is still pending.

Differential Revision: https://phabricator.services.mozilla.com/D145672
2022-05-10 22:27:49 +00:00
Nika Layzell 7068e4bbb7 Bug 1754004 - Part 15: Don't track mOriginalInput in nsPipe, r=asuth
As discovered by TSan, this member could be raced on in some edge-cases if
cloned pipe streams raced on multiple threads to be destroyed. This change
instead moves the `nsIPipe` implementation to be on a seperate type from
`nsPipe`, allowing `mOriginalInput` to no longer need to be tracked.

This technically has slightly different behaviour than the previous
implementation for JS code, as code keeping the `nsIPipe` alive will now also
be keeping the output stream reference alive directly, rather than only holding
the `nsIPipe`, meaning that `pipe.outputStream` can be read multiple times
independently without implicitly closing the underlying stream. Based on a
quick read of the few remaining uses of `nsIPipe` in JS code, I don't think
this will be an issue, and it may actually be more intuitive and consistent.

Differential Revision: https://phabricator.services.mozilla.com/D145362
2022-05-10 22:27:48 +00:00
Nika Layzell aa45b7b586 Bug 1754004 - Part 14: Fix potential skipping of async streams in nsMultiplexInputStream, r=asuth
Before this change, we could run into issues when an async stream
accepts new data and queues a runnable to notify the stream listener,
but before that stream listener's runnable is run, the target thread
reads data from the async stream, emptying it of any available data.
This would mean that the stream appears empty in
nsMultiplexInputStream::OnInputStreamReady, and the rest of the stream
is skipped.

This patch changes the logic in OnInputStreamReady to re-call AsyncWait
in those situations and avoid skipping over the empty stream, preventing
data loss.

This situation came up when running some HTTP tests under rr with the
socket process enabled, as the upload stream can both be read due to an
OnInputStreamReady callback and due to other calls in the HTTP
machinery, leading to this potential race. With the socket process
enabled, it is possible for the upload stream to be an async pipe, which
doesn't happen in the parent process due to stream normalization.

This change makes an assumption about the behaviour of streams
implementing `nsIAsyncInputStream` which I believe is correct right now,
and has been documented. I originally had other patches which modified
`Available()`'s definition to add an extra outparameter or added extra
methods, but this seemed much simpler and accurate based on my memory of
having read the Available() implementations for async streams in-tree.

A gtest was added for the failing situation using both nsPipe and DataPipe.

Differential Revision: https://phabricator.services.mozilla.com/D144451
2022-05-10 22:27:47 +00:00
Nika Layzell 024c6e0c0a Bug 1754004 - Part 11: Simplify the IPCStream serialization API, r=asuth,necko-reviewers,kershaw
As serializing IPCStream no longer requires a manager or FileDescriptor array,
the arguments are no longer necessary, and can be removed. The AutoIPCStream
helper can also be removed, as managed actors are no longer used for
serialization, so a delayed start callback is not necessary.

The delayed start parameter is also removed from nsIIPCSerializableInputStream
instances, but is still present as `aAllowLazy` on the toplevel serialization
methods.

Differential Revision: https://phabricator.services.mozilla.com/D141048
2022-05-10 22:27:46 +00:00
Nika Layzell a520c86f48 Bug 1754004 - Part 8: Remove SeekableStreamWrapper, r=asuth,necko-reviewers,kershaw
This type is no longer necessary, and has various issues due to behaving
incorrectly when used with async streams or streams which are not nsIPipe.

Differential Revision: https://phabricator.services.mozilla.com/D141045
2022-05-10 22:27:44 +00:00
Nika Layzell 873f2d6175 Bug 1754004 - Part 7: Consistently normalize upload streams passed to HTTP channels, r=asuth,necko-reviewers,dragana
Unfortunately, upload streams used by necko have various odd behaviours
and requirements which happened to be usually preserved by the previous
IPC serialization logic, but were not consistently preserved. This
includes requiring the stream to be synchronous (as some consumers such
as WebExtensions and DevTools appear to read it assuming Available() is
the stream length), seekable (as it needs to be rewound in various
places), and cloneable (as the stream information is often handed out to
other components).

In addition, the WebExtension WebRequest code makes assumptions about
the specific topology of the input stream for optimization purposes,
meaning that nsMultiplexInputStreams need to be preserved.

The way this was previously handled was by copying the entire payload
into a nsStorageStream as an async operation. This happened very
infrequently in out test suite, however, and had some issues. It could
lead to data loss if the stream was a nsMIMEInputStream (as the metadata
would be lost), and would destroy the topology required by WebRequest.

This patch changes the code to instead manually walk and replace streams
in the input stream's data structure, to efficiently copy only the
required data, preserve the invariants, and make the type seekable
before AsyncOpen continues. This helps keep the complexity of the
invariants HTTPChannel depends on out of generic input stream handling
code.

In addition, due to how early this happens, it replaces the need for
PartiallySeekableInputStream which will be removed a later part.

Differential Revision: https://phabricator.services.mozilla.com/D141044
2022-05-10 22:27:44 +00:00
Nika Layzell 7fcc3e78ed Bug 1759572 - AsyncLengthWaitHelper should be threadsafe, r=asuth
This works only because the only implementation of nsIAsyncInputStreamLength
happened to only run on the current thread. Bug 1754004, changes this, and requires the reference to be threadsafe.

Differential Revision: https://phabricator.services.mozilla.com/D141037
2022-05-10 22:27:41 +00:00
Nika Layzell 7aead901b8 Bug 1759563 - Add SerializedComplexity to limit the complexity of serialized IPCStream instances, r=asuth,necko-reviewers,dragana
This will improve the efficiency of serializing large data pipes, which in bad
cases can end up serializing very small amounts of data in individual pipes
over IPC, and acts as a compliment to the existing logic for limiting
serialized message sizes. It is also necessary for the changes in bug 1754004,
which require the ability to include FileDescriptor inline in the message,
which could blow out our FileDescriptor count limits if pipe creation was
unlimited.

In some tests, this change reduces the number of pipes required to serialize a
nsIInputStream from over 5000 to 1.

Differential Revision: https://phabricator.services.mozilla.com/D141036
2022-05-10 22:27:41 +00:00
Nika Layzell e00878d3f2 Bug 1759569 - Retain nsIInputStreamLength through NS_CloneInputStream, r=asuth
This will help in bug 1754004 as in some cases we will want to clone a
DataPipe, which is non-cloneable, and without this change length information
would be lost.

In the future it might be worth making a more generic mechanism for efficiently
cloning wrapper input streams with a fallback rather than hard-coding this
interface.

Differential Revision: https://phabricator.services.mozilla.com/D141035
2022-05-10 22:27:40 +00:00
Nika Layzell 52ee800295 Bug 1754031 - AsyncWait implementations should support updating flags on an existing listener, r=asuth,necko-reviewers,dragana
This operation is often performed by nsAStreamCopier when switching
between the source and sink streams, in order to enable or disable the
WAIT_CLOSURE_ONLY flag. Failing to reset the wait flags can lead to a
NS_AsyncCopy hanging until the source or sink are closed when is
alternating between waiting on input and output streams. This patch
relaxes the incorrect checks on various input streams.

Differential Revision: https://phabricator.services.mozilla.com/D141034
2022-05-10 22:27:40 +00:00
Neil Deakin d8b26cb066 Bug 1746052, don't allow Windows reserved filenames when sanitizing filenames. Move MangleTextToValidFileName to nsLocalFileWin and rename it to CheckForReservedFileName, r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D138737
2022-05-06 10:00:55 +00:00
Noemi Erli 39469989c9 Backed out 22 changesets (bug 1759572, bug 1759563, bug 1754004, bug 1754031, bug 1759569, bug 1696894) for causing multiple failures CLOSED TREE
Backed out changeset d69647a725a1 (bug 1754004)
Backed out changeset 09fc506865d7 (bug 1754004)
Backed out changeset 648e3dd4b62f (bug 1754004)
Backed out changeset 3465158ee230 (bug 1696894)
Backed out changeset b08475bbfbd9 (bug 1754004)
Backed out changeset dfabce587a56 (bug 1754004)
Backed out changeset cebe8d5dda34 (bug 1754004)
Backed out changeset 55b4b0c9a504 (bug 1754004)
Backed out changeset e8649de9dd22 (bug 1754004)
Backed out changeset 0f480fc861c0 (bug 1754004)
Backed out changeset e515b7edd1c8 (bug 1754004)
Backed out changeset fe90db9158ac (bug 1754004)
Backed out changeset c6388d682d48 (bug 1754004)
Backed out changeset 2374420d9fed (bug 1754004)
Backed out changeset 44dfd76472aa (bug 1754004)
Backed out changeset 000fb99de0cf (bug 1754004)
Backed out changeset 0ca1856b5fc9 (bug 1754004)
Backed out changeset 10c3683b998b (bug 1754004)
Backed out changeset 4abc98ed6b99 (bug 1759572)
Backed out changeset cdd271a5af42 (bug 1759563)
Backed out changeset fadb6cc0d81c (bug 1759569)
Backed out changeset 44be9709a93e (bug 1754031)
2022-05-06 04:28:47 +03:00
Nika Layzell cf7142badb Bug 1754004 - Part 17: Keep pipe streams alive so long as there's a callback registered, r=asuth
If we don't do this, we can encounter issues where we'll spuriously close the
stream when the last reference to the input stream is dropped while an
AsyncWait is still pending.

Depends on D145363

Differential Revision: https://phabricator.services.mozilla.com/D145672
2022-05-05 23:34:27 +00:00
Nika Layzell db4bdb5b5d Bug 1754004 - Part 15: Don't track mOriginalInput in nsPipe, r=asuth
As discovered by TSan, this member could be raced on in some edge-cases if
cloned pipe streams raced on multiple threads to be destroyed. This change
instead moves the `nsIPipe` implementation to be on a seperate type from
`nsPipe`, allowing `mOriginalInput` to no longer need to be tracked.

This technically has slightly different behaviour than the previous
implementation for JS code, as code keeping the `nsIPipe` alive will now also
be keeping the output stream reference alive directly, rather than only holding
the `nsIPipe`, meaning that `pipe.outputStream` can be read multiple times
independently without implicitly closing the underlying stream. Based on a
quick read of the few remaining uses of `nsIPipe` in JS code, I don't think
this will be an issue, and it may actually be more intuitive and consistent.

Differential Revision: https://phabricator.services.mozilla.com/D145362
2022-05-05 23:34:26 +00:00
Nika Layzell 85694759b2 Bug 1754004 - Part 14: Fix potential skipping of async streams in nsMultiplexInputStream, r=asuth
Before this change, we could run into issues when an async stream
accepts new data and queues a runnable to notify the stream listener,
but before that stream listener's runnable is run, the target thread
reads data from the async stream, emptying it of any available data.
This would mean that the stream appears empty in
nsMultiplexInputStream::OnInputStreamReady, and the rest of the stream
is skipped.

This patch changes the logic in OnInputStreamReady to re-call AsyncWait
in those situations and avoid skipping over the empty stream, preventing
data loss.

This situation came up when running some HTTP tests under rr with the
socket process enabled, as the upload stream can both be read due to an
OnInputStreamReady callback and due to other calls in the HTTP
machinery, leading to this potential race. With the socket process
enabled, it is possible for the upload stream to be an async pipe, which
doesn't happen in the parent process due to stream normalization.

This change makes an assumption about the behaviour of streams
implementing `nsIAsyncInputStream` which I believe is correct right now,
and has been documented. I originally had other patches which modified
`Available()`'s definition to add an extra outparameter or added extra
methods, but this seemed much simpler and accurate based on my memory of
having read the Available() implementations for async streams in-tree.

A gtest was added for the failing situation using both nsPipe and DataPipe.

Differential Revision: https://phabricator.services.mozilla.com/D144451
2022-05-05 23:34:25 +00:00
Nika Layzell 445ea16482 Bug 1754004 - Part 11: Simplify the IPCStream serialization API, r=asuth,necko-reviewers,kershaw
As serializing IPCStream no longer requires a manager or FileDescriptor array,
the arguments are no longer necessary, and can be removed. The AutoIPCStream
helper can also be removed, as managed actors are no longer used for
serialization, so a delayed start callback is not necessary.

The delayed start parameter is also removed from nsIIPCSerializableInputStream
instances, but is still present as `aAllowLazy` on the toplevel serialization
methods.

Differential Revision: https://phabricator.services.mozilla.com/D141048
2022-05-05 23:34:24 +00:00
Nika Layzell 000305abbf Bug 1754004 - Part 8: Remove SeekableStreamWrapper, r=asuth,necko-reviewers,kershaw
This type is no longer necessary, and has various issues due to behaving
incorrectly when used with async streams or streams which are not nsIPipe.

Differential Revision: https://phabricator.services.mozilla.com/D141045
2022-05-05 23:34:23 +00:00
Nika Layzell e18a717abc Bug 1754004 - Part 7: Consistently normalize upload streams passed to HTTP channels, r=asuth,necko-reviewers,dragana
Unfortunately, upload streams used by necko have various odd behaviours
and requirements which happened to be usually preserved by the previous
IPC serialization logic, but were not consistently preserved. This
includes requiring the stream to be synchronous (as some consumers such
as WebExtensions and DevTools appear to read it assuming Available() is
the stream length), seekable (as it needs to be rewound in various
places), and cloneable (as the stream information is often handed out to
other components).

In addition, the WebExtension WebRequest code makes assumptions about
the specific topology of the input stream for optimization purposes,
meaning that nsMultiplexInputStreams need to be preserved.

The way this was previously handled was by copying the entire payload
into a nsStorageStream as an async operation. This happened very
infrequently in out test suite, however, and had some issues. It could
lead to data loss if the stream was a nsMIMEInputStream (as the metadata
would be lost), and would destroy the topology required by WebRequest.

This patch changes the code to instead manually walk and replace streams
in the input stream's data structure, to efficiently copy only the
required data, preserve the invariants, and make the type seekable
before AsyncOpen continues. This helps keep the complexity of the
invariants HTTPChannel depends on out of generic input stream handling
code.

In addition, due to how early this happens, it replaces the need for
PartiallySeekableInputStream which will be removed a later part.

Differential Revision: https://phabricator.services.mozilla.com/D141044
2022-05-05 23:34:23 +00:00
Nika Layzell ce63bab88a Bug 1759572 - AsyncLengthWaitHelper should be threadsafe, r=asuth
This works only because the only implementation of nsIAsyncInputStreamLength
happened to only run on the current thread. Bug 1754004, changes this, and requires the reference to be threadsafe.

Differential Revision: https://phabricator.services.mozilla.com/D141037
2022-05-05 23:34:20 +00:00
Nika Layzell df13742edb Bug 1759563 - Add SerializedComplexity to limit the complexity of serialized IPCStream instances, r=asuth,necko-reviewers,dragana
This will improve the efficiency of serializing large data pipes, which in bad
cases can end up serializing very small amounts of data in individual pipes
over IPC, and acts as a compliment to the existing logic for limiting
serialized message sizes. It is also necessary for the changes in bug 1754004,
which require the ability to include FileDescriptor inline in the message,
which could blow out our FileDescriptor count limits if pipe creation was
unlimited.

In some tests, this change reduces the number of pipes required to serialize a
nsIInputStream from over 5000 to 1.

Differential Revision: https://phabricator.services.mozilla.com/D141036
2022-05-05 23:34:19 +00:00
Nika Layzell 7bbc6e365f Bug 1759569 - Retain nsIInputStreamLength through NS_CloneInputStream, r=asuth
This will help in bug 1754004 as in some cases we will want to clone a
DataPipe, which is non-cloneable, and without this change length information
would be lost.

In the future it might be worth making a more generic mechanism for efficiently
cloning wrapper input streams with a fallback rather than hard-coding this
interface.

Differential Revision: https://phabricator.services.mozilla.com/D141035
2022-05-05 23:34:19 +00:00
Nika Layzell 5bf606fa92 Bug 1754031 - AsyncWait implementations should support updating flags on an existing listener, r=asuth,necko-reviewers,dragana
This operation is often performed by nsAStreamCopier when switching
between the source and sink streams, in order to enable or disable the
WAIT_CLOSURE_ONLY flag. Failing to reset the wait flags can lead to a
NS_AsyncCopy hanging until the source or sink are closed when is
alternating between waiting on input and output streams. This patch
relaxes the incorrect checks on various input streams.

Differential Revision: https://phabricator.services.mozilla.com/D141034
2022-05-05 23:34:19 +00:00
Noemi Erli 295eab376a Backed out 14 changesets (bug 1746052) for causing build bustages in nsExternalHelperAppService.cpp CLOSED TREE
Backed out changeset bf46b0add531 (bug 1746052)
Backed out changeset 684b2aca10bb (bug 1746052)
Backed out changeset d4796eeeaf64 (bug 1746052)
Backed out changeset 5cf2378f6eb4 (bug 1746052)
Backed out changeset 2055ec1e9a57 (bug 1746052)
Backed out changeset 1398fc0669d2 (bug 1746052)
Backed out changeset 1f979899c843 (bug 1746052)
Backed out changeset 561a24801d4d (bug 1746052)
Backed out changeset 73e4689120f0 (bug 1746052)
Backed out changeset 9891f3b0229b (bug 1746052)
Backed out changeset 4c1ab30de0bd (bug 1746052)
Backed out changeset 108e14122e53 (bug 1746052)
Backed out changeset 1ee59c52578a (bug 1746052)
Backed out changeset 41fe77c5f4b2 (bug 1746052)
2022-05-05 23:13:33 +03:00
Neil Deakin c1e573cd3c Bug 1746052, don't allow Windows reserved filenames when sanitizing filenames. Move MangleTextToValidFileName to nsLocalFileWin and rename it to CheckForReservedFileName, r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D138737
2022-05-05 19:46:48 +00:00
Norisz Fay 72abc132d8 Backed out 4 changesets (bug 1754031, bug 1759563, bug 1759572, bug 1759569) because they are linked to the backed out bug 1754004 CLOSED TREE
Backed out changeset a15de342dab9 (bug 1759572)
Backed out changeset e731c9fa7444 (bug 1759563)
Backed out changeset d70810d7b63a (bug 1759569)
Backed out changeset 14a5f40fc11d (bug 1754031)
2022-05-05 13:58:04 +03:00
Sebastian Hengst 7ddbeea9d6 Backed out 17 changesets (bug 1696894, bug 1754004) for causing crashes e.g. bug 1767808, and hanging Gmail (bug 1767918). a=backout DONTBUILD
Backed out changeset 63f17a06eba9 (bug 1754004)
Backed out changeset 017e1552d549 (bug 1754004)
Backed out changeset 010dfd821cf3 (bug 1696894)
Backed out changeset 96a39c2ba7a3 (bug 1754004)
Backed out changeset a147df47a0e3 (bug 1754004)
Backed out changeset 9018dd592230 (bug 1754004)
Backed out changeset 234ff9e092c2 (bug 1754004)
Backed out changeset c4f1e86992b6 (bug 1754004)
Backed out changeset 51bd50b57dd5 (bug 1754004)
Backed out changeset d95e7ad0eafa (bug 1754004)
Backed out changeset 35a69828091c (bug 1754004)
Backed out changeset 6802a4326963 (bug 1754004)
Backed out changeset e40e810e18fc (bug 1754004)
Backed out changeset 82b38c12b298 (bug 1754004)
Backed out changeset 0a6cf0817bf5 (bug 1754004)
Backed out changeset 6d8e51b3e8d7 (bug 1754004)
Backed out changeset 2059c2d0d880 (bug 1754004)
2022-05-05 11:27:42 +02:00
Nika Layzell d5a1b01ff8 Bug 1754004 - Part 15: Don't track mOriginalInput in nsPipe, r=asuth
As discovered by TSan, this member could be raced on in some edge-cases if
cloned pipe streams raced on multiple threads to be destroyed. This change
instead moves the `nsIPipe` implementation to be on a seperate type from
`nsPipe`, allowing `mOriginalInput` to no longer need to be tracked.

This technically has slightly different behaviour than the previous
implementation for JS code, as code keeping the `nsIPipe` alive will now also
be keeping the output stream reference alive directly, rather than only holding
the `nsIPipe`, meaning that `pipe.outputStream` can be read multiple times
independently without implicitly closing the underlying stream. Based on a
quick read of the few remaining uses of `nsIPipe` in JS code, I don't think
this will be an issue, and it may actually be more intuitive and consistent.

Depends on D142127

Differential Revision: https://phabricator.services.mozilla.com/D145362
2022-05-03 23:30:38 +00:00
Nika Layzell 0b246fbf3f Bug 1754004 - Part 14: Fix potential skipping of async streams in nsMultiplexInputStream, r=asuth
Before this change, we could run into issues when an async stream
accepts new data and queues a runnable to notify the stream listener,
but before that stream listener's runnable is run, the target thread
reads data from the async stream, emptying it of any available data.
This would mean that the stream appears empty in
nsMultiplexInputStream::OnInputStreamReady, and the rest of the stream
is skipped.

This patch changes the logic in OnInputStreamReady to re-call AsyncWait
in those situations and avoid skipping over the empty stream, preventing
data loss.

This situation came up when running some HTTP tests under rr with the
socket process enabled, as the upload stream can both be read due to an
OnInputStreamReady callback and due to other calls in the HTTP
machinery, leading to this potential race. With the socket process
enabled, it is possible for the upload stream to be an async pipe, which
doesn't happen in the parent process due to stream normalization.

This change makes an assumption about the behaviour of streams
implementing `nsIAsyncInputStream` which I believe is correct right now,
and has been documented. I originally had other patches which modified
`Available()`'s definition to add an extra outparameter or added extra
methods, but this seemed much simpler and accurate based on my memory of
having read the Available() implementations for async streams in-tree.

A gtest was added for the failing situation using both nsPipe and DataPipe.

Differential Revision: https://phabricator.services.mozilla.com/D144451
2022-05-03 23:30:37 +00:00
Nika Layzell 57997381f5 Bug 1754004 - Part 11: Simplify the IPCStream serialization API, r=asuth,necko-reviewers,kershaw
As serializing IPCStream no longer requires a manager or FileDescriptor array,
the arguments are no longer necessary, and can be removed. The AutoIPCStream
helper can also be removed, as managed actors are no longer used for
serialization, so a delayed start callback is not necessary.

The delayed start parameter is also removed from nsIIPCSerializableInputStream
instances, but is still present as `aAllowLazy` on the toplevel serialization
methods.

Differential Revision: https://phabricator.services.mozilla.com/D141048
2022-05-03 23:30:36 +00:00
Nika Layzell 763329db47 Bug 1754004 - Part 8: Remove SeekableStreamWrapper, r=asuth,necko-reviewers,kershaw
This type is no longer necessary, and has various issues due to behaving
incorrectly when used with async streams or streams which are not nsIPipe.

Differential Revision: https://phabricator.services.mozilla.com/D141045
2022-05-03 23:30:35 +00:00
Nika Layzell 39eb862660 Bug 1754004 - Part 7: Consistently normalize upload streams passed to HTTP channels, r=asuth,necko-reviewers,dragana
Unfortunately, upload streams used by necko have various odd behaviours
and requirements which happened to be usually preserved by the previous
IPC serialization logic, but were not consistently preserved. This
includes requiring the stream to be synchronous (as some consumers such
as WebExtensions and DevTools appear to read it assuming Available() is
the stream length), seekable (as it needs to be rewound in various
places), and cloneable (as the stream information is often handed out to
other components).

In addition, the WebExtension WebRequest code makes assumptions about
the specific topology of the input stream for optimization purposes,
meaning that nsMultiplexInputStreams need to be preserved.

The way this was previously handled was by copying the entire payload
into a nsStorageStream as an async operation. This happened very
infrequently in out test suite, however, and had some issues. It could
lead to data loss if the stream was a nsMIMEInputStream (as the metadata
would be lost), and would destroy the topology required by WebRequest.

This patch changes the code to instead manually walk and replace streams
in the input stream's data structure, to efficiently copy only the
required data, preserve the invariants, and make the type seekable
before AsyncOpen continues. This helps keep the complexity of the
invariants HTTPChannel depends on out of generic input stream handling
code.

In addition, due to how early this happens, it replaces the need for
PartiallySeekableInputStream which will be removed a later part.

Differential Revision: https://phabricator.services.mozilla.com/D141044
2022-05-03 23:30:34 +00:00
Nika Layzell 62904d15cd Bug 1759572 - AsyncLengthWaitHelper should be threadsafe, r=asuth
This works only because the only implementation of nsIAsyncInputStreamLength
happened to only run on the current thread. Bug 1754004, changes this, and requires the reference to be threadsafe.

Differential Revision: https://phabricator.services.mozilla.com/D141037
2022-05-03 23:30:32 +00:00
Nika Layzell 9b0c0be96e Bug 1759563 - Add SerializedComplexity to limit the complexity of serialized IPCStream instances, r=asuth,necko-reviewers,dragana
This will improve the efficiency of serializing large data pipes, which in bad
cases can end up serializing very small amounts of data in individual pipes
over IPC, and acts as a compliment to the existing logic for limiting
serialized message sizes. It is also necessary for the changes in bug 1754004,
which require the ability to include FileDescriptor inline in the message,
which could blow out our FileDescriptor count limits if pipe creation was
unlimited.

In some tests, this change reduces the number of pipes required to serialize a
nsIInputStream from over 5000 to 1.

Differential Revision: https://phabricator.services.mozilla.com/D141036
2022-05-03 23:30:31 +00:00
Nika Layzell f58648e57e Bug 1759569 - Retain nsIInputStreamLength through NS_CloneInputStream, r=asuth
This will help in bug 1754004 as in some cases we will want to clone a
DataPipe, which is non-cloneable, and without this change length information
would be lost.

In the future it might be worth making a more generic mechanism for efficiently
cloning wrapper input streams with a fallback rather than hard-coding this
interface.

Differential Revision: https://phabricator.services.mozilla.com/D141035
2022-05-03 23:30:31 +00:00
Nika Layzell 7bb4f24325 Bug 1754031 - AsyncWait implementations should support updating flags on an existing listener, r=asuth,necko-reviewers,dragana
This operation is often performed by nsAStreamCopier when switching
between the source and sink streams, in order to enable or disable the
WAIT_CLOSURE_ONLY flag. Failing to reset the wait flags can lead to a
NS_AsyncCopy hanging until the source or sink are closed when is
alternating between waiting on input and output streams. This patch
relaxes the incorrect checks on various input streams.

Differential Revision: https://phabricator.services.mozilla.com/D141034
2022-05-03 23:30:30 +00:00
Csoregi Natalia 7896e7e124 Backed out 13 changesets (bug 1746052) for causing failures on uriloader/exthandler/tests/. CLOSED TREE
Backed out changeset d19cc58e3cab (bug 1746052)
Backed out changeset 229edc158a2b (bug 1746052)
Backed out changeset b0ef7c68abcf (bug 1746052)
Backed out changeset 30de4b77f242 (bug 1746052)
Backed out changeset ebc6720fdab3 (bug 1746052)
Backed out changeset daccb796a093 (bug 1746052)
Backed out changeset 5b76d8d76b2b (bug 1746052)
Backed out changeset a698068d078f (bug 1746052)
Backed out changeset 73d17535d8d1 (bug 1746052)
Backed out changeset 94c95f004221 (bug 1746052)
Backed out changeset 1a389759585a (bug 1746052)
Backed out changeset c91230a8ea90 (bug 1746052)
Backed out changeset 7665f02c114e (bug 1746052)
2022-05-04 01:15:12 +03:00
Mike Hommey a3e1d0e570 Bug 1766371 - Fix class-varargs warnings in Windows builds. r=nika,mjf
dom/bindings/BindingUtils.cpp(202,62): error: passing object of class type 'typename raw_type<char16_t, int>::type' (aka 'char16ptr_t') through variadic function [-Werror,-Wclass-varargs]
                         static_cast<unsigned>(errorNumber), funcNameStr.get(),
                                                             ^
dom/bindings/BindingUtils.cpp(203,26): error: passing object of class type 'typename raw_type<char16_t, int>::type' (aka 'char16ptr_t') through variadic function [-Werror,-Wclass-varargs]
                         ifaceName.get());
                         ^
dom/media/webrtc/transport/third_party/nICEr/src/ice/ice_component.c(582,15): error: passing object of class type 'nr_transport_addr' (aka 'struct nr_transport_addr_') through variadic function [-Werror,-Wclass-varargs]
              component->stream->turn_servers[j].turn_server.addr);
              ^
toolkit/xre/dllservices/tests/gtest/TestUntrustedModules.cpp(44,45): error: passing object of class type 'typename raw_type<char16_t, int>::type' (aka 'char16ptr_t') through variadic function [-Werror,-Wclass-varargs]
        wprintf(L"%s is not registered.\n", aNames[i].get());
                                            ^
toolkit/xre/dllservices/tests/gtest/TestUntrustedModules.cpp(49,30): error: passing object of class type 'typename raw_type<char16_t, int>::type' (aka 'char16ptr_t') through variadic function [-Werror,-Wclass-varargs]
        wprintf(L"%s:%4d\n", aNames[i].get(), *entry);
                             ^
toolkit/xre/dllservices/tests/gtest/TestUntrustedModules.cpp(248,30): error: passing object of class type 'typename raw_type<char16_t, int>::type' (aka 'char16ptr_t') through variadic function [-Werror,-Wclass-varargs]
      wprintf(L"JSON: %s\n", json.get());
                             ^
xpcom/io/nsLocalFileWin.cpp(1647,20): error: passing object of class type 'typename raw_type<char16_t, int>::type' (aka 'char16ptr_t') through variadic function [-Werror,-Wclass-varargs]
                   NS_ConvertASCIItoUTF16(nsDependentCString(aField)).get());
                   ^

Differential Revision: https://phabricator.services.mozilla.com/D144665
2022-05-03 21:48:22 +00:00
Neil Deakin c203e5ec80 Bug 1746052, don't allow Windows reserved filenames when sanitizing filenames. Move MangleTextToValidFileName to nsLocalFileWin and rename it to CheckForReservedFileName, r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D138737
2022-05-03 19:44:27 +00:00
Butkovits Atila d0dadcb6f5 Backed out 19 changesets (bug 1759569, bug 1754004, bug 1759563, bug 1754031, bug 1696894, bug 1759572) for causing wpt failures. CLOSED TREE
Backed out changeset 110a8dce4b5d (bug 1696894)
Backed out changeset a62dab05c6cd (bug 1754004)
Backed out changeset 7cf122f6e19f (bug 1754004)
Backed out changeset 2aa9a0a9adbc (bug 1754004)
Backed out changeset cde16b2cdbfb (bug 1754004)
Backed out changeset 452fe0a15c99 (bug 1754004)
Backed out changeset eace8d4756ef (bug 1754004)
Backed out changeset 5e1fad91e935 (bug 1754004)
Backed out changeset eb6de0b1ab8e (bug 1754004)
Backed out changeset 1ac1908ed3d0 (bug 1754004)
Backed out changeset 473cad5b22ab (bug 1754004)
Backed out changeset 1923922be138 (bug 1754004)
Backed out changeset c7966d91f89e (bug 1754004)
Backed out changeset df5ce1f6712c (bug 1754004)
Backed out changeset a3f3f9761ada (bug 1754004)
Backed out changeset c8ec86e0a33b (bug 1759572)
Backed out changeset 6c102f8e3d4a (bug 1759563)
Backed out changeset bd3a2fcf4f0c (bug 1759569)
Backed out changeset 2541d8face65 (bug 1754031)
2022-05-03 06:00:22 +03:00
Nika Layzell 6e1599b502 Bug 1754004 - Part 14: Fix potential skipping of async streams in nsMultiplexInputStream, r=asuth
Before this change, we could run into issues when an async stream
accepts new data and queues a runnable to notify the stream listener,
but before that stream listener's runnable is run, the target thread
reads data from the async stream, emptying it of any available data.
This would mean that the stream appears empty in
nsMultiplexInputStream::OnInputStreamReady, and the rest of the stream
is skipped.

This patch changes the logic in OnInputStreamReady to re-call AsyncWait
in those situations and avoid skipping over the empty stream, preventing
data loss.

This situation came up when running some HTTP tests under rr with the
socket process enabled, as the upload stream can both be read due to an
OnInputStreamReady callback and due to other calls in the HTTP
machinery, leading to this potential race. With the socket process
enabled, it is possible for the upload stream to be an async pipe, which
doesn't happen in the parent process due to stream normalization.

This change makes an assumption about the behaviour of streams
implementing `nsIAsyncInputStream` which I believe is correct right now,
and has been documented. I originally had other patches which modified
`Available()`'s definition to add an extra outparameter or added extra
methods, but this seemed much simpler and accurate based on my memory of
having read the Available() implementations for async streams in-tree.

A gtest was added for the failing situation using both nsPipe and DataPipe.

Differential Revision: https://phabricator.services.mozilla.com/D144451
2022-05-02 20:44:27 +00:00
Nika Layzell d88dc7e3db Bug 1754004 - Part 11: Simplify the IPCStream serialization API, r=asuth,necko-reviewers,kershaw
As serializing IPCStream no longer requires a manager or FileDescriptor array,
the arguments are no longer necessary, and can be removed. The AutoIPCStream
helper can also be removed, as managed actors are no longer used for
serialization, so a delayed start callback is not necessary.

The delayed start parameter is also removed from nsIIPCSerializableInputStream
instances, but is still present as `aAllowLazy` on the toplevel serialization
methods.

Differential Revision: https://phabricator.services.mozilla.com/D141048
2022-05-02 20:44:26 +00:00
Nika Layzell 729882a135 Bug 1754004 - Part 8: Remove SeekableStreamWrapper, r=asuth,necko-reviewers,kershaw
This type is no longer necessary, and has various issues due to behaving
incorrectly when used with async streams or streams which are not nsIPipe.

Differential Revision: https://phabricator.services.mozilla.com/D141045
2022-05-02 20:44:25 +00:00
Nika Layzell 027697a12c Bug 1754004 - Part 7: Consistently normalize upload streams passed to HTTP channels, r=asuth,necko-reviewers,dragana
Unfortunately, upload streams used by necko have various odd behaviours
and requirements which happened to be usually preserved by the previous
IPC serialization logic, but were not consistently preserved. This
includes requiring the stream to be synchronous (as some consumers such
as WebExtensions and DevTools appear to read it assuming Available() is
the stream length), seekable (as it needs to be rewound in various
places), and cloneable (as the stream information is often handed out to
other components).

In addition, the WebExtension WebRequest code makes assumptions about
the specific topology of the input stream for optimization purposes,
meaning that nsMultiplexInputStreams need to be preserved.

The way this was previously handled was by copying the entire payload
into a nsStorageStream as an async operation. This happened very
infrequently in out test suite, however, and had some issues. It could
lead to data loss if the stream was a nsMIMEInputStream (as the metadata
would be lost), and would destroy the topology required by WebRequest.

This patch changes the code to instead manually walk and replace streams
in the input stream's data structure, to efficiently copy only the
required data, preserve the invariants, and make the type seekable
before AsyncOpen continues. This helps keep the complexity of the
invariants HTTPChannel depends on out of generic input stream handling
code.

In addition, due to how early this happens, it replaces the need for
PartiallySeekableInputStream which will be removed a later part.

Differential Revision: https://phabricator.services.mozilla.com/D141044
2022-05-02 20:44:24 +00:00
Nika Layzell fd60df03b9 Bug 1759572 - AsyncLengthWaitHelper should be threadsafe, r=asuth
This works only because the only implementation of nsIAsyncInputStreamLength
happened to only run on the current thread. Bug 1754004, changes this, and requires the reference to be threadsafe.

Differential Revision: https://phabricator.services.mozilla.com/D141037
2022-05-02 20:44:21 +00:00
Nika Layzell c5140538b7 Bug 1759563 - Add SerializedComplexity to limit the complexity of serialized IPCStream instances, r=asuth,necko-reviewers,dragana
This will improve the efficiency of serializing large data pipes, which in bad
cases can end up serializing very small amounts of data in individual pipes
over IPC, and acts as a compliment to the existing logic for limiting
serialized message sizes. It is also necessary for the changes in bug 1754004,
which require the ability to include FileDescriptor inline in the message,
which could blow out our FileDescriptor count limits if pipe creation was
unlimited.

In some tests, this change reduces the number of pipes required to serialize a
nsIInputStream from over 5000 to 1.

Differential Revision: https://phabricator.services.mozilla.com/D141036
2022-05-02 20:44:21 +00:00
Nika Layzell d8386e965a Bug 1759569 - Retain nsIInputStreamLength through NS_CloneInputStream, r=asuth
This will help in bug 1754004 as in some cases we will want to clone a
DataPipe, which is non-cloneable, and without this change length information
would be lost.

In the future it might be worth making a more generic mechanism for efficiently
cloning wrapper input streams with a fallback rather than hard-coding this
interface.

Differential Revision: https://phabricator.services.mozilla.com/D141035
2022-05-02 20:44:21 +00:00
Nika Layzell 151a89349e Bug 1754031 - AsyncWait implementations should support updating flags on an existing listener, r=asuth,necko-reviewers,dragana
This operation is often performed by nsAStreamCopier when switching
between the source and sink streams, in order to enable or disable the
WAIT_CLOSURE_ONLY flag. Failing to reset the wait flags can lead to a
NS_AsyncCopy hanging until the source or sink are closed when is
alternating between waiting on input and output streams. This patch
relaxes the incorrect checks on various input streams.

Differential Revision: https://phabricator.services.mozilla.com/D141034
2022-05-02 20:44:20 +00:00
Mike Hommey 00732bfa12 Bug 1766375 - Fix implicit-fallthrough warnings in Windows builds. r=media-playback-reviewers,necko-reviewers,rkraesig,xpcom-reviewers,nika,bryce,kershaw
dom/media/platforms/wmf/WMFEncoderModule.cpp(31,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case MediaDataEncoder::CodecType::VP9:
    ^
dom/media/platforms/wmf/WMFEncoderModule.cpp(31,5): note: insert '[[fallthrough]];' to silence this warning
    case MediaDataEncoder::CodecType::VP9:
    ^
    [[fallthrough]];
netwerk/test/gtest/TestNamedPipeService.cpp(212,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    default:  // error
    ^
netwerk/test/gtest/TestNamedPipeService.cpp(212,5): note: insert '[[fallthrough]];' to silence this warning
    default:  // error
    ^
    [[fallthrough]];
widget/windows/KeyboardLayout.cpp(1973,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    default:
    ^
widget/windows/KeyboardLayout.cpp(1973,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    default:
    ^
    U_FALLTHROUGH;
widget/windows/WinMouseScrollHandler.cpp(633,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case SB_PAGEDOWN:
    ^
widget/windows/WinMouseScrollHandler.cpp(633,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case SB_PAGEDOWN:
    ^
    U_FALLTHROUGH;
widget/windows/WinMouseScrollHandler.cpp(640,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case SB_LINEDOWN:
    ^
widget/windows/WinMouseScrollHandler.cpp(640,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case SB_LINEDOWN:
    ^
    U_FALLTHROUGH;
widget/windows/nsLookAndFeel.cpp(188,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case ColorID::MozMenuhovertext:
    ^
widget/windows/nsLookAndFeel.cpp(188,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case ColorID::MozMenuhovertext:
    ^
    U_FALLTHROUGH;
widget/windows/nsLookAndFeel.cpp(194,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case ColorID::Highlighttext:
    ^
widget/windows/nsLookAndFeel.cpp(194,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case ColorID::Highlighttext:
    ^
    U_FALLTHROUGH;
widget/windows/nsLookAndFeel.cpp(469,15): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
              case ABE_BOTTOM:
              ^
widget/windows/nsLookAndFeel.cpp(469,15): note: insert 'U_FALLTHROUGH;' to silence this warning
              case ABE_BOTTOM:
              ^
              U_FALLTHROUGH;
widget/windows/nsNativeThemeWin.cpp(2540,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case StyleAppearance::Button:
    ^
widget/windows/nsNativeThemeWin.cpp(2540,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case StyleAppearance::Button:
    ^
    U_FALLTHROUGH;
widget/windows/nsNativeThemeWin.cpp(3278,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case StyleAppearance::Checkbox:
    ^
widget/windows/nsNativeThemeWin.cpp(3278,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case StyleAppearance::Checkbox:
    ^
    U_FALLTHROUGH;
widget/windows/nsNativeThemeWin.cpp(3332,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case StyleAppearance::Tabpanel:
    ^
widget/windows/nsNativeThemeWin.cpp(3332,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case StyleAppearance::Tabpanel:
    ^
    U_FALLTHROUGH;
widget/windows/nsNativeThemeWin.cpp(3461,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case StyleAppearance::Menuarrow: {
    ^
widget/windows/nsNativeThemeWin.cpp(3461,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case StyleAppearance::Menuarrow: {
    ^
    U_FALLTHROUGH;
widget/windows/nsWindow.cpp(1339,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case eWindowType_toplevel:
    ^
widget/windows/nsWindow.cpp(1339,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case eWindowType_toplevel:
    ^
    U_FALLTHROUGH;
widget/windows/nsWindow.cpp(1422,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case eWindowType_toplevel:
    ^
widget/windows/nsWindow.cpp(1422,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case eWindowType_toplevel:
    ^
    U_FALLTHROUGH;
widget/windows/nsWindow.cpp(3379,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case eTransparencyGlass:
    ^
widget/windows/nsWindow.cpp(3379,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case eTransparencyGlass:
    ^
    U_FALLTHROUGH;
widget/windows/nsWindow.cpp(5595,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case WM_MOUSELEAVE: {
    ^
widget/windows/nsWindow.cpp(5595,5): note: insert 'U_FALLTHROUGH;' to silence this warning
    case WM_MOUSELEAVE: {
    ^
    U_FALLTHROUGH;
xpcom/io/SpecialSystemDirectory.cpp(572,5): error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
    case Win_Programs: {
    ^
xpcom/io/SpecialSystemDirectory.cpp(572,5): note: insert '[[fallthrough]];' to silence this warning
    case Win_Programs: {
    ^
    [[fallthrough]];

Differential Revision: https://phabricator.services.mozilla.com/D144668
2022-04-27 22:12:53 +00:00
Emilio Cobos Álvarez 5e3a231f28 Bug 1762708 - Use async dbus for revealing files in nsGIOService. r=stransky
This at least doesn't block the UI, even though the file could take a while to
show up.

Depends on D143606

Differential Revision: https://phabricator.services.mozilla.com/D143607
2022-04-15 23:28:08 +00:00
Nika Layzell 3a5d9a53ba Bug 1435766 - Reimplement nsDirectoryService Mac getters in terms of GetSpecialSystemDirectory, r=xpcom-reviewers,mccr8
This makes the getters more consistent with getters on other platforms,
and theoretically provides a faster way of getting these directories
from C++ code in the future.

Differential Revision: https://phabricator.services.mozilla.com/D142871
2022-04-06 20:43:07 +00:00
Stephen A Pohl 9fe39b5f5d Bug 1761481: Improve the conversion of line breaks. r=mstange
Differential Revision: https://phabricator.services.mozilla.com/D142104
2022-04-06 17:45:45 +00:00
Jan Rio Krause 057785b6d5 Bug 1519200 - Remove `NS_ERROR_FILE_TARGET_DOES_NOT_EXIST` in favor of `NS_ERROR_FILE_NOT_FOUND`. r=xpcom-reviewers,nika,dom-storage-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D77575
2022-04-05 15:17:03 +00:00
Nathan Froyd 45d38d17c1 Bug 1478146 - Use SetFilePointerEx in nsLocalFileWin.cpp r=nika
Differential Revision: https://phabricator.services.mozilla.com/D142883
2022-04-04 20:39:04 +00:00
Masatoshi Kimura 030cb502bf Bug 1761438 - Remove nsILocalFileWin::GetNativeCanonicalPath. r=xpcom-reviewers,application-update-reviewers,mccr8,nalexander
I removed the last caller.

Depends on D142051

Differential Revision: https://phabricator.services.mozilla.com/D142052
2022-03-26 00:52:07 +00:00
Nika Layzell 789c8553d9 Bug 1761548 - Add basic locking to nsStorageStream, r=xpcom-reviewers,mccr8
This should make it slightly safer to to try to read from a
nsStorageInputStream while the stream is being concurrently written to
on another thread, though it will still not behave very well as there is
no nsIAsyncInputStream support.

Individual input streams are still non-threadsafe with this change.

Differential Revision: https://phabricator.services.mozilla.com/D142135
2022-03-25 22:29:02 +00:00
Randell Jesup 2c0c956707 Bug 1207753 - Various xpcom thread-safety annotations r=nika
Differential Revision: https://phabricator.services.mozilla.com/D130579
2022-03-23 22:22:51 +00:00
Nicholas Rishel 79aad2eea4 Bug 1722777 - Pre: files contained within a folder implicitly must have a longer path; make this explicit for clarity. r=nalexander
Depends on D140910

Differential Revision: https://phabricator.services.mozilla.com/D140911
2022-03-22 00:28:23 +00:00
Nicholas Rishel 38f65972b7 Bug 1722777 - Pre: Reuse existing directory iteration function when deleting folder content on Windows. r=nalexander
Depends on D140428

Differential Revision: https://phabricator.services.mozilla.com/D140910
2022-03-22 00:28:22 +00:00
Nicholas Rishel 9e17c0d135 Bug 1722777 - Pre: Add comment explaining why Windows recursive folder deletion uses neither `SHFileOperation` nor `IFileOperation` APIs. r=nalexander
Depends on D140427

Differential Revision: https://phabricator.services.mozilla.com/D140428
2022-03-22 00:28:22 +00:00
Randell Jesup c5917ed65a Bug 1207753: Basic thread-safety annotations to quiet errors until real annotations land r=nika
Differential Revision: https://phabricator.services.mozilla.com/D141062
2022-03-17 18:39:15 +00:00
Randell Jesup fcaf70841e Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 18:47:08 +00:00
Noemi Erli 2390d257e6 Backed out changeset 12a59e5a50bf (bug 1207753) for causing build bustage CLOSED TREE 2022-03-16 18:32:51 +02:00
Randell Jesup 4b033a5256 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 16:16:14 +00:00
Butkovits Atila 927ad62c6a Backed out changeset a68ee4b09f92 (bug 1207753) for causing Hazard bustages. CLOSED TREE 2022-03-16 14:38:14 +02:00
Randell Jesup 7d4b5fae04 Bug 1207753 - Add MOZ_UNANNOTATED to all Mutexes/Monitors r=nika,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D140849
2022-03-16 12:01:14 +00:00
Jan Rio Krause 10f92fad6c Bug 1757754 - Fix MinGW build failure by defining `ERROR_CONTENT_BLOCKED`. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D140212
2022-03-04 05:52:19 +00:00
Jan Rio Krause f1571e65c4 Bug 1690326 - Map Windows error `0x510 ERROR_CONTENT_BLOCKED` to `NS_ERROR_FILE_ACCESS_DENIED`. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D139968
2022-03-02 14:10:19 +00:00
Masatoshi Kimura 97d32e6c03 Bug 1751840 - Make nsLocalFileWin::Equals compare long names before trying 8.3 names. r=bobowen
Differential Revision: https://phabricator.services.mozilla.com/D137339
2022-02-19 12:37:10 +00:00
Emilio Cobos Álvarez 00f5ea846d Bug 1755896 - Add support from AString to ACString Base64 decoding. r=hsivonen
Differential Revision: https://phabricator.services.mozilla.com/D139029
2022-02-18 10:42:10 +00:00
Nika Layzell de1e97c891 Bug 1754040 - Clean up common shared WriteSegments helper functions, r=necko-reviewers,xpcom-reviewers,mccr8
These helper methods are similar to the related ones for
nsIInputStream::ReadSegments, and can be used to implement
nsIOutputStream::Write and nsIOutputStream::WriteFrom in terms of
WriteSegments.

There were various places which used manual copies of these methods, which are
being unified.

Differential Revision: https://phabricator.services.mozilla.com/D138334
2022-02-14 23:59:35 +00:00
Jan Rio Krause 4905393a20 Bug 1690326 - Map Windows error `ERROR_DISK_CORRUPT` to `NS_ERROR_FILE_FS_CORRUPTED`. r=xpcom-reviewers,dom-storage-reviewers,jstutte,nika
Differential Revision: https://phabricator.services.mozilla.com/D138162
2022-02-09 15:27:33 +00:00
Masatoshi Kimura 4d3b2121cb Bug 1752683 - Make nsILocalFileWin.canonicalPath [noscript]. r=xpcom-reviewers,mccr8
No JS callers use this attribute anymore.

Differential Revision: https://phabricator.services.mozilla.com/D137380
2022-01-31 19:43:37 +00:00
Paul Zuehlcke 47129a9cd9 Bug 1746645 - Generate EscapeChars array programmatically. r=xpcom-reviewers,nika
Differential Revision: https://phabricator.services.mozilla.com/D136222
2022-01-19 10:21:05 +00:00
Nika Layzell 4f556b1bea Bug 1748719 - Make nsStringInputStream more flexible as to the backing data buffer, r=mccr8
This change aims to make the way that the nsStringInputStream owns the backing
data buffer more flexible. This has a few impacts, including allowing
arbitrarily large payload sizes on 64-bit platforms, not requiring as complex
checks around borrowed string buffers or nsTArray data storage, and supporting
custom data ownership schemes such as those used by blobs.

The new system uses a separate refcounted object internally to provide the
contiguous backing buffer, with the nsStringInputStream wrapping it and
providing the `nsIInputStream` interface and cursor. This also avoids issues
around the buffer being mutated during reads, as mutating the `nsIInputStream`
no longer mutates the actual data storage object.

Differential Revision: https://phabricator.services.mozilla.com/D135162
2022-01-07 20:34:52 +00:00
Randell Jesup 7a46e96bdf Bug 1746488: xpcom/io cleanup r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D134062
2022-01-04 14:21:56 +00:00
Barret Rennie 772d29da89 Bug 1736331 - Add nsILocalFileMac methods for interacting with extended attributes r=nika
This patch adds support for setting, getting, and reading extended filesystem
attributes on macOS.

Differential Revision: https://phabricator.services.mozilla.com/D133836
2021-12-25 00:30:10 +00:00
Butkovits Atila 1ce2eea394 Backed out 2 changesets (bug 1736331) for causing failures at test_ioutils_mac_xattr.html. CLOSED TREE
Backed out changeset 3d627a038faa (bug 1736331)
Backed out changeset b0df890ed09e (bug 1736331)
2021-12-24 03:26:45 +02:00
Barret Rennie f93fd9cc79 Bug 1736331 - Add nsILocalFileMac methods for interacting with extended attributes r=nika
This patch adds support for setting, getting, and reading extended filesystem
attributes on macOS.

Differential Revision: https://phabricator.services.mozilla.com/D133836
2021-12-23 23:02:13 +00:00
Toshihito Kikuchi 7d38851282 Bug 1746114 - Part1. Avoid delayloading shlwapi.dll in a sandboxed process. r=mhowell
While processing third-party module loading events, the process may delayload
shlwapi.dll.  This could be a problem if the process is sandboxed and the access
to local files is restricted.  Before enabling the third-party modules ping in
socket process, this patch avoids such delayloading.

The first path is `ParamTraits<mozilla::ModuleRecord>::Read` calls `NS_NewLocalFile`
that calls `PathGetDriveNumberW`.  This API is simple enough that we define our own
version.

The second path is the ctor of `ProcessedModuleLoadEvent` that is called from
`UntrustedModulesProcessor::CompleteProcessing` calls `PreparePathForTelemetry`
that calls `PathFindFileNameW` and `PathCanonicalizeW`.  For this path, instead
of sanitizing a requested name in `ProcessedModuleLoadEvent`'s ctor, we sanitize
it when transferring it to the main process.

Differential Revision: https://phabricator.services.mozilla.com/D134492
2021-12-23 02:15:35 +00:00
Sandor Molnar 8032ae5c31 Backed out 2 changesets (bug 1736331) for causing build bustages in IOUtils. CLOSED TREE
Backed out changeset 5745c2669e88 (bug 1736331)
Backed out changeset 0a34c502e65f (bug 1736331)
2021-12-22 22:04:10 +02:00
Barret Rennie de949e8aca Bug 1736331 - Add nsILocalFileMac methods for interacting with extended attributes r=nika
This patch adds support for setting, getting, and reading extended filesystem
attributes on macOS.

Differential Revision: https://phabricator.services.mozilla.com/D133836
2021-12-22 19:46:15 +00:00
Csoregi Natalia cbfb9e9a8e Backed out 2 changesets (bug 1736331) for bustage on IOUtils.webidl CLOSED TREE
Backed out changeset 293085bdd5a1 (bug 1736331)
Backed out changeset 275621f46891 (bug 1736331)
2021-12-22 19:09:54 +02:00
Barret Rennie 83aee913ba Bug 1736331 - Add nsILocalFileMac methods for interacting with extended attributes r=nika
This patch adds support for setting, getting, and reading extended filesystem
attributes on macOS.

Differential Revision: https://phabricator.services.mozilla.com/D133836
2021-12-22 16:40:52 +00:00
Cristian Tuns ca67207453 Backed out changeset e38313bed466 (bug 1746488) for causing mochitest failures on Mutex_posix.cpp CLOSED TREE 2021-12-21 05:11:33 -05:00