mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
This patch exposes a servo internal DOM API that is only made available to about: pages on the navigator object to request memory reports. The about:memory page itself is loaded like other html resources (eg. bad cert, net error) and makes use of this new API. On the implementation side, notable changes: - components/script/routed_promise.rs abstracts the setup used to fulfill a promise when the work needs to be routed through the constellation. The goal is to migrate other similar promise APIs in followup (eg. dom/webgpu/gpu.rs, bluetooth.rs). - a new message is added to request a report from the memory reporter, and the memory reporter creates a json representation of the set of memory reports. - the post-processing of memory reports is done in Javascript in the about-memory.html page, providing the same results as the current Rust code that outputs to stdout. We can decide later if we want to remove the current output. Signed-off-by: webbeef <me@webbeef.org>
58 lines
2.5 KiB
Rust
58 lines
2.5 KiB
Rust
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
use std::path::PathBuf;
|
|
|
|
use servo::resources::{Resource, ResourceReaderMethods};
|
|
|
|
pub(crate) struct ResourceReaderInstance;
|
|
|
|
impl ResourceReaderInstance {
|
|
pub(crate) fn new() -> ResourceReaderInstance {
|
|
ResourceReaderInstance
|
|
}
|
|
}
|
|
|
|
impl ResourceReaderMethods for ResourceReaderInstance {
|
|
fn read(&self, res: Resource) -> Vec<u8> {
|
|
Vec::from(match res {
|
|
Resource::HstsPreloadList => {
|
|
&include_bytes!("../../../../resources/hsts_preload.json")[..]
|
|
},
|
|
Resource::BadCertHTML => &include_bytes!("../../../../resources/badcert.html")[..],
|
|
Resource::NetErrorHTML => &include_bytes!("../../../../resources/neterror.html")[..],
|
|
Resource::UserAgentCSS => &include_bytes!("../../../../resources/user-agent.css")[..],
|
|
Resource::ServoCSS => &include_bytes!("../../../../resources/servo.css")[..],
|
|
Resource::PresentationalHintsCSS => {
|
|
&include_bytes!("../../../../resources/presentational-hints.css")[..]
|
|
},
|
|
Resource::QuirksModeCSS => &include_bytes!("../../../../resources/quirks-mode.css")[..],
|
|
Resource::RippyPNG => &include_bytes!("../../../../resources/rippy.png")[..],
|
|
Resource::DomainList => &include_bytes!("../../../../resources/public_domains.txt")[..],
|
|
Resource::BluetoothBlocklist => {
|
|
&include_bytes!("../../../../resources/gatt_blocklist.txt")[..]
|
|
},
|
|
Resource::MediaControlsCSS => {
|
|
&include_bytes!("../../../../resources/media-controls.css")[..]
|
|
},
|
|
Resource::MediaControlsJS => {
|
|
&include_bytes!("../../../../resources/media-controls.js")[..]
|
|
},
|
|
Resource::CrashHTML => &include_bytes!("../../../../resources/crash.html")[..],
|
|
Resource::DirectoryListingHTML => {
|
|
&include_bytes!("../../../../resources/directory-listing.html")[..]
|
|
},
|
|
Resource::AboutMemoryHTML => {
|
|
&include_bytes!("../../../../resources/about-memory.html")[..]
|
|
},
|
|
})
|
|
}
|
|
|
|
fn sandbox_access_files(&self) -> Vec<PathBuf> {
|
|
vec![]
|
|
}
|
|
|
|
fn sandbox_access_files_dirs(&self) -> Vec<PathBuf> {
|
|
vec![]
|
|
}
|
|
}
|