Bug 1614394 - Cherry-pick some servo-only changes to malloc_size_of.

Differential Revision: https://phabricator.services.mozilla.com/D62301

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2020-02-10 17:32:09 +00:00
parent dd3ef574ef
commit 741ec04a23
2 changed files with 20 additions and 0 deletions

View File

@ -22,9 +22,12 @@ servo = [
"webrender_api",
"xml5ever",
"content-security-policy",
"uuid",
"accountable-refcell",
]
[dependencies]
accountable-refcell = { version = "0.2.0", optional = true }
app_units = "0.7"
content-security-policy = {version = "0.3.0", features = ["serde"], optional = true}
crossbeam-channel = { version = "0.3", optional = true }
@ -47,3 +50,4 @@ url = { version = "2.0", optional = true }
webrender_api = { git = "https://github.com/servo/webrender", optional = true }
xml5ever = { version = "0.16", optional = true }
void = "1.0.2"
uuid = {version = "0.8", features = ["v4"], optional = true}

View File

@ -46,6 +46,8 @@
//! Note: WebRender has a reduced fork of this crate, so that we can avoid
//! publishing this crate on crates.io.
#[cfg(feature = "servo")]
extern crate accountable_refcell;
extern crate app_units;
#[cfg(feature = "servo")]
extern crate content_security_policy;
@ -75,6 +77,8 @@ extern crate thin_slice;
extern crate time;
#[cfg(feature = "url")]
extern crate url;
#[cfg(feature = "servo")]
extern crate uuid;
extern crate void;
#[cfg(feature = "webrender_api")]
extern crate webrender_api;
@ -90,6 +94,8 @@ use std::mem::size_of;
use std::ops::Range;
use std::ops::{Deref, DerefMut};
use std::os::raw::c_void;
#[cfg(feature = "servo")]
use uuid::Uuid;
use void::Void;
/// A C function that takes a pointer to a heap allocation and returns its size.
@ -840,6 +846,9 @@ malloc_size_of_is_0!(cssparser::RGBA, cssparser::TokenSerializationType);
#[cfg(feature = "servo")]
malloc_size_of_is_0!(csp::Destination);
#[cfg(feature = "servo")]
malloc_size_of_is_0!(Uuid);
#[cfg(feature = "url")]
impl MallocSizeOf for url::Host {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
@ -963,3 +972,10 @@ impl<T: MallocSizeOf> DerefMut for Measurable<T> {
&mut self.0
}
}
#[cfg(feature = "servo")]
impl<T: MallocSizeOf> MallocSizeOf for accountable_refcell::RefCell<T> {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize {
self.borrow().size_of(ops)
}
}