Commit graph

121 commits

Author SHA1 Message Date
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
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
Jan Varga
a7f7389681 Bug 1731969 - Rename ToResultInvoke member function overloads to ToResultInvokeMember; r=dom-storage-reviewers,jari
Differential Revision: https://phabricator.services.mozilla.com/D126328
2021-11-30 05:05:53 +00:00
Haiyang Xu
aafd5d8064 Bug 1672140 - Rename cache::ClientMetadata to cache::CacheDirectoryMetadata; r=dom-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D131590
2021-11-24 20:50:37 +00:00
hxu
93316dde65 Bug 1672140 - Change cache::ClientMetadata's base class from quota::OriginMetadata to quota::ClientMetadata; r=dom-storage-reviewers,janv
Depends on D125583

Differential Revision: https://phabricator.services.mozilla.com/D126056
2021-11-24 20:50:37 +00:00
hxu
2dbd17aeac Bug 1672140 - Rename cache::QuotaInfo to cache::ClientMetadata and rename corresponding functions; r=dom-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D125583
2021-11-24 20:50:36 +00:00
Butkovits Atila
af69ca9209 Backed out 3 changesets (bug 1672140) for causing Bp-hybrid build bustages.
Backed out changeset 32edbc243607 (bug 1672140)
Backed out changeset 549556f430a7 (bug 1672140)
Backed out changeset 396640d13ece (bug 1672140)
2021-11-23 20:25:56 +02:00
Haiyang Xu
cd667b26f8 Bug 1672140 - Rename cache::ClientMetadata to cache::CacheDirectoryMetadata; r=dom-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D131590
2021-11-23 16:53:50 +00:00
hxu
95d8bdaa44 Bug 1672140 - Change cache::ClientMetadata's base class from quota::OriginMetadata to quota::ClientMetadata; r=dom-storage-reviewers,janv
Depends on D125583

Differential Revision: https://phabricator.services.mozilla.com/D126056
2021-11-23 16:53:50 +00:00
hxu
45a53e311d Bug 1672140 - Rename cache::QuotaInfo to cache::ClientMetadata and rename corresponding functions; r=dom-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D125583
2021-11-23 16:53:49 +00:00
Jan Varga
572fb1f823 Bug 1731544 - Replace existing ToResult uses with MOZ_TO_RESULT; r=dom-storage-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D125324
2021-10-10 19:06:36 +00:00
Jan Varga
685aa0cc5e Bug 1728267 - Remove implicit ToResult from QM_TRY when no extra argument is passed in dom/cache; r=dom-storage-reviewers,jstutte,jari
Differential Revision: https://phabricator.services.mozilla.com/D125319
2021-09-24 13:08:30 +00:00
Jan Varga
f4a3bc258f Bug 1711848 - Add argument separation comments for QM_OR_ELSE(WARN|NOTE|LOG_VERBOSE)(_IF) uses; r=dom-storage-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D115465
2021-06-01 13:58:27 +00:00
Jan Varga
f7d0092e58 Bug 1711656 - Rename QM_OR_ELSE_LOG to QM_OR_ELSE_LOG_VERBOSE; r=dom-storage-reviewers,jstutte
Differential Revision: https://phabricator.services.mozilla.com/D115363
2021-06-01 12:12:27 +00:00
Jan Varga
2792c72140 Bug 1708643 - CACHE: Replace QM_OR_ELSE_(WARN|LOG) with QM_OR_ELSE_(WARN|LOG)_IF in places where the fallback needs to be called conditionally; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D115150
2021-05-30 11:08:02 +00:00
Jan Varga
52086b9801 Bug 1711181 - Change uses of ordinary orElse to QM_OR_ELSE_LOG; r=dom-storage-reviewers,jstutte
This is more consistent with other cases where we either use QM_OR_ELSE_WARN or
QM_OR_ELSE_NOTE. We will later change some uses of QM_OR_ELSE_LOG to
QM_OR_ELSE_LOG_IF. The switch from custom OrElseIf to Result::orElseIf will be
easier when we don't use OrElseIf directly.

This patch only changes uses of ordinary orElse introduced in bug 1701346.

Remaining uses will be handled in bug 1711180 (the ones that were missed in bug
1686191).

