-
Notifications
You must be signed in to change notification settings - Fork 893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cached guardian's subscriber credentials #15702
Conversation
e8de062
to
e4b88c9
Compare
e4b88c9
to
6bfe394
Compare
6bfe394
to
4e3573e
Compare
5511339
to
c9afbcf
Compare
#else | ||
GetBraveVPNConnectionAPI()->SetSkusCredential(skus_credential_); | ||
if (subscriber_credential == kTokenNoLongerValid) { |
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.
@spylogsster Curious kTokenNoLongerValid
is only effective on desktop?
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.
I did not check on mobile, maybe @deeppandya can help?
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.
Code is consistent with before at least - so if it was used on mobile, it's continuing to be used 👍 And for expired case, we default to showing in-app-purchase again on mobile
GetBraveVPNPaymentsEnv(GetCurrentEnvironment())); | ||
// Caller can get valid subscriber credential only in purchased state. | ||
// Otherwise, false is passed to |callback| as success param. | ||
std::move(callback).Run(::brave_vpn::GetSubscriberCredential(local_prefs_), |
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.
@deeppandya @bsclifton , As we cache subscriber credential in local state, we can return subscriber credential to caller directly. Previously, we fetch subscriber credential whenever this method is called with stored skus_credential_
.
As this PR stores subscriber credential in local state with its expiration date, we don't refetch subscriber credential if expiration date is not passed. So, most of ReloadPurchasedState()
will be no-op.
Previously, skus subscriber credential is fetched on every android app open and maybe it has sufficient expiration time because ReloadPurchasedState()
is called on app open.
One behavioral change from this PR for android is, subscriber credential is not refreshed on every app open.
Instead, stored credential is reused if not expired. and maybe this could affect on Android?
Caller will got false
as a success
param when stored subscriber credential is already expired.
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.
@deeppandya I think we don't need to worry about expiration with this background refreshing - 5c17a6c
@@ -743,6 +749,36 @@ void BraveVpnService::OnGetSubscriberCredentialV12( | |||
#endif | |||
} | |||
|
|||
void BraveVpnService::ScheduleSubscriberCredentialRefresh() { |
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.
@deeppandya With this background refreshing, BraveVpnService
could use valid subscriber credential on Android and Desktop.
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 great and might solve the expiration problem for iOS too
fix brave/brave-browser#26254 With this caching, we only need to ask skus credentials when subscriber credential is expired. and we only need to care about profile credentials during the connecting.
f1c47de
to
5c17a6c
Compare
Timer for getting new subscriber credential will be fired when current credential is expired.
5c17a6c
to
9ab1d10
Compare
and resolved some review comments.
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 working great! Tested a few scenarios (submitting ticket, changing servers). Verified code is persisting to local storage. And code looks great! This should fix Android as well as Desktop
fix brave/brave-browser#26254
With this caching, we only need to ask skus credentials when subscriber credential is expired.
Resolves
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
npm run test brave_unit_tests -- --filter=*VPN*