-
Notifications
You must be signed in to change notification settings - Fork 473
Issue #9838: Introduce CreditCardValidationDelegate and implement onCreditCardSave in GeckoCreditCardsAddressesStorageDelegate #9875
Conversation
Codecov Report
@@ Coverage Diff @@
## main #9875 +/- ##
============================================
- Coverage 74.15% 66.67% -7.48%
+ Complexity 6240 768 -5472
============================================
Files 835 119 -716
Lines 31562 3712 -27850
Branches 5268 590 -4678
============================================
- Hits 23405 2475 -20930
+ Misses 5465 903 -4562
+ Partials 2692 334 -2358
Continue to review full report at Codecov.
|
78b9e18
to
3932be0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty close! A few questions throughout, and some specific suggestions.
...cept/storage/src/main/java/mozilla/components/concept/storage/CreditCardsAddressesStorage.kt
Outdated
Show resolved
Hide resolved
data class CanBeUpdated(val foundCreditCard: CreditCard) : Result() | ||
|
||
/** | ||
* The [CreditCard] cannot be saved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"saved or updated", right?
Also - do we get anything from the API we can use as a "reason" here?
...cept/storage/src/main/java/mozilla/components/concept/storage/CreditCardsAddressesStorage.kt
Outdated
Show resolved
Hide resolved
...cept/storage/src/main/java/mozilla/components/concept/storage/CreditCardsAddressesStorage.kt
Outdated
Show resolved
Hide resolved
...rc/main/java/mozilla/components/service/sync/autofill/AutofillCreditCardsAddressesStorage.kt
Outdated
Show resolved
Hide resolved
...in/java/mozilla/components/service/sync/autofill/GeckoCreditCardsAddressesStorageDelegate.kt
Outdated
Show resolved
Hide resolved
) | ||
} | ||
is CreditCardValidationDelegate.Result.Error -> { | ||
// Do nothing since an error occurred and the credit card cannot be saved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not return any results to GV?
@@ -8,8 +8,10 @@ import kotlinx.coroutines.CoroutineScope | |||
import kotlinx.coroutines.Deferred | |||
import kotlinx.coroutines.Dispatchers | |||
import kotlinx.coroutines.async | |||
import kotlinx.coroutines.launch |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this class should probably be called DefaultCreditCardsAddressesStorageDelegate
if there's nothing gecko-specific going on here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda of Gecko specific. It is only consumed by the GeckoAutocompleteStorageDelegate. Its respective Login counterpart also uses the Gecko prefix. If we want to rename this, I would suggest we do it for both, and note that it will be a breaking change.
@@ -38,6 +40,22 @@ class GeckoCreditCardsAddressesStorageDelegate( | |||
} | |||
|
|||
override fun onCreditCardSave(creditCard: CreditCard) { | |||
TODO("Not yet implemented") | |||
val validationDelegate = DefaultCreditCardValidationDelegate(storage) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this method is called in a quick succession (and you're not in control of its consumers, so you don't know if it'll be called in this fashion or not), it's possible that one of the add/update calls to storage below will fail (and we'll crash) with a SQL_LOCKED exception coming out of storage.
That's because sqlite doesn't support consequent writers, and within AutofillCreditCardsAddressesStorage
you only have a single connection instance to the storage that's shared for both reading and writing. And, the coroutineContext
use there is defined over Dispatchers.IO
. That means you call addCreditCard
and then very quickly an updateCreditCard
while first operation is still running, it's possible for things to crash - we'll end up using a different thread for the update operation, and will try to talk to the storage while it's busy.
For comparison, PlacesStorage
defines two scopes - readScope
and writeScope
. The former uses a thread pool to make sure reads are quick, while the latter uses a single threaded executor to make sure write operations are sequential and never overlap.
Just to avoid this class of errors and not have to worry about what's possible here and what's not, this is the kind of split I'd introduce here as well.
|
||
assertEquals(Result.CanBeCreated, result) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note how your tests assume that weird/bad things won't happen (they don't test for them). See my comment in the validate method.
...rc/main/java/mozilla/components/service/sync/autofill/DefaultCreditCardValidationDelegate.kt
Outdated
Show resolved
Hide resolved
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
1 similar comment
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
This pull request has conflicts when rebasing. Could you fix it @gabrielluong? 🙏 |
Looking through old PRs... Is this something we still want to get landed? |
@pocmo yup, definitely worth landing this - and the pieces on the GV side to call into this delegate. I'll rebase/clean this up and will land it. |
…of InputResultDetail We need to wait until having a response from GeckoView on how it handled the touch only after which we'll know whether to animate the toolbar or not. The edgecase scenario of having pull to refresh enabled even before having a response from GeckoView will still work because "canOverscrollTop()" only checks for the touch to not be handled by the browser to pan the page.
The previous implementation was affected by the fact that the class has 3 integer properties, all with values [0..4] (-1 was added recently) and it would just add those value to compute the hashcode. Collisions were a given. By using decimal places for each property the new implementation should avoid collisions while allowing for all the other expected guarantees.
This commented method seems to be a leftover from the previous refactoring. "behavior.forceExpand(..)" now calls "expandWithAnimation" for which we already have a test at line 450.
This version of A-S included breaking changes around the history metadata API, which this patch resolves.
…lla-mobile#10913) * Ensure we notice and repair a missing or expired push endpoint. The core problem is that the device constellation's observer is registered after we've updated the devices, so the code that checks if re-subscribing is necessary is never hit. The easiest way of fixing this was to move the `refreshDevices` call to the account state state-machine, rather than the authentication state-machine, meaning we can ensure the `onAuthenticated` notification is delivered before we refresh the devices. Note that I also removed the special-case for "SEND_TAB" devices - push is also used for account-related notifications, such as being disconnected. * Address CI failures (hopefully!) * Update comments about push renewal * Tweak suggested by Grisha for when to call refreshDevices * More CI failures Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
…ozilla-mobile#9827) * Accounts: Make webchannel work with custom fxa server * Accounts: Send overrideFxAServer message only to custom fxa server * Accounts: make webchannel background message name constant Co-authored-by: Grisha Kruglov <gkruglov@mozilla.com>
Ummm. Yeah, that didn't go quite as planned... Going to close this in favour of #10964 |
Fixes #9838
CreditCardValidationDelegate
and a default implementation inDefaultCreditCardValidationDelegate
wipeLocal()
toCreditCardsAddressesStorage
to clear out local state in between testsonCreditCardSave
inGeckoCreditCardsAddressesStorageDelegate
Pull Request checklist
After merge