mirror of
https://github.com/servo/servo.git
synced 2025-09-29 16:19:14 +01:00
script: initial CookieStore implementation (#37968)
This is a first draft at implementing the required infrastructure for CookieStore, which requires setting up IPC between script and the resource thread to allow for async/"in parallel" handling of cookie changes that have a promise API. Cookie Store also will need to receive change events when cookies for a url are changed so the architecture needs to support that. Expect this PR to be reworked once the architecture becomes more settled, cookie change events will be implemented in follow up PRs Testing: WPT tests exist for this API Part of #37674 --------- Signed-off-by: Sebastian C <sebsebmc@gmail.com>
This commit is contained in:
parent
a75f3fd09b
commit
b869b7eb96
35 changed files with 917 additions and 305 deletions
|
@ -10,7 +10,7 @@ use std::sync::{LazyLock, OnceLock};
|
|||
use std::thread::{self, JoinHandle};
|
||||
|
||||
use base::cross_process_instant::CrossProcessInstant;
|
||||
use base::id::HistoryStateId;
|
||||
use base::id::{CookieStoreId, HistoryStateId};
|
||||
use content_security_policy::{self as csp};
|
||||
use cookie::Cookie;
|
||||
use crossbeam_channel::{Receiver, Sender, unbounded};
|
||||
|
@ -526,6 +526,12 @@ pub enum CoreResourceMsg {
|
|||
SetCookieForUrl(ServoUrl, Serde<Cookie<'static>>, CookieSource),
|
||||
/// Store a set of cookies for a given originating URL
|
||||
SetCookiesForUrl(ServoUrl, Vec<Serde<Cookie<'static>>>, CookieSource),
|
||||
SetCookieForUrlAsync(
|
||||
CookieStoreId,
|
||||
ServoUrl,
|
||||
Serde<Cookie<'static>>,
|
||||
CookieSource,
|
||||
),
|
||||
/// Retrieve the stored cookies for a given URL
|
||||
GetCookiesForUrl(ServoUrl, IpcSender<Option<String>>, CookieSource),
|
||||
/// Get a cookie by name for a given originating URL
|
||||
|
@ -534,8 +540,13 @@ pub enum CoreResourceMsg {
|
|||
IpcSender<Vec<Serde<Cookie<'static>>>>,
|
||||
CookieSource,
|
||||
),
|
||||
GetCookieDataForUrlAsync(CookieStoreId, ServoUrl, Option<String>),
|
||||
GetAllCookieDataForUrlAsync(CookieStoreId, ServoUrl, Option<String>),
|
||||
DeleteCookies(ServoUrl),
|
||||
DeleteCookie(ServoUrl, String),
|
||||
DeleteCookieAsync(CookieStoreId, ServoUrl, String),
|
||||
NewCookieListener(CookieStoreId, IpcSender<CookieAsyncResponse>, ServoUrl),
|
||||
RemoveCookieListener(CookieStoreId),
|
||||
/// Get a history state by a given history state id
|
||||
GetHistoryState(HistoryStateId, IpcSender<Option<Vec<u8>>>),
|
||||
/// Set a history state for a given history state id
|
||||
|
@ -976,6 +987,26 @@ pub enum CookieSource {
|
|||
NonHTTP,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct CookieChange {
|
||||
changed: Vec<Serde<Cookie<'static>>>,
|
||||
deleted: Vec<Serde<Cookie<'static>>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub enum CookieData {
|
||||
Change(CookieChange),
|
||||
Get(Option<Serde<Cookie<'static>>>),
|
||||
GetAll(Vec<Serde<Cookie<'static>>>),
|
||||
Set(Result<(), ()>),
|
||||
Delete(Result<(), ()>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
pub struct CookieAsyncResponse {
|
||||
pub data: CookieData,
|
||||
}
|
||||
|
||||
/// Network errors that have to be exported out of the loaders
|
||||
#[derive(Clone, Debug, Deserialize, Eq, MallocSizeOf, PartialEq, Serialize)]
|
||||
pub enum NetworkError {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue