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

3170 Коммитов

Автор SHA1 Сообщение Дата
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
Barret Rennie 1775ee67bf Bug 1680151 - Replace WriteUTF8Sync with call to WriteSync r=nika
Differential Revision: https://phabricator.services.mozilla.com/D99153
2021-01-15 04:57:07 +00:00
Barret Rennie 6539ca7596 Bug 1680151 - Reduce copies in IOUtils::Read{,UTF8} r=nika,tcampbell
Previously, in both Read and ReadUTF8, we were doing copies where we did not
need to. Read allocated an nsTArray and passed that to JS, which performed a
copy of its contents to create a Uint8Array. ReadUTF8, on the other hand, would
take that nsTArray, convert it into ns nsString (1 copy), and then pass it to
JS for it to recreate the string (2 copies).

Now, we allocate our string and array buffers up front in JS' memory pools
directly and use the JS API to create the strings and arrays ourselves (instead
of relying on Promise::MaybeResolve() to do a copying conversion). Read now
performs 0 copies in the best case (if the file is not compressed) and ReadUTF8
also does 0 copies in the best case (if the file is not compressed and the
string is ASCII). In the worst case, Read performs a single extra allocation
(to decompress the file) and ReadUTF8 performs 2 (to decompress the file and to
convert a UTF-8 string to either a Latin1 string or a UTF-16 string).

Differential Revision: https://phabricator.services.mozilla.com/D99004
2021-01-15 04:28:08 +00:00
Barret Rennie eaf165033d Bug 1680151 - Accept UTF8String directly in IOUtils::WriteUTF8 r=Gijs
Instead of accepting a DOMString (ie, a UTF16 string) and manually converting
it to UTF-8, we can instead accept a UTF8String from JS, which saves us
manually doing conversions and (and may save an additional conversion if the
JSString* is an ASCII string).

Differential Revision: https://phabricator.services.mozilla.com/D99003
2021-01-15 04:28:00 +00:00
Narcis Beleuzu 07863cc5ea Backed out changeset 43f2f5614583 (bug 1649611) for bustages on IOUtils.cpp CLOSED TREE 2021-01-15 05:26:47 +02:00
Emma Malysz 8a1ef36d37 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-14 19:05:32 +00:00
Narcis Beleuzu aaaaac3953 Backed out 3 changesets (bug 1680151) for mochitest crashes on IOUtils.cpp
Backed out changeset 50f790d4be27 (bug 1680151)
Backed out changeset 166148e5ef4e (bug 1680151)
Backed out changeset dc01552c74c0 (bug 1680151)
2021-01-15 01:23:18 +02:00
Barret Rennie 02b633a69e Bug 1680151 - Replace WriteUTF8Sync with call to WriteSync r=nika
Differential Revision: https://phabricator.services.mozilla.com/D99153
2021-01-14 19:22:15 +00:00
Barret Rennie a4e26e471d Bug 1680151 - Reduce copies in IOUtils::Read{,UTF8} r=nika,tcampbell
Previously, in both Read and ReadUTF8, we were doing copies where we did not
need to. Read allocated an nsTArray and passed that to JS, which performed a
copy of its contents to create a Uint8Array. ReadUTF8, on the other hand, would
take that nsTArray, convert it into ns nsString (1 copy), and then pass it to
JS for it to recreate the string (2 copies).

Now, we allocate our string and array buffers up front in JS' memory pools
directly and use the JS API to create the strings and arrays ourselves (instead
of relying on Promise::MaybeResolve() to do a copying conversion). Read now
performs 0 copies in the best case (if the file is not compressed) and ReadUTF8
also does 0 copies in the best case (if the file is not compressed and the
string is ASCII). In the worst case, Read performs a single extra allocation
(to decompress the file) and ReadUTF8 performs 2 (to decompress the file and to
convert a UTF-8 string to either a Latin1 string or a UTF-16 string).

Differential Revision: https://phabricator.services.mozilla.com/D99004
2021-01-14 19:22:10 +00:00
Barret Rennie 4e4ae21770 Bug 1680151 - Accept UTF8String directly in IOUtils::WriteUTF8 r=Gijs
Instead of accepting a DOMString (ie, a UTF16 string) and manually converting
it to UTF-8, we can instead accept a UTF8String from JS, which saves us
manually doing conversions and (and may save an additional conversion if the
JSString* is an ASCII string).

Differential Revision: https://phabricator.services.mozilla.com/D99003
2021-01-14 19:20:56 +00:00
smolnar de6685f248 Backed out 3 changesets (bug 1680151) for causing xpc/mochitest failures. CLOSED TREE
Backed out changeset 87222362f8f3 (bug 1680151)
Backed out changeset f5a436352e34 (bug 1680151)
Backed out changeset f9a606a66973 (bug 1680151)
2021-01-14 17:20:34 +02:00
Barret Rennie d9f36dce53 Bug 1680151 - Replace WriteUTF8Sync with call to WriteSync r=nika
Differential Revision: https://phabricator.services.mozilla.com/D99153
2021-01-13 00:57:24 +00:00
Barret Rennie 8c757c36b2 Bug 1680151 - Reduce copies in IOUtils::Read{,UTF8} r=nika,tcampbell
Previously, in both Read and ReadUTF8, we were doing copies where we did not
need to. Read allocated an nsTArray and passed that to JS, which performed a
copy of its contents to create a Uint8Array. ReadUTF8, on the other hand, would
take that nsTArray, convert it into ns nsString (1 copy), and then pass it to
JS for it to recreate the string (2 copies).

Now, we allocate our string and array buffers up front in JS' memory pools
directly and use the JS API to create the strings and arrays ourselves (instead
of relying on Promise::MaybeResolve() to do a copying conversion). Read now
performs 0 copies in the best case (if the file is not compressed) and ReadUTF8
also does 0 copies in the best case (if the file is not compressed and the
string is ASCII). In the worst case, Read performs a single extra allocation
(to decompress the file) and ReadUTF8 performs 2 (to decompress the file and to
convert a UTF-8 string to either a Latin1 string or a UTF-16 string).

Differential Revision: https://phabricator.services.mozilla.com/D99004
2021-01-13 00:57:16 +00:00
Barret Rennie 35a2af24dd Bug 1680151 - Accept UTF8String directly in IOUtils::WriteUTF8 r=Gijs
Instead of accepting a DOMString (ie, a UTF16 string) and manually converting
it to UTF-8, we can instead accept a UTF8String from JS, which saves us
manually doing conversions and (and may save an additional conversion if the
JSString* is an ASCII string).

Differential Revision: https://phabricator.services.mozilla.com/D99003
2021-01-13 00:57:03 +00:00
Emma Malysz 1ec5d6778d Bug 1686335, fix test for PathUtils.createUniquePath() r=barret
Differential Revision: https://phabricator.services.mozilla.com/D101645
2021-01-13 22:53:23 +00:00
Barret Rennie 99ec0104cf Bug 1684999 - Call RunOnShutdown on main thread in PathUtils r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D101382
2021-01-12 20:38:28 +00:00
Emma Malysz 1fb61f9730 Bug 1679704, support createUniquePath in PathUtils r=barret
Differential Revision: https://phabricator.services.mozilla.com/D101419
2021-01-12 20:44:46 +00:00
Butkovits Atila dc4510e256 Backed out changeset 3587cb6cc383 (bug 1684999) for causing failure at send_alert_text.py. CLOSED TREE 2021-01-12 21:26:40 +02:00
Barret Rennie f32a9ef091 Bug 1684999 - Call RunOnShutdown on main thread in PathUtils r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D101382
2021-01-12 16:36:56 +00:00
Barret Rennie cff1a2c34d Bug 1682031 - Add PathUtils.appendRelative r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D99505
2020-12-17 23:55:45 +00:00
Razvan Maries c1dc47efa6 Backed out changeset dbea74f0edd3 (bug 1682031) for perma faimures on test_pathutils.html. CLOSED TREE 2020-12-17 08:07:08 +02:00
Barret Rennie 502eea4257 Bug 1682031 - Add PathUtils.appendRelative r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D99505
2020-12-11 22:01:38 +00:00
Barret Rennie 9ff7f42366 Bug 1677000 - Address unpublished clang-tidy lints r=Gijs
There are two new lints introduced since IOUtils was written that we're hitting
now:

* IOUtils::InternalFileInfo's constructor does not initialize `mType`, `mSize`,
  `mLastModified`, and `mPermissions`; and
* We should be using a nested namespace statement.

We haven't hit them since these lines haven't been touched, but I noticed them
on the code review frontend.

Differential Revision: https://phabricator.services.mozilla.com/D99163
2020-12-09 05:48:51 +00:00
Barret Rennie 3d4c77c1f2 Bug 1677000 - Remove unused IOUtils::WriteSync(PRFileDesc* ...) declaration r=Gijs
The implementation was removed in a previous change (bug 1665172) but the
declaration stuck around.

Differential Revision: https://phabricator.services.mozilla.com/D99152
2020-12-09 05:48:48 +00:00
Barret Rennie e2fce2bed4 Bug 1677000 - Rename IOUtils.writeAtomic{,UTF8} to IOUtils.write{,UTF8} r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D99001
2020-12-09 05:48:46 +00:00
Barret Rennie 72492145e6 Bug 1677000 - Add a type alias for MozPromise<T, IOError, true> r=Gijs
To use this type alias, IOUtils::InvokeToIOPromise had to become either a
member fn or a friend.

Differential Revision: https://phabricator.services.mozilla.com/D99000
2020-12-09 05:48:44 +00:00
Barret Rennie 45f4571694 Bug 1677000 - Refactor ResolveJSPromise out of RunOnBackgroundThread r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D98999
2020-12-09 05:48:41 +00:00
Barret Rennie 9046e56316 Bug 1677000 - Pass Promise* to RejectJSPromise instead of RefPtr<Promise>& r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D98998
2020-12-09 05:47:31 +00:00
Barret Rennie d2531c0b18 Bug 1677000 - Remove IsAbsolutePath() from IOUtils.h r=Gijs
The implementation was removed in bug 1676942.

Differential Revision: https://phabricator.services.mozilla.com/D98997
2020-12-09 05:47:24 +00:00
Razvan Maries 9614a08d73 Backed out 7 changesets (bug 1677000) for perma failures on test_ioutils_read_write.html. CLOSED TREE
Backed out changeset 3521334cfc38 (bug 1677000)
Backed out changeset 737f380c2cf2 (bug 1677000)
Backed out changeset 9dba15fdfe1f (bug 1677000)
Backed out changeset b2fa1a061b15 (bug 1677000)
Backed out changeset a5d7845d3c0c (bug 1677000)
Backed out changeset 8e6081b0c07d (bug 1677000)
Backed out changeset 6592577cf0fa (bug 1677000)
2020-12-09 07:34:21 +02:00
Barret Rennie 10834d52a9 Bug 1677000 - Address unpublished clang-tidy lints r=Gijs
There are two new lints introduced since IOUtils was written that we're hitting
now:

* IOUtils::InternalFileInfo's constructor does not initialize `mType`, `mSize`,
  `mLastModified`, and `mPermissions`; and
* We should be using a nested namespace statement.

We haven't hit them since these lines haven't been touched, but I noticed them
on the code review frontend.

Differential Revision: https://phabricator.services.mozilla.com/D99163
2020-12-09 04:31:55 +00:00
Barret Rennie 8b5f75f647 Bug 1677000 - Remove unused IOUtils::WriteSync(PRFileDesc* ...) declaration r=Gijs
The implementation was removed in a previous change (bug 1665172) but the
declaration stuck around.

Differential Revision: https://phabricator.services.mozilla.com/D99152
2020-12-09 04:31:47 +00:00
Barret Rennie 0dc367a38f Bug 1677000 - Rename IOUtils.writeAtomic{,UTF8} to IOUtils.write{,UTF8} r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D99001
2020-12-09 04:31:40 +00:00
Barret Rennie c50f24f067 Bug 1677000 - Add a type alias for MozPromise<T, IOError, true> r=Gijs
To use this type alias, IOUtils::InvokeToIOPromise had to become either a
member fn or a friend.

Differential Revision: https://phabricator.services.mozilla.com/D99000
2020-12-09 04:31:01 +00:00
Barret Rennie 3aa75d55bb Bug 1677000 - Refactor ResolveJSPromise out of RunOnBackgroundThread r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D98999
2020-12-09 04:30:54 +00:00
Barret Rennie 5f9b9ebb3e Bug 1677000 - Pass Promise* to RejectJSPromise instead of RefPtr<Promise>& r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D98998
2020-12-09 04:30:46 +00:00
Barret Rennie 052ed397fa Bug 1677000 - Remove IsAbsolutePath() from IOUtils.h r=Gijs
The implementation was removed in bug 1676942.

Differential Revision: https://phabricator.services.mozilla.com/D98997
2020-12-09 04:30:39 +00:00
Dale Harvey bea62c168a Bug 1663501 - Use geolocation monitor for region updates r=Standard8
Differential Revision: https://phabricator.services.mozilla.com/D91214
2020-12-04 17:46:03 +00:00
Barret Rennie 72dbca0048 Bug 1680449 - Clean up after test_setPermissions on Windows r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D98672
2020-12-03 23:58:39 +00:00
Barret Rennie 1cf888ecaf Bug 1678415 - Support setting file mode in IOUtils.createDirectory on non-Windows platforms r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D97691
2020-12-03 05:38:11 +00:00
Barret Rennie ae7c7ad4a2 Bug 1678471 - Implement IOUtils::Exists r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D97690
2020-12-03 05:38:03 +00:00
Barret Rennie 47793f361c Bug 1673019 - Get and set file permissions in IOUtils r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D97689
2020-12-03 05:37:45 +00:00
Barret Rennie 69d3035e96 Bug 1660843 - Return creation time from IOUtils.stat() on supported platforms r=emalysz
Differential Revision: https://phabricator.services.mozilla.com/D96890
2020-12-03 05:37:33 +00:00
Barret Rennie 3ab2f47c1c Bug 1679873 - Pass closures to IOUtils::RunOnBackgroundThread r=nika
Passing in a callable and its arguments to RunOnBackgroundThread was fine
before we started passing in already_AddRefed<nsIFile>. However, if we fail to
get an event target, then we drop all our arguments and in debug builds
already_AddRefed<T> asserts that it was moved out of.

Now we require callers of RunOnBackgroundThread to pass in a closure that
contains all the bindings they require, which has the added bonus of making
lifetimes more explicit. As part of this refactor, all the `ReadSync` etc
methods now take raw nsIFile* pointers since they are called in a scope that
has them refcounted.

Differential Revision: https://phabricator.services.mozilla.com/D98273
2020-12-03 04:10:30 +00:00