diff options
Diffstat (limited to 'components/script/dom/bindings/refcounted.rs')
-rw-r--r-- | components/script/dom/bindings/refcounted.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/components/script/dom/bindings/refcounted.rs b/components/script/dom/bindings/refcounted.rs index 97a181f1c2f..d3f55012534 100644 --- a/components/script/dom/bindings/refcounted.rs +++ b/components/script/dom/bindings/refcounted.rs @@ -47,10 +47,10 @@ mod dummy { use std::rc::Rc; use super::LiveDOMReferences; - thread_local!(pub static LIVE_REFERENCES: Rc<RefCell<Option<LiveDOMReferences>>> = + thread_local!(pub(crate) static LIVE_REFERENCES: Rc<RefCell<Option<LiveDOMReferences>>> = Rc::new(RefCell::new(None))); } -pub use self::dummy::LIVE_REFERENCES; +pub(crate) use self::dummy::LIVE_REFERENCES; /// A pointer to a Rust DOM object that needs to be destroyed. #[derive(MallocSizeOf)] @@ -84,7 +84,7 @@ impl TrustedPromise { /// be prevented from being GCed for the duration of the resulting `TrustedPromise` object's /// lifetime. #[allow(crown::unrooted_must_root)] - pub fn new(promise: Rc<Promise>) -> TrustedPromise { + pub(crate) fn new(promise: Rc<Promise>) -> TrustedPromise { LIVE_REFERENCES.with(|r| { let r = r.borrow(); let live_references = r.as_ref().unwrap(); @@ -100,7 +100,7 @@ impl TrustedPromise { /// Obtain a usable DOM Promise from a pinned `TrustedPromise` value. Fails if used on /// a different thread than the original value from which this `TrustedPromise` was /// obtained. - pub fn root(self) -> Rc<Promise> { + pub(crate) fn root(self) -> Rc<Promise> { LIVE_REFERENCES.with(|r| { let r = r.borrow(); let live_references = r.as_ref().unwrap(); @@ -134,7 +134,7 @@ impl TrustedPromise { /// A task which will reject the promise. #[allow(crown::unrooted_must_root)] - pub fn reject_task(self, error: Error) -> impl TaskOnce { + pub(crate) fn reject_task(self, error: Error) -> impl TaskOnce { let this = self; task!(reject_promise: move || { debug!("Rejecting promise."); @@ -144,7 +144,7 @@ impl TrustedPromise { /// A task which will resolve the promise. #[allow(crown::unrooted_must_root)] - pub fn resolve_task<T>(self, value: T) -> impl TaskOnce + pub(crate) fn resolve_task<T>(self, value: T) -> impl TaskOnce where T: ToJSValConvertible + Send, { @@ -162,7 +162,7 @@ impl TrustedPromise { /// `Trusted<T>` instance. #[crown::unrooted_must_root_lint::allow_unrooted_interior] #[derive(MallocSizeOf)] -pub struct Trusted<T: DomObject> { +pub(crate) struct Trusted<T: DomObject> { /// A pointer to the Rust DOM object of type T, but void to allow /// sending `Trusted<T>` between threads, regardless of T's sendability. #[conditional_malloc_size_of] @@ -178,7 +178,7 @@ impl<T: DomObject> Trusted<T> { /// Create a new `Trusted<T>` instance from an existing DOM pointer. The DOM object will /// be prevented from being GCed for the duration of the resulting `Trusted<T>` object's /// lifetime. - pub fn new(ptr: &T) -> Trusted<T> { + pub(crate) fn new(ptr: &T) -> Trusted<T> { fn add_live_reference( ptr: *const libc::c_void, ) -> (Arc<TrustedReference>, *const LiveDOMReferences) { @@ -201,7 +201,7 @@ impl<T: DomObject> Trusted<T> { /// Obtain a usable DOM pointer from a pinned `Trusted<T>` value. Fails if used on /// a different thread than the original value from which this `Trusted<T>` was /// obtained. - pub fn root(&self) -> DomRoot<T> { + pub(crate) fn root(&self) -> DomRoot<T> { fn validate(owner_thread: *const LiveDOMReferences) { assert!(LIVE_REFERENCES.with(|r| { let r = r.borrow(); @@ -227,7 +227,7 @@ impl<T: DomObject> Clone for Trusted<T> { /// The set of live, pinned DOM objects that are currently prevented /// from being garbage collected due to outstanding references. #[allow(crown::unrooted_must_root)] -pub struct LiveDOMReferences { +pub(crate) struct LiveDOMReferences { // keyed on pointer to Rust DOM object reflectable_table: RefCell<HashMap<*const libc::c_void, Weak<TrustedReference>>>, promise_table: RefCell<HashMap<*const Promise, Vec<Rc<Promise>>>>, @@ -235,7 +235,7 @@ pub struct LiveDOMReferences { impl LiveDOMReferences { /// Set up the thread-local data required for storing the outstanding DOM references. - pub fn initialize() { + pub(crate) fn initialize() { LIVE_REFERENCES.with(|r| { *r.borrow_mut() = Some(LiveDOMReferences { reflectable_table: RefCell::new(HashMap::new()), @@ -244,7 +244,7 @@ impl LiveDOMReferences { }); } - pub fn destruct() { + pub(crate) fn destruct() { LIVE_REFERENCES.with(|r| { *r.borrow_mut() = None; }); @@ -302,7 +302,7 @@ fn remove_nulls<K: Eq + Hash + Clone, V>(table: &mut HashMap<K, Weak<V>>) { /// A JSTraceDataOp for tracing reflectors held in LIVE_REFERENCES #[allow(crown::unrooted_must_root)] -pub unsafe fn trace_refcounted_objects(tracer: *mut JSTracer) { +pub(crate) unsafe fn trace_refcounted_objects(tracer: *mut JSTracer) { trace!("tracing live refcounted references"); LIVE_REFERENCES.with(|r| { let r = r.borrow(); |