From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- .../Modules/encryptedmedia/MediaKeySession.h | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 Source/WebCore/Modules/encryptedmedia/MediaKeySession.h (limited to 'Source/WebCore/Modules/encryptedmedia/MediaKeySession.h') diff --git a/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h b/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h new file mode 100644 index 000000000..0ce875d89 --- /dev/null +++ b/Source/WebCore/Modules/encryptedmedia/MediaKeySession.h @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2016 Metrological Group B.V. + * Copyright (C) 2016 Igalia S.L. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#if ENABLE(ENCRYPTED_MEDIA) + +#include "ActiveDOMObject.h" +#include "CDMInstance.h" +#include "EventTarget.h" +#include "GenericEventQueue.h" +#include "GenericTaskQueue.h" +#include "JSDOMPromise.h" +#include "MediaKeyMessageType.h" +#include "MediaKeySessionType.h" +#include "MediaKeyStatus.h" +#include +#include +#include +#include + +namespace WebCore { + +class BufferSource; +class CDM; +class MediaKeyStatusMap; +class MediaKeys; +class SharedBuffer; + +class MediaKeySession final : public RefCounted, public EventTargetWithInlineData, public ActiveDOMObject { +public: + static Ref create(ScriptExecutionContext&, MediaKeySessionType, bool useDistinctiveIdentifier, Ref&&, Ref&&); + virtual ~MediaKeySession(); + + using RefCounted::ref; + using RefCounted::deref; + + const String& sessionId() const; + double expiration() const; + Ref keyStatuses() const; + + void generateRequest(const AtomicString&, const BufferSource&, Ref&&); + void load(const String&, Ref&&); + void update(const BufferSource&, Ref&&); + void close(Ref&&); + void remove(Ref&&); + + using ClosedPromise = DOMPromise; + void registerClosedPromise(ClosedPromise&&); + + const Vector, MediaKeyStatus>>& statuses() const { return m_statuses; } + +private: + MediaKeySession(ScriptExecutionContext&, MediaKeySessionType, bool useDistinctiveIdentifier, Ref&&, Ref&&); + void enqueueMessage(MediaKeyMessageType, const SharedBuffer&); + void updateKeyStatuses(CDMInstance::KeyStatusVector&&); + void updateExpiration(double); + void sessionClosed(); + + // EventTarget + EventTargetInterface eventTargetInterface() const override { return MediaKeySessionEventTargetInterfaceType; } + ScriptExecutionContext* scriptExecutionContext() const override { return ActiveDOMObject::scriptExecutionContext(); } + void refEventTarget() override { ref(); } + void derefEventTarget() override { deref(); } + + // ActiveDOMObject + bool hasPendingActivity() const override; + const char* activeDOMObjectName() const override; + bool canSuspendForDocumentSuspension() const override; + void stop() override; + + String m_sessionId; + double m_expiration; + std::optional m_closedPromise; + Ref m_keyStatuses; + bool m_closed { false }; + bool m_uninitialized { true }; + bool m_callable { false }; + bool m_useDistinctiveIdentifier; + MediaKeySessionType m_sessionType; + Ref m_implementation; + Ref m_instance; + GenericEventQueue m_eventQueue; + GenericTaskQueue m_taskQueue; + Vector> m_recordOfKeyUsage; + double m_firstDecryptTime { 0 }; + double m_latestDecryptTime { 0 }; + Vector, MediaKeyStatus>> m_statuses; + WeakPtrFactory m_weakPtrFactory; +}; + +} // namespace WebCore + +#endif // ENABLE(ENCRYPTED_MEDIA) -- cgit v1.2.1