| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/mediasession/HTMLMediaElementMediaSession.h" | 5 #include "modules/mediasession/HTMLMediaElementMediaSession.h" |
| 6 | 6 |
| 7 #include "core/dom/ExceptionCode.h" | 7 #include "core/dom/ExceptionCode.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| 11 MediaSession* HTMLMediaElementMediaSession::session(HTMLMediaElement& mediaEleme
nt) | 11 MediaSession* HTMLMediaElementMediaSession::session(HTMLMediaElement& mediaEleme
nt) |
| 12 { | 12 { |
| 13 if (HTMLMediaElementMediaSession* supplement = fromIfExists(mediaElement)) | 13 if (HTMLMediaElementMediaSession* supplement = fromIfExists(mediaElement)) |
| 14 return supplement->m_session.get(); | 14 return supplement->m_session.get(); |
| 15 return nullptr; | 15 return nullptr; |
| 16 } | 16 } |
| 17 | 17 |
| 18 void HTMLMediaElementMediaSession::setSession(HTMLMediaElement& mediaElement, Me
diaSession* session, ExceptionState& exceptionState) | 18 void HTMLMediaElementMediaSession::setSession(HTMLMediaElement& mediaElement, Me
diaSession* session, ExceptionState& exceptionState) |
| 19 { | 19 { |
| 20 HTMLMediaElement::NetworkState networkState = mediaElement.getNetworkState()
; | 20 HTMLMediaElement::NetworkState networkState = mediaElement.getNetworkState()
; |
| 21 if (networkState == HTMLMediaElement::NETWORK_IDLE || networkState == HTMLMe
diaElement::NETWORK_LOADING) { | 21 if (networkState == HTMLMediaElement::kNetworkIdle || networkState == HTMLMe
diaElement::kNetworkLoading) { |
| 22 exceptionState.throwDOMException(InvalidStateError, "networkState must b
e NETWORK_EMPTY or NETWORK_NO_SOURCE."); | 22 exceptionState.throwDOMException(InvalidStateError, "networkState must b
e kNetworkEmpty or kNetworkNoSource."); |
| 23 return; | 23 return; |
| 24 } | 24 } |
| 25 | 25 |
| 26 from(mediaElement).m_session = session; | 26 from(mediaElement).m_session = session; |
| 27 } | 27 } |
| 28 | 28 |
| 29 const char* HTMLMediaElementMediaSession::supplementName() | 29 const char* HTMLMediaElementMediaSession::supplementName() |
| 30 { | 30 { |
| 31 return "HTMLMediaElementMediaSession"; | 31 return "HTMLMediaElementMediaSession"; |
| 32 } | 32 } |
| (...skipping 13 matching lines...) Expand all Loading... |
| 46 return static_cast<HTMLMediaElementMediaSession*>(Supplement<HTMLMediaElemen
t>::from(element, supplementName())); | 46 return static_cast<HTMLMediaElementMediaSession*>(Supplement<HTMLMediaElemen
t>::from(element, supplementName())); |
| 47 } | 47 } |
| 48 | 48 |
| 49 DEFINE_TRACE(HTMLMediaElementMediaSession) | 49 DEFINE_TRACE(HTMLMediaElementMediaSession) |
| 50 { | 50 { |
| 51 visitor->trace(m_session); | 51 visitor->trace(m_session); |
| 52 Supplement<HTMLMediaElement>::trace(visitor); | 52 Supplement<HTMLMediaElement>::trace(visitor); |
| 53 } | 53 } |
| 54 | 54 |
| 55 } // namespace blink | 55 } // namespace blink |
| OLD | NEW |