| 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/MediaSession.h" | 5 #include "modules/mediasession/MediaSession.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" | 7 #include "bindings/core/v8/CallbackPromiseAdapter.h" |
| 8 #include "bindings/core/v8/ScriptPromiseResolver.h" | 8 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 9 #include "bindings/core/v8/ScriptState.h" | 9 #include "bindings/core/v8/ScriptState.h" |
| 10 #include "core/dom/DOMException.h" | 10 #include "core/dom/DOMException.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 MediaSession* MediaSession::create(ExecutionContext* context, ExceptionState& ex
ceptionState) | 26 MediaSession* MediaSession::create(ExecutionContext* context, ExceptionState& ex
ceptionState) |
| 27 { | 27 { |
| 28 Document* document = toDocument(context); | 28 Document* document = toDocument(context); |
| 29 LocalFrame* frame = document->frame(); | 29 LocalFrame* frame = document->frame(); |
| 30 FrameLoaderClient* client = frame->loader().client(); | 30 FrameLoaderClient* client = frame->loader().client(); |
| 31 OwnPtr<WebMediaSession> webMediaSession = client->createWebMediaSession(); | 31 OwnPtr<WebMediaSession> webMediaSession = client->createWebMediaSession(); |
| 32 if (!webMediaSession) { | 32 if (!webMediaSession) { |
| 33 exceptionState.throwDOMException(NotSupportedError, "Missing platform im
plementation."); | 33 exceptionState.throwDOMException(NotSupportedError, "Missing platform im
plementation."); |
| 34 return nullptr; | 34 return nullptr; |
| 35 } | 35 } |
| 36 return new MediaSession(webMediaSession.release()); | 36 return new MediaSession(std::move(webMediaSession)); |
| 37 } | 37 } |
| 38 | 38 |
| 39 ScriptPromise MediaSession::activate(ScriptState* scriptState) | 39 ScriptPromise MediaSession::activate(ScriptState* scriptState) |
| 40 { | 40 { |
| 41 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; | 41 ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState)
; |
| 42 ScriptPromise promise = resolver->promise(); | 42 ScriptPromise promise = resolver->promise(); |
| 43 | 43 |
| 44 m_webMediaSession->activate(new CallbackPromiseAdapter<void, MediaSessionErr
or>(resolver)); | 44 m_webMediaSession->activate(new CallbackPromiseAdapter<void, MediaSessionErr
or>(resolver)); |
| 45 return promise; | 45 return promise; |
| 46 } | 46 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 65 { | 65 { |
| 66 return m_metadata; | 66 return m_metadata; |
| 67 } | 67 } |
| 68 | 68 |
| 69 DEFINE_TRACE(MediaSession) | 69 DEFINE_TRACE(MediaSession) |
| 70 { | 70 { |
| 71 visitor->trace(m_metadata); | 71 visitor->trace(m_metadata); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace blink | 74 } // namespace blink |
| OLD | NEW |