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

3061 Коммитов

Автор SHA1 Сообщение Дата
Keefer Rourke 627bc1205f Bug 1654295: Reduce boilerplate needed to run background I/O in IOUtils r=barret
Introduces a new RunOnBackgroundThread template method which abstracts away
most of the boilerplate needed to run sync I/O tasks with result reported by a
JS Promise on a background thread.

Differential Revision: https://phabricator.services.mozilla.com/D85296
2020-07-30 14:03:03 +00:00
Keefer Rourke 50a79e72d0 Bug 1654295: Reduce boilerplate in IOUtils failure paths r=barret
This change completely overhauls the way errors are handled in `IOUtils`. With
the introduction of the new `IOError` type, a useful error message is paired
with an `nsresult` at the error site. This provides erroneous callers with more
information about what went wrong, while improving consistency with mapping
errors to `DOMExceptions`.

For error sites where it is not immediately clear what went wrong, messages can
be omitted. A default error message will be filled in corresponding with the
wrapped `nsresult` when the operation is rejected to the calling JavaScript.

Differential Revision: https://phabricator.services.mozilla.com/D84736
2020-07-30 14:02:50 +00:00
Keefer Rourke 970f76ccd9 Bug 1654295: Reduce boilerplate in IOUtils success paths r=barret
This change introduces some new methods to reduce repeated boilerplate around
promise usage in success paths of `IOUtils` method implementations.

Differential Revision: https://phabricator.services.mozilla.com/D84735
2020-07-30 14:02:43 +00:00
Keefer Rourke 4984245a2f Bug 1654295: Use Result as a return type where possible in IOUtils.cpp r=barret,Gijs
This changes most private methods of `IOUtils` to use the `Result` monad as a
return type instead of a bare `nsresult`. This improves consistency of all of
the public method implementations, and will allow for the shared patterns to be
abstracted in a follow-up patch.

Differential Revision: https://phabricator.services.mozilla.com/D84734
2020-07-30 14:02:38 +00:00
Keefer Rourke fff3cc72e5 Bug 1654295: Refactor IOUtils::writeAtomic to improve error handling r=barret
This patch introduces a new private `IOUtils::WriteAtomicSync` method, which
fully encapsulates the behaviour of `IOUtils::writeAtomic`. The private
`IOUtils::WriteSync` method has also been updated to use the `Result` monad as
a return type, which is favourable over a bare `nsresult`.

These changes together simplify the implementation of the public method, and
lay some of the ground work to further improve error handling in `IOUtils`.

Differential Revision: https://phabricator.services.mozilla.com/D84733
2020-07-30 14:02:36 +00:00
Keefer Rourke 3796a46c3b Bug 1654295: Refactor IOUtils::read to improve error handling r=barret,Gijs
This patch fully encapsulates the behaviour of the IOUtils::read method behind
the private `IOUtils::ReadSync` method. Error handling for these methods has
been updated to use the `Result` monad, which is favourable over a bare
`nsresult`.

This lays some of the ground work to further improve error handling in
`IOUtils`.

Differential Revision: https://phabricator.services.mozilla.com/D84732
2020-07-30 14:02:34 +00:00
Keefer Rourke 79d59f9c56 Bug 1654295: Reject early when relative paths are used in IOUtils methods r=barret,Gijs
This patch introduces a new `REJECT_IF_RELATIVE_PATH` macro for use in
`IOUtils`. Its usage ensures that every method rejects in the same way when
unsupported relative paths are passed as parameters to `IOUtils` public
methods.

Differential Revision: https://phabricator.services.mozilla.com/D84731
2020-07-30 14:02:32 +00:00
Brindusan Cristian ead144d750 Backed out 7 changesets (bug 1654295) for mochitest failures at test_ioutils.html. CLOSED TREE
Backed out changeset 5759d0505c0e (bug 1654295)
Backed out changeset 08bc2a5eefd0 (bug 1654295)
Backed out changeset eef5969a2e21 (bug 1654295)
Backed out changeset 6bac11641ad3 (bug 1654295)
Backed out changeset c94e94a51e94 (bug 1654295)
Backed out changeset 8dd9ad718cf9 (bug 1654295)
Backed out changeset 44191218e308 (bug 1654295)
2020-07-30 16:11:00 +03:00
Keefer Rourke 5464b46a66 Bug 1654295: Reduce boilerplate needed to run background I/O in IOUtils r=barret
Introduces a new RunOnBackgroundThread template method which abstracts away
most of the boilerplate needed to run sync I/O tasks with result reported by a
JS Promise on a background thread.

