Commit Graph

175 Commits

Author SHA1 Message Date
Peter Van der Beken
1c499dc49d Bug 1766130 - Properly propagate errors from Promise creation. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D144515
2022-05-02 07:44:23 +00:00
Jan Rio Krause
3fe00f5de7 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
Barret Rennie
ed0e7e310f Bug 1743671 - Keep worker threads alive while IOUtils tasks are running r=Gijs,dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D137465
2022-02-01 03:23:44 +00:00
Barret Rennie
70dafd0061 Bug 1745361 - Create unique directories and files with IOUtils r=Gijs,webdriver-reviewers,extension-reviewers,robwu
PathUtils::CreateUniquePath was doing main thread IO, so we're moving it to
IOUtils to use its event loop to do the IO.

Additionally, we're adding IOUtils::CreateUniqueDirectory which is the same as
::CreateUniqueFile, but for directories.

Differential Revision: https://phabricator.services.mozilla.com/D133841
2022-01-18 05:04:52 +00:00
Cristian Tuns
df312eac74 Backed out changeset e93fd0b78d3e (bug 1745361) for causing build bustages on PathUtils.cpp CLOSED TREE 2022-01-17 13:06:42 -05:00
Barret Rennie
9729de44e3 Bug 1745361 - Create unique directories and files with IOUtils r=Gijs,webdriver-reviewers,extension-reviewers,robwu
PathUtils::CreateUniquePath was doing main thread IO, so we're moving it to
IOUtils to use its event loop to do the IO.

Additionally, we're adding IOUtils::CreateUniqueDirectory which is the same as
::CreateUniqueFile, but for directories.

Differential Revision: https://phabricator.services.mozilla.com/D133841
2022-01-17 17:50:26 +00:00
criss
e0ce1d165b Backed out changeset 4448cd53ed42 (bug 1745361) for causing hybrid bustages on PathUtils.cpp 2021-12-31 23:06:40 +02:00
Barret Rennie
ca3d461009 Bug 1745361 - Create unique directories and files with IOUtils r=Gijs,webdriver-reviewers,extension-reviewers,robwu
PathUtils::CreateUniquePath was doing main thread IO, so we're moving it to
IOUtils to use its event loop to do the IO.

Additionally, we're adding IOUtils::CreateUniqueDirectory which is the same as
::CreateUniqueFile, but for directories.

Differential Revision: https://phabricator.services.mozilla.com/D133841
2021-12-31 20:28:39 +00:00
Barret Rennie
0adaa4433d Bug 1736331 - Add IOUtils methods for dealing with macOS extended filesystem attributes r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D133837
2021-12-25 00:30:11 +00:00
Butkovits Atila
2ea56bdbc5 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
f9d87bf04c Bug 1736331 - Add IOUtils methods for dealing with macOS extended filesystem attributes r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D133837
2021-12-23 23:02:13 +00:00
Sandor Molnar
da9cceefbe 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
c7424f8ce9 Bug 1736331 - Add IOUtils methods for dealing with macOS extended filesystem attributes r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D133837
2021-12-22 19:46:15 +00:00
Csoregi Natalia
c714056675 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
25bef001bd Bug 1736331 - Add IOUtils methods for dealing with macOS extended filesystem attributes r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D133837
2021-12-22 16:40:53 +00:00
Barret Rennie
0dff193301 Bug 1743404 - Add IOUtils::{Get,Set}WindowsFileAttributes r=nika
Differential Revision: https://phabricator.services.mozilla.com/D133835
2021-12-17 17:21:22 +00:00
Barret Rennie
fb92dcd19c Bug 1744809 - Reduce boilerplate in IOUtils frontend methods r=nika
Differential Revision: https://phabricator.services.mozilla.com/D133832
2021-12-16 04:47:19 +00:00
Marian-Vasile Laza
47e36e26aa Backed out 2 changesets (bug 1744809, bug 1744316) for causing xpcshell failures on marAppApplyDirLockedStageFailure_win.js.
Backed out changeset d14261ebd3b1 (bug 1744316)
Backed out changeset dbbcea46c9d9 (bug 1744809)
2021-12-16 03:31:32 +02:00
Barret Rennie
9a1ecc13e7 Bug 1744809 - Reduce boilerplate in IOUtils frontend methods r=nika
Differential Revision: https://phabricator.services.mozilla.com/D133832
2021-12-15 19:56:08 +00:00
Barret Rennie
dc0705b353 Bug 1741465 - Support reading files larger than UINT32_MAX if using a large enough offset r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D132262
2021-12-03 17:21:52 +00:00
Alexandru Michis
cafa623cca Backed out changeset b6ebaaea0102 (bug 1741465) for causing bustages in IOUtils.cpp
CLOSED TREE
2021-12-01 23:42:21 +02:00
Barret Rennie
7ccc0abcae Bug 1741465 - Support reading files larger than UINT32_MAX if using a large enough offset r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D132262
2021-12-01 20:35:21 +00:00
Mathew Hodson
836d988279 Bug 1741548 - Add ignoreAbsent option to IOUtils.getChildren method. r=barret
Remove an incorrect comment.

