Explorar o código

WebContent: Change the cookie setting IPC to be synchronous

Considering an operation like the following:

    document.cookie = "cookie=value";
    const value = document.cookie;

If the IPC for the cookie setter is asynchronous, the getter can execute
while the browser/SQLServer processes are still handling the setter.
This is often seen when hammering the document with cookie requests.
Timothy Flynn hai 1 ano
pai
achega
a4f862a869

+ 5 - 1
Userland/Services/WebContent/PageClient.cpp

@@ -504,7 +504,11 @@ ByteString PageClient::page_did_request_cookie(const URL& url, Web::Cookie::Sour
 
 void PageClient::page_did_set_cookie(const URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source)
 {
-    client().async_did_set_cookie(url, cookie, static_cast<u8>(source));
+    auto response = client().send_sync_but_allow_failure<Messages::WebContentClient::DidSetCookie>(url, cookie, static_cast<u8>(source));
+    if (!response) {
+        dbgln("WebContent client disconnected during DidSetCookie. Exiting peacefully.");
+        exit(0);
+    }
 }
 
 void PageClient::page_did_update_cookie(Web::Cookie::Cookie cookie)

+ 1 - 1
Userland/Services/WebContent/WebContentClient.ipc

@@ -54,7 +54,7 @@ endpoint WebContentClient
     did_request_all_cookies(URL url) => (Vector<Web::Cookie::Cookie> cookies)
     did_request_named_cookie(URL url, ByteString name) => (Optional<Web::Cookie::Cookie> cookie)
     did_request_cookie(URL url, u8 source) => (ByteString cookie)
-    did_set_cookie(URL url, Web::Cookie::ParsedCookie cookie, u8 source) =|
+    did_set_cookie(URL url, Web::Cookie::ParsedCookie cookie, u8 source) => ()
     did_update_cookie(Web::Cookie::Cookie cookie) =|
     did_update_resource_count(i32 count_waiting) =|
     did_request_new_tab(Web::HTML::ActivateTab activate_tab) => (String handle)