Differential Revision: https://phabricator.services.mozilla.com/D115055
2021-05-21 09:30:30 +00:00
Jan Varga
09996cc685 Bug 1709067 - CACHE: Remove module specific QM_TRY macros; r=dom-storage-reviewers,jstutte
Depends on D114080

Differential Revision: https://phabricator.services.mozilla.com/D114081
2021-05-03 19:44:39 +00:00
Jan Varga
729a24595d Bug 1701346 - CACHE: Add explanatory comments for some ordinary orElse uses; r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D113526
2021-04-28 07:33:55 +00:00
Jan Varga
cf5e9e7c32 Bug 1690326 - Follow-up fix for the ERROR_FILE_CORRUPT to NS_ERROR_FILE_FS_CORRUPTED mapping; r=jstutte
The code which depends on the old generic NS_ERROR_MODULE_WIN32 mapping needs
to be updated too.

Depends on D113505

Differential Revision: https://phabricator.services.mozilla.com/D113518
2021-04-28 07:33:54 +00:00
Jan Varga
dcb06f6d6d Bug 1706005 - Report failed DirectoryPaddingGet as a warning (instead of an error); r=dom-storage-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D113392
2021-04-27 07:12:23 +00:00
Jan Varga
604404dd23 Bug 1706350 - Follow-up cleanup for bug 1648399; r=dom-storage-reviewers,asuth
This patch addresses remaining review comments from
https://phabricator.services.mozilla.com/D81680.
It also adds missing origin initialization to the tests which was causing
unnecessary warnings during test execution.

Differential Revision: https://phabricator.services.mozilla.com/D112759
2021-04-21 13:55:04 +00:00
Tom Tung
abf9f74311 Bug 1655953 - Remove mutex lock for protecting the padding file; r=dom-workers-and-storage-reviewers,sg,asuth,janv
Depends on D81680

Differential Revision: https://phabricator.services.mozilla.com/D85279
2021-04-16 01:09:10 +00:00
Tom Tung
69065f48aa Bug 1647316 - Align the InitOrigin for Cache with other client's; r=dom-workers-and-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D80823
2021-04-16 01:09:09 +00:00
Jan Varga
4323e6df02 Bug 1686031 - Rename GroupAndOrigin to OriginMetadata; r=dom-storage-reviewers,sg
Differential Revision: https://phabricator.services.mozilla.com/D104970
2021-02-12 14:03:28 +00:00
Simon Giesecke
d3b3ad3a3d Bug 1690234 - Ignore ERROR_FILE_CORRUPT when calling BodyTraverseFiles from within CollectEachFile/ReduceUsageInfo. r=dom-workers-and-storage-reviewers,janv,asuth
Differential Revision: https://phabricator.services.mozilla.com/D103785
2021-02-12 09:14:21 +00:00
Simon Giesecke
26725b587f Bug 1687321 - Use GetDirEntryKind instead of IsDirectory when iterating over directory entries in dom/cache. r=dom-workers-and-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D103763
2021-02-08 13:15:50 +00:00
Simon Giesecke
4e33445ac3 Bug 1687254 - Skip directory entries that no longer exist in GetBodyUsage. r=dom-workers-and-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D102204
2021-01-21 15:33:04 +00:00
Simon Giesecke
b011d2e6fb Bug 1683828 - Use QM_TRY et al. in QuotaClient. r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D100770
2021-01-18 08:52:06 +00:00
Simon Giesecke
731e2bb3f2 Bug 1683828 - Use QM_TRY et al. in FileUtils and modernize signatures. r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D100320
2021-01-14 16:42:32 +00:00
Simon Giesecke
aa680355aa Bug 1679540 - Extract CollectEachFile function and use in quota manager and clients. r=dom-workers-and-storage-reviewers,ttung,janv
Differential Revision: https://phabricator.services.mozilla.com/D98075
2021-01-05 09:27:18 +00:00
Mihai Alexandru Michis
a4520f52a9 Backed out changeset 9ef5f1fe26e8 (bug 1679540) for causing Bug 1683863. a=backout 2020-12-22 17:00:34 +02:00
Simon Giesecke
0a86aba723 Bug 1679540 - Extract CollectEachFile function and use in quota manager and clients. r=dom-workers-and-storage-reviewers,ttung,janv
Differential Revision: https://phabricator.services.mozilla.com/D98075
2020-12-21 18:13:56 +00:00
Jan Varga
fe7c71a9e0 Bug 1680031 - Abort operations for given directory lock ids; r=dom-workers-and-storage-reviewers,sg
This patch changes the way how we abort operations when clearing of data is
requested. Instead of aborting all operations for given origin, we now abort
all operations for given directory locks which are blocking clearing of data.

Differential Revision: https://phabricator.services.mozilla.com/D98609
2020-12-09 08:13:44 +00:00
Jan Varga
ccea28442b Bug 1680031 - Introduce Client::AbortAllOperations; r=dom-workers-and-storage-reviewers,sg
Client::AbortOperations no longer supports the case when an empty origin string
is passed (which was used to abort all operations).

Differential Revision: https://phabricator.services.mozilla.com/D98344
2020-12-02 16:38:07 +00:00
Simon Giesecke
6f59efdcd5 Bug 1672369 - Record Cache API shutdown steps. r=dom-workers-and-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D94740
2020-11-30 13:04:23 +00:00
Simon Giesecke
257530e1da Bug 1672369 - Unify handling shutdown timeout of quota clients. r=dom-workers-and-storage-reviewers,ttung,janv
Differential Revision: https://phabricator.services.mozilla.com/D94318
2020-11-30 10:40:59 +00:00
Simon Giesecke
bafe1df218 Bug 1672369 - Pull up common ShutdownWorkThreads into QuotaClient. r=dom-workers-and-storage-reviewers,ttung,janv
Differential Revision: https://phabricator.services.mozilla.com/D94298
2020-11-26 09:20:03 +00:00
Simon Giesecke
3236acba9d Bug 1671369 - Change GetUsageForClient to return a UsageInfo. r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D93777
2020-11-17 13:17:24 +00:00
Simon Giesecke
dec6e1d21c Bug 1671369 - Change LockedDirectoryPaddingGet to return a Result and use CACHE_TRY. r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D93775
2020-11-17 09:07:03 +00:00
Simon Giesecke
a52d798cb2 Bug 1671369 - Change LockedDirectoryPaddingRestore to return a Result and use CACHE_TRY. r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D93774
2020-11-17 09:04:35 +00:00
Simon Giesecke
fe283bda0a Bug 1671369 - Change OpenDBConnection to return a Result. r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D93773
2020-11-17 09:04:33 +00:00
Simon Giesecke
669e845944 Bug 1671369 - Extract ReduceEach function from ReduceUsageInfo. r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D93772
2020-11-17 09:04:28 +00:00
Simon Giesecke
cbccc42eb2 Bug 1671369 - Extract ReduceUsageInfo function from GetBodyUsage and GetUsageForOriginInternal. r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D93771
2020-11-17 09:04:25 +00:00
Simon Giesecke
56ab947139 Bug 1671369 - Change GetBodyUsage to return a Result. r=dom-workers-and-storage-reviewers,ttung
Differential Revision: https://phabricator.services.mozilla.com/D93769
2020-11-17 09:04:23 +00:00
Simon Giesecke
923504afa0 Bug 1671369 - Move anonymous namespace inside mozilla::dom::cache. r=dom-workers-and-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D93767
2020-11-17 09:04:21 +00:00
Simon Giesecke
dcd436349e Bug 1671369 - Change LockedGetPaddingSizeFromDB to return a Result. r=dom-workers-and-storage-reviewers,janv
Differential Revision: https://phabricator.services.mozilla.com/D93766
2020-11-17 09:04:18 +00:00
Simon Giesecke
ef9d87ac52 Bug 1671369 - Use CACHE_TRY in CacheQuotaClient::GetUsageForOriginInternal. r=ttung
Differential Revision: https://phabricator.services.mozilla.com/D93662
2020-11-17 09:04:16 +00:00
Sylvestre Ledru
fde06f6d21 Bug 1674637 - Use nested namespaces in dom/ r=sg,andi
Also add some missing namespace qualifications

Done with:
./mach static-analysis check --checks="-*,modernize-concat-nested-namespaces" --fix dom/
./mach clang-format -p $(hg status dom/|grep ^M|awk '{print $2}')

Differential Revision: https://phabricator.services.mozilla.com/D95456
2020-11-04 17:04:01 +00:00
Butkovits Atila
964cca3198 Backed out changeset c0adbf7522dc (bug 1674637) for bustage on GMPParent.cpp. CLOSED TREE 2020-11-04 10:54:36 +02:00