aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/script_thread.rs
diff options
context:
space:
mode:
authorFernando Jiménez Moreno <ferjmoreno@gmail.com>2019-10-04 12:27:16 +0200
committerFernando Jiménez Moreno <ferjmoreno@gmail.com>2019-11-20 13:32:10 +0100
commitf8246801ba47f66d205dae142d4d3498a304220e (patch)
tree41e2e2f0a95d9565262c4907308c773c6ae9e70f /components/script/script_thread.rs
parent1ab65005ae4d1925de357f42212bc2aaa972e77e (diff)
downloadservo-f8246801ba47f66d205dae142d4d3498a304220e.tar.gz
servo-f8246801ba47f66d205dae142d4d3498a304220e.zip
MediaSession registration
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 {