Skip to content

Implement async version for cookie APIs#44708

Open
longvatrong111 wants to merge 2 commits into
servo:mainfrom
longvatrong111:cookie-api-async
Open

Implement async version for cookie APIs#44708
longvatrong111 wants to merge 2 commits into
servo:mainfrom
longvatrong111:cookie-api-async

Conversation

@longvatrong111
Copy link
Copy Markdown
Contributor

Follow up to #44166 (comment), this PR adds an optional callback to current synchronous APIs to allow asynchronous operation.

Test: existing unit tests of SiteDataManager.

Add an optional callback to current synchronous APIs to allow asynchronous operation.

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label May 4, 2026
}

/// Asynchronously returns the cookies for the domain associated with the given [`Url`].
pub fn cookies_for_url_async(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this makes every sync caller do .unwrap() and every async caller ignore a returned Option, api is little bit awkward now, I would prefer keeping separate methods.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also noticed and had some same thoughts. Maybe for only get cookie, it's more reasonable to keep 2 separate methods.
Let's wait for the opinions of others.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Taym95 Seem like there is no more review. I've updated thank you.

}

pub fn clear_cookies_async(&self, id: CookieOperationId) {
let _ = self
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happen when one send fails, will the callback never fires?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I think the callback is like onSuccess.

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
@longvatrong111 longvatrong111 requested a review from Taym95 May 14, 2026 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-awaiting-review There is new code that needs to be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants