aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/script_thread.rs')
-rw-r--r--components/script/script_thread.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index dbc4f0fb444..5aec6a8a57d 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -51,6 +51,7 @@ use crate::dom::event::{Event, EventBubbles, EventCancelable};
use crate::dom::globalscope::GlobalScope;
use crate::dom::htmlanchorelement::HTMLAnchorElement;
use crate::dom::htmliframeelement::{HTMLIFrameElement, NavigationType};
+use crate::dom::mediasession::MediaSession;
use crate::dom::mutationobserver::MutationObserver;
use crate::dom::node::{
from_untrusted_node_address, window_from_node, Node, NodeDamage, ShadowIncluding,
@@ -696,6 +697,11 @@ pub struct ScriptThread {
/// Code is running as a consequence of a user interaction
is_user_interacting: Cell<bool>,
+
+ /// The MediaSessions registered for this Pipeline, if any.
+ /// There can only be one active MediaSession. The constellation
+ /// has the PipelineId of the active MediaSession, if any.
+ media_sessions: DomRefCell<HashMap<PipelineId, Dom<MediaSession>>>,
}
/// In the event of thread panic, all data on the stack runs its destructor. However, there
@@ -1365,6 +1371,7 @@ impl ScriptThread {
node_ids: Default::default(),
is_user_interacting: Cell::new(false),
+ media_sessions: DomRefCell::new(HashMap::new()),
}
}
@@ -3948,6 +3955,26 @@ impl ScriptThread {
globals,
)
}
+
+ pub fn register_media_session(media_session: &MediaSession, pipeline_id: PipelineId) {
+ SCRIPT_THREAD_ROOT.with(|root| {
+ let script_thread = unsafe { &*root.get().unwrap() };
+ script_thread
+ .media_sessions
+ .borrow_mut()
+ .insert(pipeline_id, Dom::from_ref(media_session));
+ })
+ }
+
+ pub fn remove_media_session(pipeline_id: PipelineId) {
+ SCRIPT_THREAD_ROOT.with(|root| {
+ let script_thread = unsafe { &*root.get().unwrap() };
+ script_thread
+ .media_sessions
+ .borrow_mut()
+ .remove(&pipeline_id);
+ })
+ }
}
impl Drop for ScriptThread {