Differential Revision: https://phabricator.services.mozilla.com/D131323
2021-11-25 10:45:55 +00:00
Barret Rennie
df126592db Bug 1739702 - Rename IOUtils.touch to IOUtils.setModificationTime r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D131957
2021-11-25 02:19:20 +00:00
Butkovits Atila
32834904a6 Backed out changeset 2ebd54655436 (bug 1739702) for causing failres at test_ioutils_stat_set_modification_time.html. CLOSED TREE 2021-11-24 06:41:13 +02:00
Barret Rennie
a27162f471 Bug 1739702 - Rename IOUtils.touch to IOUtils.setModificationTime r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D131957
2021-11-24 03:52:14 +00:00
Barret Rennie
5df15c6e9d Bug 1742429 - On Windows, assert IOUtils/PathUtils paths do not contain forward slashes r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D131812
2021-11-23 17:27:20 +00:00
Marian-Vasile Laza
9257323ccf Backed out changeset db6cd75d5c00 (bug 1742429) for causing build bustages on IOUtils.cpp. CLOSED TREE 2021-11-23 17:23:33 +02:00
Barret Rennie
2273b83e80 Bug 1742429 - On Windows, assert IOUtils/PathUtils paths do not contain forward slashes r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D131812
2021-11-23 14:33:27 +00:00
Barret Rennie
a3f4fb6d99 Bug 1723082 - Support reading files > INT32_MAX in IOUtils r=Gijs
Previously, if you attempted to read a file greater than INT32_MAX in size, we
would either fail to read the file (on release) or crash (on debug). This is
due to the implementation of _PR_MD_READ accepting an int32_t of bytes to read
instead of a uint32_t, which nsFileStream::Read accepts and passes on.

Differential Revision: https://phabricator.services.mozilla.com/D131161
2021-11-17 03:55:36 +00:00
Barret Rennie
0c0d4b63e6 Bug 1741247 - Include nsresult error codes in errors IOUtils does not know how to map r=Gijs
Presently, if IOUtils encounters an error that it does not know how to map to
 a DOMException (via RejectJSPromise), it will only include the nsresult error
 code if the IOError was constructed without a message. This hides the root
 cause of errors.

 Now we always include the error code when rejecting with an UnknownError.

Differential Revision: https://phabricator.services.mozilla.com/D131160
2021-11-17 03:55:35 +00:00
Alexandru Michis
79dda0b2d5 Backed out 3 changesets (bug 1741247, bug 1723082, bug 1736175) for causing PathUtils.normalize failures.
CLOSED TREE

