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

Unified Diff: Source/modules/mediasession/MediaSession.cpp

Issue 1325493002: NOT FOR LANDING Introduce and use WebMediaSession (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add missing files Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/modules/mediasession/MediaSession.h ('k') | Source/modules/mediasession/MediaSession.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/mediasession/MediaSession.cpp
diff --git a/Source/modules/mediasession/MediaSession.cpp b/Source/modules/mediasession/MediaSession.cpp
index 937bf7f19d23f26aadf5c3f1ae0393ae0050d093..8b0445854697798e023501c6027dc34b990109f1 100644
--- a/Source/modules/mediasession/MediaSession.cpp
+++ b/Source/modules/mediasession/MediaSession.cpp
@@ -5,19 +5,52 @@
#include "config.h"
#include "modules/mediasession/MediaSession.h"
+#include "Source/bindings/core/v8/CallbackPromiseAdapter.h"
+#include "bindings/core/v8/ScriptState.h"
+#include "core/frame/LocalDOMWindow.h"
+#include "core/frame/LocalFrame.h"
+#include "core/loader/FrameLoaderClient.h"
+#include "modules/mediasession/MediaSessionError.h"
+
namespace blink {
-MediaSession* MediaSession::create()
+MediaSession::MediaSession(PassOwnPtr<WebMediaSession> webMediaSession)
+ : m_webMediaSession(webMediaSession)
+{
+ ASSERT(m_webMediaSession);
+}
+
+MediaSession* MediaSession::create(ScriptState* scriptState)
{
- return new MediaSession;
+ LocalDOMWindow* domWindow = scriptState->domWindow();
+ LocalFrame* frame = domWindow->frame();
+ FrameLoaderClient* client = frame->loader().client();
+ return new MediaSession(client->createWebMediaSession());
}
-void MediaSession::activate()
+MediaSession* MediaSession::createForTesting(PassOwnPtr<WebMediaSession> webMediaSession)
{
+ return new MediaSession(webMediaSession);
}
-void MediaSession::deactivate()
+ScriptPromise MediaSession::activate(ScriptState* scriptState)
{
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+
+ m_webMediaSession->activate(new CallbackPromiseAdapter<void, MediaSessionError>(resolver));
+
+ return promise;
+}
+
+ScriptPromise MediaSession::deactivate(ScriptState* scriptState)
+{
+ ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState);
+ ScriptPromise promise = resolver->promise();
+
+ m_webMediaSession->deactivate(new CallbackPromiseAdapter<void, MediaSessionError>(resolver));
+
+ return promise;
}
} // namespace blink
« no previous file with comments | « Source/modules/mediasession/MediaSession.h ('k') | Source/modules/mediasession/MediaSession.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698