Differential Revision: https://phabricator.services.mozilla.com/D85296
2020-07-29 22:35:45 +00:00
Keefer Rourke 35921c76ee Bug 1654295: Reduce boilerplate in IOUtils failure paths r=barret
This change completely overhauls the way errors are handled in `IOUtils`. With
the introduction of the new `IOError` type, a useful error message is paired
with an `nsresult` at the error site. This provides erroneous callers with more
information about what went wrong, while improving consistency with mapping
errors to `DOMExceptions`.

For error sites where it is not immediately clear what went wrong, messages can
be omitted. A default error message will be filled in corresponding with the
wrapped `nsresult` when the operation is rejected to the calling JavaScript.

Differential Revision: https://phabricator.services.mozilla.com/D84736
2020-07-29 21:52:32 +00:00
Keefer Rourke 7ac9784ef4 Bug 1654295: Reduce boilerplate in IOUtils success paths r=barret
This change introduces some new methods to reduce repeated boilerplate around
promise usage in success paths of `IOUtils` method implementations.

Differential Revision: https://phabricator.services.mozilla.com/D84735
2020-07-29 21:52:14 +00:00
Keefer Rourke f73fc9bd00 Bug 1654295: Use Result as a return type where possible in IOUtils.cpp r=barret,Gijs
This changes most private methods of `IOUtils` to use the `Result` monad as a
return type instead of a bare `nsresult`. This improves consistency of all of
the public method implementations, and will allow for the shared patterns to be
abstracted in a follow-up patch.

Differential Revision: https://phabricator.services.mozilla.com/D84734
2020-07-29 21:52:01 +00:00
Keefer Rourke 423a0f1c77 Bug 1654295: Refactor IOUtils::writeAtomic to improve error handling r=barret
This patch introduces a new private `IOUtils::WriteAtomicSync` method, which
fully encapsulates the behaviour of `IOUtils::writeAtomic`. The private
`IOUtils::WriteSync` method has also been updated to use the `Result` monad as
a return type, which is favourable over a bare `nsresult`.

These changes together simplify the implementation of the public method, and
lay some of the ground work to further improve error handling in `IOUtils`.

Differential Revision: https://phabricator.services.mozilla.com/D84733
2020-07-29 21:51:48 +00:00
Keefer Rourke 633f1c26a4 Bug 1654295: Refactor IOUtils::read to improve error handling r=barret,Gijs
This patch fully encapsulates the behaviour of the IOUtils::read method behind
the private `IOUtils::ReadSync` method. Error handling for these methods has
been updated to use the `Result` monad, which is favourable over a bare
`nsresult`.

This lays some of the ground work to further improve error handling in
`IOUtils`.

Differential Revision: https://phabricator.services.mozilla.com/D84732
2020-07-29 21:51:41 +00:00
Keefer Rourke 606fc50d06 Bug 1654295: Reject early when relative paths are used in IOUtils methods r=barret,Gijs
This patch introduces a new `REJECT_IF_RELATIVE_PATH` macro for use in
`IOUtils`. Its usage ensures that every method rejects in the same way when
unsupported relative paths are passed as parameters to `IOUtils` public
methods.

Differential Revision: https://phabricator.services.mozilla.com/D84731
2020-07-29 21:51:33 +00:00
Keefer Rourke b5254a1e31 Bug 1653985: Implement IOUtils::stat method r=barret,Gijs
Differential Revision: https://phabricator.services.mozilla.com/D84408
2020-07-23 18:15:30 +00:00
Keefer Rourke 3017836fc5 Bug 1653001: Implement IOUtils::makeDirectory method r=barret,Gijs
This patch introduces a makeDirectory method to the IOUtils interface, which
allows for creating directories on disk.

Differential Revision: https://phabricator.services.mozilla.com/D83996
2020-07-21 15:13:35 +00:00
Elaine 5423be3d2c Bug 1653431 - Remove unused _wifiScanningEnabledCountry pref. r=daleharvey
Differential Revision: https://phabricator.services.mozilla.com/D84089
2020-07-18 12:45:39 +00:00
Keefer Rourke 7498430cf9 Bug 1653003: Implement IOUtils::remove method r=barret,Gijs
This patch introduces a remove method to the IOUtils interface, which allows
for removing files and directories on disk. It is a simple wrapper around
the nsIFile::Remove method.

