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

146 Коммитов

Автор SHA1 Сообщение Дата
Barret Rennie 0a42a75031 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 f4bf79a649 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 2d0c990efe 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 72b138b1d8 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 f6a367e413 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 df441c491f 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 40de6947f1 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 4a41568805 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 71fbec519e 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 bcbf4ea5cd 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 16596721d7 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 f2f68509d3 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 cb53a7c598 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 11e3806217 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 13d49d5aec 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 f0e8e4fa7d 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 f018480dfe 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 8ee03a8cfa 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 ca179d4005 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 f8bbd23197 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 257abce850 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
Chris Peterson 2d4ca059e8 Bug 1691889 - Replace MOZ_MUST_USE with [[nodiscard]] in dom/. r=peterv
The MOZ_MUST_USE macro is defined as clang's and gcc's nonstandard __attribute__((warn_unused_result)). Now that we compile as C++17 by default (bug 1560664), we can replace MOZ_MUST_USE with C++17's standard [[nodiscard]] attribute.

The [[nodiscard]] attribute must precede a function declaration's declaration specifiers (like static, extern, inline, or virtual). The __attribute__((warn_unused_result)) attribute does not have this order restriction.

Differential Revision: https://phabricator.services.mozilla.com/D107355
2021-03-10 08:19:25 +00:00
Alexandru Michis 62a9d11677 Backed out 2 changesets (bug 1672431) for causing bustages in IOUtils.cpp
CLOSED TREE

Backed out changeset 9d117ef49249 (bug 1672431)
Backed out changeset fa79148301f5 (bug 1672431)
2021-03-10 06:32:41 +02:00
Barret Rennie 416e462689 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-09 23:11:13 +00:00
smolnar e95ed5a59b Backed out 3 changesets (bug 1672431) for causing xpc failures in IOUtils. CLOSED TREE
Backed out changeset ef2e347ff4f0 (bug 1672431)
Backed out changeset b1b467fd5aeb (bug 1672431)
Backed out changeset d223c887b0b6 (bug 1672431)
2021-02-22 20:56:05 +02:00
Barret Rennie 731aee8763 Bug 1672431 - Initialize IOUtils during startup r=nika
Previously we were initializing IOUtils lazily when we received our first IO
request, but that could run into problems when

1. shutdown starts before submitting any IO requests, which would then fail to
   add shutdown blockers for phases we have already passed; or
2. the first IO request comes from off-main-thread, which can not tell if the
   shutdown blockers are added successfully.

Now we register an observer to initialize the event queue and add all startup
blockers in the `profile-after-change` phase. We can then be sure that IOUtils
will have its blockers added before `profile-before-change`.

Differential Revision: https://phabricator.services.mozilla.com/D105700
2021-02-22 18:25:06 +00:00
Barret Rennie 483ccc22f9 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-02-22 18:25:05 +00:00
smolnar ab304f6276 Backed out 2 changesets (bug 1672431) for causing mochitest failures at IOUtils. CLOSED TREE DONTBUILD
Backed out changeset 1f5a77c484b0 (bug 1672431)
Backed out changeset 65397d9e0ff3 (bug 1672431)
2021-02-18 10:20:24 +02:00
Barret Rennie 17a105fe5c 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-02-18 07:29:17 +00:00
Emma Malysz 036272d9b2 Bug 1649611: Remove OS.File usage from DownloadIntegration.jsm and respect umask in IOUtils::SetPermissions r=barret
Depends on D103520

Differential Revision: https://phabricator.services.mozilla.com/D99729
2021-01-30 00:50:47 +00:00
Barret Rennie eebe62f30e Bug 1689740 - Check for nsIFile::GetParent() returning null in IOUtils r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D103520
2021-01-30 05:47:25 +00:00
Barret Rennie 60d382943b Bug 1688711 - Don't write to empty JsBuffer when reading compressed files r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D103524
2021-01-30 00:33:21 +00:00
Narcis Beleuzu 37d1a797ce Backed out 2 changesets (bug 1689740, bug 1649611) for mochitest failures on test_ioutils_mkdir.html
Backed out changeset 91181a01b68c (bug 1649611)
Backed out changeset 4dd71fe08a0e (bug 1689740)
2021-01-30 02:47:37 +02:00
Emma Malysz e13166a7b1 Bug 1649611: Remove OS.File usage from DownloadIntegration.jsm and respect umask in IOUtils::SetPermissions r=barret
Depends on D103520

