Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: third_party/WebKit/Source/modules/mediasession/HTMLMediaElementMediaSession.cpp

Issue 2338223003: Unassociating MediaSession from media players (in blink & content) (Closed)
Patch Set: fixed tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "modules/mediasession/HTMLMediaElementMediaSession.h"
6
7 #include "core/dom/ExceptionCode.h"
8
9 namespace blink {
10
11 MediaSession* HTMLMediaElementMediaSession::session(HTMLMediaElement& mediaEleme nt)
12 {
13 if (HTMLMediaElementMediaSession* supplement = fromIfExists(mediaElement))
14 return supplement->m_session.get();
15 return nullptr;
16 }
17
18 void HTMLMediaElementMediaSession::setSession(HTMLMediaElement& mediaElement, Me diaSession* session, ExceptionState& exceptionState)
19 {
20 HTMLMediaElement::NetworkState networkState = mediaElement.getNetworkState() ;
21 if (networkState == HTMLMediaElement::kNetworkIdle || networkState == HTMLMe diaElement::kNetworkLoading) {
22 exceptionState.throwDOMException(InvalidStateError, "networkState must b e kNetworkEmpty or kNetworkNoSource.");
23 return;
24 }
25
26 from(mediaElement).m_session = session;
27 }
28
29 const char* HTMLMediaElementMediaSession::supplementName()
30 {
31 return "HTMLMediaElementMediaSession";
32 }
33
34 HTMLMediaElementMediaSession& HTMLMediaElementMediaSession::from(HTMLMediaElemen t& element)
35 {
36 HTMLMediaElementMediaSession* supplement = fromIfExists(element);
37 if (!supplement) {
38 supplement = new HTMLMediaElementMediaSession();
39 provideTo(element, supplementName(), supplement);
40 }
41 return *supplement;
42 }
43
44 HTMLMediaElementMediaSession* HTMLMediaElementMediaSession::fromIfExists(HTMLMed iaElement& element)
45 {
46 return static_cast<HTMLMediaElementMediaSession*>(Supplement<HTMLMediaElemen t>::from(element, supplementName()));
47 }
48
49 DEFINE_TRACE(HTMLMediaElementMediaSession)
50 {
51 visitor->trace(m_session);
52 Supplement<HTMLMediaElement>::trace(visitor);
53 }
54
55 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698