Backed out changeset 55165cf4b7bb (bug 1736175)
Backed out changeset 492f5ca3b592 (bug 1723082)
Backed out changeset ce199e98a0c5 (bug 1741247)
2021-11-17 03:12:07 +02:00
Barret Rennie
ef2d0bcd3a Bug 1723082 - Support reading files > INT32_MAX in IOUtils r=Gijs
Previously, if you attempted to read a file greater than INT32_MAX in size, we
would either fail to read the file (on release) or crash (on debug). This is
due to the implementation of _PR_MD_READ accepting an int32_t of bytes to read
instead of a uint32_t, which nsFileStream::Read accepts and passes on.

Differential Revision: https://phabricator.services.mozilla.com/D131161
2021-11-17 00:28:58 +00:00
Barret Rennie
6bb143045a Bug 1741247 - Include nsresult error codes in errors IOUtils does not know how to map r=Gijs
Presently, if IOUtils encounters an error that it does not know how to map to
 a DOMException (via RejectJSPromise), it will only include the nsresult error
 code if the IOError was constructed without a message. This hides the root
 cause of errors.

 Now we always include the error code when rejecting with an UnknownError.

Differential Revision: https://phabricator.services.mozilla.com/D131160
2021-11-17 00:28:58 +00:00
Markus Stange
e5170083a6 Bug 1726480 - Add IOUtils::OpenFileForSyncReading. r=dom-worker-reviewers,asuth
This exposes synchronous file reading to workers. It's intended to be used
by profiler symbolication.
The API only supports reading into an existing Uint8Array. This avoids
creating garbage, and minimizes copies.
It also keeps the file open so that it doesn't need to be reopened for
each read.

The implementation uses nsFileStream.

I first tried an implementation which used mmap + memcpy rather than read,
but it didn't work for files larger than 2GiB due to limitations in NSPR's
mmap support, and the profiler needs to read >2GiB files.
Specifically, the profiler sometimes needs to read
/System/Library/dyld/dyld_shared_cache_arm64e , which is 2.2GiB big on
macOS 11.5.

Differential Revision: https://phabricator.services.mozilla.com/D124207
2021-11-04 19:47:29 +00:00
Nika Layzell
7c17c38e31 Bug 1734700 - Use the IO event queue for IOUtils background tasks, r=KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D128311
2021-10-18 19:34:59 +00:00
Noemi Erli
06628df338 Backed out changeset 584a442f7d7b (bug 1734700) for causing failures in test_feature_fileioall.js CLOSED TREE 2021-10-15 18:47:08 +03:00
Nika Layzell
1c28fe4501 Bug 1734700 - Use the IO event queue for IOUtils background tasks, r=KrisWright
Differential Revision: https://phabricator.services.mozilla.com/D128311
2021-10-15 14:17:42 +00:00
Gijs Kruitbosch
7a6699064b Bug 1714583 - allow nsIFile::Create to skip creating ancestor directories, to fix IOUtils::makeDirectory, to fix UNC default download folders, r=barret,xpcom-reviewers,mccr8
Differential Revision: https://phabricator.services.mozilla.com/D120338
2021-07-21 18:38:12 +00:00
Emma Malysz
086910c022 Bug 1712642: allow overwrite for WriteMode::Overwrite and WriteMode::Append r=barret
Differential Revision: https://phabricator.services.mozilla.com/D115849
2021-05-26 16:46:03 +00:00
Jens Stutte
67170da4d4 Bug 1690326: Add mappings for ERROR_DEVICE_HARDWARE_ERROR, ERROR_DEVICE_NOT_CONNECTED, ERROR_DISK_FULL and remove error NS_ERROR_FILE_DISK_FULL in favor of existing NS_ERROR_FILE_NO_DEVICE_SPACE r=xpcom-reviewers,necko-reviewers,nika,valentin
Win32 errors ERROR_DEVICE_HARDWARE_ERROR, ERROR_DEVICE_NOT_CONNECTED, ERROR_DISK_FULL need a mapping.
NS_ERROR_FILE_DISK_FULL is duplicate to NS_ERROR_FILE_NO_DEVICE_SPACE
Drive by: RejectJSPromise lacked some NS_ERROR_* mappings

