Changeset 185270 in webkit
- Timestamp:
- Jun 5, 2015 3:33:23 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r185269 r185270 1 2015-06-05 Matt Rajca <mrajca@apple.com> 2 3 MediaSessions should keep track of their participating media elements. 4 https://bugs.webkit.org/show_bug.cgi?id=145703 5 6 Reviewed by Eric Carlson. 7 8 * Modules/mediasession/MediaSession.cpp: 9 (WebCore::MediaSession::addMediaElement): Add the given media element to the media session. 10 (WebCore::MediaSession::removeMediaElement): Remove the given media element from the media session. 11 (WebCore::MediaSession::activeParticipatingElements): Dynamically build a vector of actively-playing media 12 elements. 13 * Modules/mediasession/MediaSession.h: 14 * html/HTMLMediaElement.cpp: 15 (WebCore::HTMLMediaElement::~HTMLMediaElement): Ensure the element is removed from its media session. 16 (WebCore::HTMLMediaElement::setSession): Update sessions' references to their media elements. 17 1 18 2015-06-05 Chris Dumez <cdumez@apple.com> 2 19 -
trunk/Source/WebCore/Modules/mediasession/MediaSession.cpp
r185126 r185270 29 29 #if ENABLE(MEDIA_SESSION) 30 30 31 #include "HTMLMediaElement.h" 32 31 33 namespace WebCore { 32 34 … … 49 51 } 50 52 53 void MediaSession::addMediaElement(HTMLMediaElement& element) 54 { 55 ASSERT(!m_participatingElements.contains(&element)); 56 m_participatingElements.append(&element); 57 } 58 59 void MediaSession::removeMediaElement(HTMLMediaElement& element) 60 { 61 ASSERT(m_participatingElements.contains(&element)); 62 m_participatingElements.remove(m_participatingElements.find(&element)); 63 } 64 65 Vector<HTMLMediaElement*> MediaSession::activeParticipatingElements() const 66 { 67 Vector<HTMLMediaElement*> elements; 68 69 for (auto* element : m_participatingElements) { 70 if (element->isPlaying()) 71 elements.append(element); 72 } 73 74 return elements; 75 } 76 51 77 void MediaSession::releaseSession() 52 78 { -
trunk/Source/WebCore/Modules/mediasession/MediaSession.h
r185136 r185270 33 33 namespace WebCore { 34 34 35 class HTMLMediaElement; 36 35 37 class MediaSession final : public RefCounted<MediaSession> { 36 38 public: … … 55 57 }; 56 58 59 friend class HTMLMediaElement; 60 61 void addMediaElement(HTMLMediaElement&); 62 void removeMediaElement(HTMLMediaElement&); 63 64 Vector<HTMLMediaElement*> activeParticipatingElements() const; 65 57 66 State m_currentState { State::Idle }; 67 Vector<HTMLMediaElement*> m_participatingElements; 58 68 59 69 const String m_kind; -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r185223 r185270 458 458 #endif 459 459 460 #if ENABLE(MEDIA_SESSION) 461 if (m_session) { 462 m_session->removeMediaElement(*this); 463 m_session = nullptr; 464 } 465 #endif 466 460 467 m_seekTaskQueue.close(); 461 468 … … 6368 6375 void HTMLMediaElement::setSession(MediaSession* session) 6369 6376 { 6377 if (m_session) 6378 m_session->removeMediaElement(*this); 6379 6370 6380 m_session = session; 6371 } 6372 6373 #endif 6374 6375 } 6376 6377 #endif 6381 6382 if (session) 6383 session->addMediaElement(*this); 6384 } 6385 6386 #endif 6387 6388 } 6389 6390 #endif
Note: See TracChangeset
for help on using the changeset viewer.