Differential Revision: https://phabricator.services.mozilla.com/D99729
2021-01-29 22:56:54 +00:00
Barret Rennie 8ba96a2ae5 Bug 1689740 - Check for nsIFile::GetParent() returning null in IOUtils r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D103520
2021-01-29 22:55:22 +00:00
Cosmin Sabou dd042f25a8 Backed out changeset c7dd9e63300d (bug 1649611) for causing bug 1689404. a=backout 2021-01-29 11:57:53 +02:00
Emma Malysz 61a1c11e58 Bug 1649611: Remove OS.File usage from DownloadIntegration.jsm and respect umask in IOUtils::SetPermissions r=barret
Differential Revision: https://phabricator.services.mozilla.com/D99729
2021-01-28 00:59:04 +00:00
Butkovits Atila 09e52162fa Backed out changeset c89276392499 (bug 1649611) for causing build bustages. CLOSED TREE 2021-01-28 01:13:59 +02:00
Emma Malysz 83a2a99541 Bug 1649611: Remove OS.File usage from DownloadIntegration.jsm and respect umask in IOUtils::SetPermissions r=barret
Differential Revision: https://phabricator.services.mozilla.com/D99729
2021-01-27 22:19:22 +00:00
Barret Rennie d95d11d187 Bug 1676942 - Replace remaining usage of NS_ENSURE_TRUE in IOUtils r=nika
This patch is a minor cleanup based on prior feedback to make all of IOUtils
consistent.

Differential Revision: https://phabricator.services.mozilla.com/D100058
2021-01-18 19:52:36 +00:00
Barret Rennie 711d24719c Bug 1676942 - Add IOUtils::WriteJSON r=nika,tcampbell
Differential Revision: https://phabricator.services.mozilla.com/D99155
2021-01-18 19:52:34 +00:00
Barret Rennie 7e2b57614d Bug 1676942 - Add IOUtils::ReadJSON r=nika,tcampbell
Differential Revision: https://phabricator.services.mozilla.com/D99154
2021-01-18 19:52:32 +00:00
Barret Rennie 1b41576f43 Bug 1676942 - Refactor RunOnBackgroundThread r=nika
RunOnBackgroundThread has been renamed to RunOnBackgroundThreadAndResolve. The
body dealing with calling InvokeAsync for calling a function on the background
event target and returning a MozPromise has been refactored into a new
function, RunOnBackgroundThread.

This allows us to have more complicated IOUtils methods that do not simply
resolve their promises to whatever is returned by the background methods.

Differential Revision: https://phabricator.services.mozilla.com/D99002
2021-01-18 19:52:29 +00:00
Mihai Alexandru Michis cc7f02268b Backed out changeset 4934ec1fbb6f (bug 1649611) for causing xpcshell failures in test_DownloadCore.js
CLOSED TREE
2021-01-16 12:50:11 +02:00
Emma Malysz 9497c44dcb Bug 1649611: Remove OS.File usage from DownloadIntegration.jsm and respect umask in IOUtils::SetPermissions r=barret
Differential Revision: https://phabricator.services.mozilla.com/D99729
2021-01-15 21:42:10 +00:00
Csoregi Natalia e2b141a4a9 Backed out 4 changesets (bug 1676942) for failures on test_ioutils_read_write_json.html. CLOSED TREE
Backed out changeset cbd8324d869d (bug 1676942)
Backed out changeset ac0d932fe580 (bug 1676942)
Backed out changeset 3cc0c110b0ec (bug 1676942)
Backed out changeset 3595d192a9e0 (bug 1676942)
2021-01-15 23:28:18 +02:00
Barret Rennie ee3629a5a3 Bug 1676942 - Replace remaining usage of NS_ENSURE_TRUE in IOUtils r=nika
This patch is a minor cleanup based on prior feedback to make all of IOUtils
consistent.

Differential Revision: https://phabricator.services.mozilla.com/D100058
2021-01-15 04:57:43 +00:00
Barret Rennie 5218239ac1 Bug 1676942 - Add IOUtils::WriteJSON r=nika,tcampbell
Differential Revision: https://phabricator.services.mozilla.com/D99155
2021-01-15 04:57:36 +00:00
Barret Rennie ff56b503d0 Bug 1676942 - Add IOUtils::ReadJSON r=nika,tcampbell
Differential Revision: https://phabricator.services.mozilla.com/D99154
2021-01-15 04:57:28 +00:00
Barret Rennie 0e2cccc6a3 Bug 1676942 - Refactor RunOnBackgroundThread r=nika
RunOnBackgroundThread has been renamed to RunOnBackgroundThreadAndResolve. The
body dealing with calling InvokeAsync for calling a function on the background
event target and returning a MozPromise has been refactored into a new
function, RunOnBackgroundThread.

This allows us to have more complicated IOUtils methods that do not simply
resolve their promises to whatever is returned by the background methods.

Differential Revision: https://phabricator.services.mozilla.com/D99002
2021-01-15 04:57:15 +00:00