Differential Revision: https://phabricator.services.mozilla.com/D113974
2021-05-06 14:00:06 +00:00
Martin Giger
26f3e6f4a8 Bug 1709056 - Fix IOUtils append mode documentation and overwrite error. r=barret
Differential Revision: https://phabricator.services.mozilla.com/D114075
2021-05-05 08:36:48 +00:00
Barret Rennie
dc5b4cbebf Bug 1663707 - Support multiple modes for IOUtils.write methods r=emalysz
IOUtils.write{,UTF8,JSON} now support multiple writing modes:

* overwrite, where the contents of the file will be overwritten and a new file
  will be created if it does not exist (the old default),
* create, where the file cannot exist and it will be created during the
  operation; and
* append, where the file will be appended to.

(Append is not currently supported for writeJSON because appending JSON blobs
together doesn't make sense most of the time.)

Differential Revision: https://phabricator.services.mozilla.com/D113450
2021-04-29 22:38:02 +00:00
Barret Rennie
57fc4d423d Bug 1702471 - Support reading at an offset in IOUtils.read r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D111734
2021-04-28 23:27:42 +00:00
Barret Rennie
b8b3abced8 Bug 1703448 - IOUtils.write() to a directory with a temp file should fail r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D111052
2021-04-28 18:37:49 +00:00
Csoregi Natalia
19198b94b2 Backed out changeset 9e72fa6ee4a2 (bug 1703448) for causing failures due to files in tmp folder. CLOSED TREE 2021-04-22 08:29:29 +03:00
Barret Rennie
d2ed30de70 Bug 1703448 - IOUtils.write() to a directory with a temp file should fail r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D111052
2021-04-22 04:21:09 +00:00
Barret Rennie
ff550400aa Bug 1672431 - Provide a shutdown client for IOUtils r=xpcom-reviewers,nika
IOUtils now provides a shutdown client for clients to register IO jobs with
that need to run before shutdown finishes. This allows IO jobs to run during
the profileBeforeChange phase.

IOUtils' event queuing has been refactored into a singleton EventQueue class,
which is responsible for running tasks and setting up shutdown blockers. It is
now guarded behind a StaticDataMutex so that is more explicitly clear what is
and is not re-entrant. (The atomic sShutdownFinished cannot be placed behind
the mutex because we need to keep track of that state even when we do not have
an EventQueue.)

Differential Revision: https://phabricator.services.mozilla.com/D103973
2021-03-23 04:26:50 +00:00
Dorel Luca
5c8894b9e6 Backed out 2 changesets (bug 1672431) for Browser-chrome failures with assertion on checkouts/gecko/dom/system/IOUtils.cpp. CLOSED TREE
Backed out changeset b9b380d9a847 (bug 1672431)
Backed out changeset f4ca5feb7e35 (bug 1672431)
2021-03-11 01:44:09 +02:00
Barret Rennie
ee26094a70 Bug 1672431 - Provide a shutdown client for IOUtils r=xpcom-reviewers,nika
IOUtils now provides a shutdown client for clients to register IO jobs with
that need to run before shutdown finishes. This allows IO jobs to run during
the profileBeforeChange phase.

IOUtils' event queuing has been refactored into a singleton EventQueue class,
which is responsible for running tasks and setting up shutdown blockers. It is
now guarded behind a StaticDataMutex so that is more explicitly clear what is
and is not re-entrant. (The atomic sShutdownFinished cannot be placed behind
the mutex because we need to keep track of that state even when we do not have
an EventQueue.)

Differential Revision: https://phabricator.services.mozilla.com/D103973
2021-03-10 20:34:27 +00:00