servo/components/net
Martin Robinson 312cf0df08
script: Create a CrossProcessInstant to enable serializable monotonic time (#33282)
Up until now, Servo was using a very old version of time to get a
cross-process monotonic timestamp (using `time::precise_time_ns()`).
This change replaces the usage of old time with a new serializable
monotonic time called `CrossProcessInstant` and uses it where `u64`
timestamps were stored before. The standard library doesn't provide this
functionality because it isn't something you can do reliably on all
platforms. The idea is that we do our best and then fall back
gracefully.

This is a big change, because Servo was using `u64` timestamps all over
the place some as raw values taken from `time::precise_time_ns()` and
some as relative offsets from the "navigation start," which is a concept
similar to DOM's `timeOrigin` (but not exactly the same). It's very
difficult to fix this situation without fixing it everywhere as the
`Instant` concept is supposed to be opaque. The good thing is that this
change clears up all ambiguity when passing times as a `time::Duration`
is unit agnostic and a `CrossProcessInstant` represents an absolute
moment in time.

The `time` version of `Duration` is used because it can both be negative
and is also serializable.

Good things:
 - No need too pass around `time` and `time_precise` any longer.
   `CrossProcessInstant` is also precise and monotonic.
 - The distinction between a time that is unset or at `0` (at some kind
   of timer epoch) is now gone.

There still a lot of work to do to clean up timing, but this is the
first step. In general, I've tried to preserve existing behavior, even
when not spec compliant, as much as possible. I plan to submit followup
PRs fixing some of the issues I've noticed.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
2024-09-05 18:50:09 +00:00
..
fetch net: Stop using legacy time in the HTTP and CORS caches (#33259) 2024-08-30 12:54:02 +00:00
protocols make protocol handlers registrable (#33104) 2024-08-22 04:11:16 +00:00
tests Make all platforms use a delay during cookie tests. (#33279) 2024-09-01 20:07:46 +00:00
async_runtime.rs Replace the lazy_static crate with std::sync::LazyLock in components/net (#33046) 2024-08-14 12:15:55 +00:00
Cargo.toml net: Stop using both versions of the time crate in the cookie code (#33260) 2024-08-30 17:15:47 +00:00
connector.rs Net: fold websocket and http tokio runtime into one (#31771) 2024-03-21 06:13:03 +00:00
cookie.rs net: Stop using both versions of the time crate in the cookie code (#33260) 2024-08-30 17:15:47 +00:00
cookie_storage.rs net: Stop using both versions of the time crate in the cookie code (#33260) 2024-08-30 17:15:47 +00:00
decoder.rs Fix warnings after latest rust upgrade (#33043) 2024-08-14 07:00:16 +00:00
filemanager_thread.rs clippy: Allow too_many_arguments for existing functions (#31974) 2024-04-02 12:50:45 +00:00
hosts.rs Replace the lazy_static crate with std::sync::LazyLock in components/net (#33046) 2024-08-14 12:15:55 +00:00
hsts.rs clippy: fix warnings in components/net (#31564) 2024-03-10 15:34:16 +00:00
http_cache.rs net: Stop using legacy time in the HTTP and CORS caches (#33259) 2024-08-30 12:54:02 +00:00
http_loader.rs script: Create a CrossProcessInstant to enable serializable monotonic time (#33282) 2024-09-05 18:50:09 +00:00
image_cache.rs compositor: Move WebRender-ish messages and types to webrender_traits (#32315) 2024-05-20 10:35:18 +00:00
lib.rs make protocol handlers registrable (#33104) 2024-08-22 04:11:16 +00:00
local_directory_listing.rs clippy: Fix a bunch of warnings in script (#32680) 2024-07-04 11:40:23 +00:00
mime_classifier.rs clippy: Fix a bunch of warnings in script (#32680) 2024-07-04 11:40:23 +00:00
resource_thread.rs make protocol handlers registrable (#33104) 2024-08-22 04:11:16 +00:00
storage_thread.rs clippy: fix some leftover warnings in components/net (#32476) 2024-06-11 17:50:21 +00:00
subresource_integrity.rs clippy: Fix warnings in components/net (#31626) 2024-03-13 09:40:04 +00:00
websocket_loader.rs dependencies: Upgrade cookie and rename Servo's Cookie to ServoCookie (#32861) 2024-07-26 16:13:39 +00:00