Differential Revision: https://phabricator.services.mozilla.com/D83663
2020-07-18 00:31:57 +00:00
Keefer Rourke 871fa78568 Bug 1653177: Fix minGW build failure due to use of missing identifiers r=Yoric,barret
This patch attempts to fix the permanent win mingw build failure caused
by use of the undeclared identifiers 'S_IFLNK' and 'S_IFSOCK' in
dom/system/OSFileConstants.cpp

These identifiers are only ever declared on Unix systems (Linux, macOS,
Android, etc.), so the `ifdef` guard around the use of these constants
has been updated appropriately.

Differential Revision: https://phabricator.services.mozilla.com/D83844
2020-07-16 21:46:38 +00:00
Bogdan Tara ae2858d542 Backed out changeset 8dee8cb525a2 (bug 1653003) for test_ioutils.html failures CLOSED TREE 2020-07-16 00:35:21 +03:00
Keefer Rourke 84e3e308b9 Bug 1653003: Implement IOUtils::remove method r=barret,Gijs
This patch introduces a remove method to the IOUtils interface, which allows
for removing files and directories on disk. It is a simple wrapper around
the nsIFile::Remove method.

Differential Revision: https://phabricator.services.mozilla.com/D83663
2020-07-15 19:45:37 +00:00
Keefer Rourke 80670a1607 Bug 1651742: Remove support for relative paths in IOUtils r=barret,Gijs
Differential Revision: https://phabricator.services.mozilla.com/D82982
2020-07-15 16:04:51 +00:00
Keefer Rourke b732cf15e1 Bug 1650898: Implement tmpPath and backupFile options for IOUtils::writeAtomic r=barret,Gijs
This patch refactors the existing IOUtils::writeAtomic method to add support for the `tmpPath` and `backupFile` options.

Differential Revision: https://phabricator.services.mozilla.com/D82601
2020-07-15 16:04:17 +00:00
Keefer Rourke 0dcdd65989 Bug 1650227: Implement IOUtils move method r=barret,Gijs
This patch introduces a move method to the IOUtils interface, which allows
for renaming/moving files or directories on disk. Source and destination
files may be specified either by an absolute path, or a relative path from
the current working directory.

This method has well-defined behaviour similar to the POSIX mv command
(except that this may create missing directories as necessary).
The behaviour is briefly summarized below:

1. If the source is a file that exists:

 a. If the destination is a file that does not exist, the source is
    renamed (and re-parented as a child of the destination parent
    directory). The destination parent directory will be created if
    necessary.

 b. If the destination is a file that does exist, the destination is
    replaced with the source (unless the noOverwrite option is true).


2. If the source is a directory that exists:

 a. If the destination is a directory, then the source directory is
    re-parented such that it becomes a child of the destination.

 b. If the destination does not exist, then the source is renamed,
    creating additional directories if needed.

 c. If the destination is a file, then an error occurs.


3. If the source does not exist, an error occurs.

Differential Revision: https://phabricator.services.mozilla.com/D82202
2020-07-15 16:03:52 +00:00
Csoregi Natalia cf4cf69408 Backed out 3 changesets (bug 1650898, bug 1651742, bug 1650227) for bustage on IOUtils.cpp. CLOSED TREE
Backed out changeset 4a1958574a2f (bug 1651742)
Backed out changeset 2809655ba642 (bug 1650898)
Backed out changeset d8930122993c (bug 1650227)
2020-07-14 23:03:48 +03:00
Keefer Rourke 235442cb08 Bug 1651742: Remove support for relative paths in IOUtils r=barret,Gijs
Differential Revision: https://phabricator.services.mozilla.com/D82982
2020-07-14 14:07:27 +00:00
Keefer Rourke f9cbdd7632 Bug 1650898: Implement tmpPath and backupFile options for IOUtils::writeAtomic r=barret,Gijs
This patch refactors the existing IOUtils::writeAtomic method to add support for the `tmpPath` and `backupFile` options.

Differential Revision: https://phabricator.services.mozilla.com/D82601
2020-07-14 18:45:29 +00:00
Keefer Rourke d71c1326c1 Bug 1650227: Implement IOUtils move method r=barret,Gijs
This patch introduces a move method to the IOUtils interface, which allows
for renaming/moving files or directories on disk. Source and destination
files may be specified either by an absolute path, or a relative path from
the current working directory.

This method has well-defined behaviour similar to the POSIX mv command
(except that this may create missing directories as necessary).
The behaviour is briefly summarized below:

1. If the source is a file that exists:

 a. If the destination is a file that does not exist, the source is
    renamed (and re-parented as a child of the destination parent
    directory). The destination parent directory will be created if
    necessary.

 b. If the destination is a file that does exist, the destination is
    replaced with the source (unless the noOverwrite option is true).


2. If the source is a directory that exists:

 a. If the destination is a directory, then the source directory is
    re-parented such that it becomes a child of the destination.

 b. If the destination does not exist, then the source is renamed,
    creating additional directories if needed.

 c. If the destination is a file, then an error occurs.


3. If the source does not exist, an error occurs.

Differential Revision: https://phabricator.services.mozilla.com/D82202
2020-07-13 23:06:19 +00:00
Kris Maglione 9d78661f88 Bug 1649221: Update ChromeUtils.generateQI callers to pass strings. r=mccr8,remote-protocol-reviewers,marionette-reviewers,perftest-reviewers,webcompat-reviewers,geckoview-reviewers,preferences-reviewers,agi,whimboo,Bebe,twisniewski
Differential Revision: https://phabricator.services.mozilla.com/D81594
2020-07-10 23:58:28 +00:00
Keefer Rourke 16fbac6f70 Bug 1642454: Implement IOUtils read and writeAtomic methods r=barret,smaug,Gijs
This patch introduces a minimal, asynchronous Web IDL interface for
reading/writing whole files in privileged chrome code (main-thread and web
workers). All I/O is performed on a background thread. Pending I/O blocks
Firefox shutdown.

Differential Revision: https://phabricator.services.mozilla.com/D78134
2020-07-02 22:32:03 +00:00
Keefer Rourke 6bab7cc369 Bug 1642454: Explicitly list copy and move assignment and ctor in PR_CloseDelete r=barret,smaug
Differential Revision: https://phabricator.services.mozilla.com/D80896
2020-07-02 22:30:12 +00:00
Keefer Rourke 5a86ee66cc Bug 1642454: Move PR_CloseDelete to dom/system r=barret,smaug
The class PR_CloseDelete is a useful deleter for automatically closing NSPR File
Descriptors when used with UniquePtr. This patch extracts this class from
nsTerminator.cpp to dom/system so it may easily be used by new Gecko code.

Differential Revision: https://phabricator.services.mozilla.com/D80719
2020-07-02 22:30:03 +00:00
Narcis Beleuzu 2f11bc8165 Backed out 4 changesets (bug 1642454) for failures on dom/system/tests/test_ioutils_worker.xhtml . CLOSED TREE
Backed out changeset 13553531fc62 (bug 1642454)
Backed out changeset 7896b4315920 (bug 1642454)
Backed out changeset 1e68090eed0b (bug 1642454)
Backed out changeset dfb201663480 (bug 1642454)
2020-07-03 01:16:36 +03:00
Keefer Rourke d6e77b7023 Bug 1642454: Implement IOUtils read and writeAtomic methods r=barret,smaug,Gijs
This patch introduces a minimal, asynchronous Web IDL interface for
reading/writing whole files in privileged chrome code (main-thread and web
workers). All I/O is performed on a background thread. Pending I/O blocks
Firefox shutdown.

Differential Revision: https://phabricator.services.mozilla.com/D78134
2020-07-02 20:21:16 +00:00
Keefer Rourke 79d8dcb860 Bug 1642454: Explicitly list copy and move assignment and ctor in PR_CloseDelete r=barret,smaug
Differential Revision: https://phabricator.services.mozilla.com/D80896
2020-07-02 20:16:15 +00:00
Keefer Rourke d4666b431c Bug 1642454: Move PR_CloseDelete to dom/system r=barret,smaug
The class PR_CloseDelete is a useful deleter for automatically closing NSPR File
Descriptors when used with UniquePtr. This patch extracts this class from
nsTerminator.cpp to dom/system so it may easily be used by new Gecko code.

Differential Revision: https://phabricator.services.mozilla.com/D80719
2020-07-02 20:16:07 +00:00
Simon Giesecke cd8b8939b9 Bug 1648010 - Replace uses of NS_LITERAL_STRING/NS_LITERAL_CSTRING macros by _ns literals. r=geckoview-reviewers,jgilbert,agi,hsivonen,froydnj
Differential Revision: https://phabricator.services.mozilla.com/D80860
2020-07-01 08:29:29 +00:00
Dale Harvey 9273a29b68 Bug 1637402 - Add pref to compare MLS results r=chutten,mikedeboer
Differential Revision: https://phabricator.services.mozilla.com/D74953
2020-06-02 00:01:31 +00:00
Razvan Maries a8e926b419 Backed out changeset 10807c4612a8 (bug 1637402) for perma failures on test_location_services_telemetry.html. CLOSED TREE 2020-06-01 23:52:44 +03:00
Dale Harvey a6ce421356 Bug 1637402 - Add pref to compare MLS results r=chutten,mikedeboer
Differential Revision: https://phabricator.services.mozilla.com/D74953
2020-06-01 16:44:29 +00:00
Frederik Braun de3412e689 Bug 1613609 - Add required loadinfo flag requests initiated with SystemPrincipal r=necko-reviewers,dragana
Adding the flag to existing channel/loadinfo object for:
- PushServices HTTP, WebSocket
- NetworkGeolocationProvider
- NetUtil.jsm's NewChannel
- NetworkConnectivityService
- OCSP
- Portal Detection
- ProductAddonChecker.jsm
- URLClassifier

Differential Revision: https://phabricator.services.mozilla.com/D75063
2020-05-19 08:54:58 +00:00
Mihai Alexandru Michis a2026344a1 Backed out 2 changesets (bug 1613609) for causing bustages.
CLOSED TREE

Backed out changeset dd6e395dc342 (bug 1613609)
Backed out changeset 5bcb7b13a4ad (bug 1613609)
2020-05-18 16:38:58 +03:00
Frederik Braun 3baff21cbd Bug 1613609 - Add required loadinfo flag requests initiated with SystemPrincipal r=necko-reviewers,dragana
Adding the flag to existing channel/loadinfo object for:
- PushServices HTTP, WebSocket
- NetworkGeolocationProvider
- NetUtil.jsm's NewChannel
- NetworkConnectivityService
- OCSP
- Portal Detection
- ProductAddonChecker.jsm
- URLClassifier

Differential Revision: https://phabricator.services.mozilla.com/D75063
2020-05-18 10:59:04 +00:00
Csoregi Natalia 5162f86676 Backed out 2 changesets (bug 1613609) for failures on nsXPConnect.cpp. CLOSED TREE
Backed out changeset c593a7296df4 (bug 1613609)
Backed out changeset 72199fc4ea2b (bug 1613609)
2020-05-18 13:05:12 +03:00
Frederik Braun 3b0d63cd07 Bug 1613609 - Add required loadinfo flag requests initiated with SystemPrincipal r=necko-reviewers,dragana
Adding the flag to existing channel/loadinfo object for:
- PushServices HTTP, WebSocket
- NetworkGeolocationProvider
- NetUtil.jsm's NewChannel
- NetworkConnectivityService
- OCSP
- Portal Detection
- ProductAddonChecker.jsm
- URLClassifier

Differential Revision: https://phabricator.services.mozilla.com/D75063
2020-05-18 09:19:17 +00:00
Aaron Klotz 7a8903706b Bug 1637452: Part 17 - Fix JNI includes in dom; r=nika
In this bug we're moving away from monolithic JNI headers to class-specific
headers so that we don't have to rebuild the world every time we make a change
to a JNI interface.

Differential Revision: https://phabricator.services.mozilla.com/D75380
2020-05-15 17:06:28 +00:00
Dale Harvey 3fa67b082d Bug 1627538 - Extract getRegion into its own jsm r=mikedeboer,Standard8
Differential Revision: https://phabricator.services.mozilla.com/D71165
2020-05-06 12:07:53 +00:00
Bogdan Tara 86530eabd1 Backed out changeset 049df3990b16 (bug 1627538) for test_autocomplete_basic_form_formActionOrigin.html failures CLOSED TREE 2020-05-06 22:09:46 +03:00
Dale Harvey ee1b1349f7 Bug 1627538 - Extract getRegion into its own jsm r=mikedeboer,Standard8
Differential Revision: https://phabricator.services.mozilla.com/D71165
2020-05-06 12:07:53 +00:00