OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 13 matching lines...) Expand all Loading... |
24 */ | 24 */ |
25 | 25 |
26 #ifndef MediaKeySession_h | 26 #ifndef MediaKeySession_h |
27 #define MediaKeySession_h | 27 #define MediaKeySession_h |
28 | 28 |
29 #include "bindings/v8/ScriptWrappable.h" | 29 #include "bindings/v8/ScriptWrappable.h" |
30 #include "core/dom/ActiveDOMObject.h" | 30 #include "core/dom/ActiveDOMObject.h" |
31 #include "core/events/EventTarget.h" | 31 #include "core/events/EventTarget.h" |
32 #include "heap/Handle.h" | 32 #include "heap/Handle.h" |
33 #include "platform/Timer.h" | 33 #include "platform/Timer.h" |
34 #include "platform/drm/ContentDecryptionModuleSession.h" | 34 #include "public/platform/WebContentDecryptionModuleSession.h" |
35 #include "wtf/Deque.h" | 35 #include "wtf/Deque.h" |
36 #include "wtf/PassRefPtr.h" | 36 #include "wtf/PassRefPtr.h" |
37 #include "wtf/RefCounted.h" | 37 #include "wtf/RefCounted.h" |
38 #include "wtf/Uint8Array.h" | 38 #include "wtf/Uint8Array.h" |
39 #include "wtf/WeakPtr.h" | 39 #include "wtf/WeakPtr.h" |
40 #include "wtf/text/WTFString.h" | 40 #include "wtf/text/WTFString.h" |
41 | 41 |
| 42 namespace blink { |
| 43 class WebContentDecryptionModule; |
| 44 } |
| 45 |
42 namespace WebCore { | 46 namespace WebCore { |
43 | 47 |
44 class ContentDecryptionModule; | |
45 class ContentDecryptionModuleSession; | |
46 class ExceptionState; | 48 class ExceptionState; |
47 class GenericEventQueue; | 49 class GenericEventQueue; |
48 class MediaKeyError; | 50 class MediaKeyError; |
49 class MediaKeys; | 51 class MediaKeys; |
50 | 52 |
51 // References are held by JS only. However, even if all JS references are | 53 // References are held by JS only. However, even if all JS references are |
52 // dropped, it won't be garbage collected until close event received or | 54 // dropped, it won't be garbage collected until close event received or |
53 // MediaKeys goes away (as determined by the validity of a WeakPtr). This allows | 55 // MediaKeys goes away (as determined by the validity of a WeakPtr). This allows |
54 // the CDM to continue to fire events for this session, as long as the session | 56 // the CDM to continue to fire events for this session, as long as the session |
55 // is open. | 57 // is open. |
56 // | 58 // |
57 // WeakPtr<MediaKeys> is used instead of having MediaKeys and MediaKeySession | 59 // WeakPtr<MediaKeys> is used instead of having MediaKeys and MediaKeySession |
58 // keep references to each other, and then having to inform the other object | 60 // keep references to each other, and then having to inform the other object |
59 // when it gets destroyed. | 61 // when it gets destroyed. |
60 // | 62 // |
61 // Because this object controls the lifetime of the ContentDecryptionModuleSessi
on, | 63 // Because this object controls the lifetime of the WebContentDecryptionModuleSe
ssion, |
62 // it may outlive any references to it as long as the MediaKeys object is alive. | 64 // it may outlive any JavaScript references as long as the MediaKeys object is a
live. |
63 // The ContentDecryptionModuleSession has the same lifetime as this object. | 65 // The WebContentDecryptionModuleSession has the same lifetime as this object. |
64 class MediaKeySession FINAL | 66 class MediaKeySession FINAL |
65 : public RefCountedWillBeRefCountedGarbageCollected<MediaKeySession>, public
ActiveDOMObject, public ScriptWrappable, public EventTargetWithInlineData | 67 : public RefCountedWillBeRefCountedGarbageCollected<MediaKeySession>, public
ActiveDOMObject, public ScriptWrappable, public EventTargetWithInlineData |
66 , private ContentDecryptionModuleSessionClient { | 68 , private blink::WebContentDecryptionModuleSession::Client { |
67 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<M
ediaKeySession>); | 69 DEFINE_EVENT_TARGET_REFCOUNTING(RefCountedWillBeRefCountedGarbageCollected<M
ediaKeySession>); |
68 public: | 70 public: |
69 static PassRefPtrWillBeRawPtr<MediaKeySession> create(ExecutionContext*, Con
tentDecryptionModule*, WeakPtr<MediaKeys>); | 71 static PassRefPtrWillBeRawPtr<MediaKeySession> create(ExecutionContext*, bli
nk::WebContentDecryptionModule*, WeakPtr<MediaKeys>); |
70 virtual ~MediaKeySession(); | 72 virtual ~MediaKeySession(); |
71 | 73 |
72 const String& keySystem() const { return m_keySystem; } | 74 const String& keySystem() const { return m_keySystem; } |
73 String sessionId() const; | 75 String sessionId() const; |
74 | 76 |
75 void setError(MediaKeyError*); | 77 void setError(MediaKeyError*); |
76 MediaKeyError* error() { return m_error.get(); } | 78 MediaKeyError* error() { return m_error.get(); } |
77 | 79 |
78 void initializeNewSession(const String& mimeType, const Uint8Array& initData
); | 80 void initializeNewSession(const String& mimeType, const Uint8Array& initData
); |
79 void update(Uint8Array* response, ExceptionState&); | 81 void update(Uint8Array* response, ExceptionState&); |
(...skipping 22 matching lines...) Expand all Loading... |
102 const RefPtr<Uint8Array> data; | 104 const RefPtr<Uint8Array> data; |
103 | 105 |
104 static PassOwnPtr<PendingAction> CreatePendingUpdate(PassRefPtr<Uint8Arr
ay> data); | 106 static PassOwnPtr<PendingAction> CreatePendingUpdate(PassRefPtr<Uint8Arr
ay> data); |
105 static PassOwnPtr<PendingAction> CreatePendingRelease(); | 107 static PassOwnPtr<PendingAction> CreatePendingRelease(); |
106 ~PendingAction(); | 108 ~PendingAction(); |
107 | 109 |
108 private: | 110 private: |
109 PendingAction(Type, PassRefPtr<Uint8Array> data); | 111 PendingAction(Type, PassRefPtr<Uint8Array> data); |
110 }; | 112 }; |
111 | 113 |
112 MediaKeySession(ExecutionContext*, ContentDecryptionModule*, WeakPtr<MediaKe
ys>); | 114 MediaKeySession(ExecutionContext*, blink::WebContentDecryptionModule*, WeakP
tr<MediaKeys>); |
113 void actionTimerFired(Timer<MediaKeySession>*); | 115 void actionTimerFired(Timer<MediaKeySession>*); |
114 | 116 |
115 // ContentDecryptionModuleSessionClient | 117 // blink::WebContentDecryptionModuleSession::Client |
116 virtual void message(const unsigned char* message, size_t messageLength, con
st KURL& destinationURL) OVERRIDE; | 118 virtual void message(const unsigned char* message, size_t messageLength, con
st blink::WebURL& destinationURL) OVERRIDE; |
117 virtual void ready() OVERRIDE; | 119 virtual void ready() OVERRIDE; |
118 virtual void close() OVERRIDE; | 120 virtual void close() OVERRIDE; |
119 virtual void error(MediaKeyErrorCode, unsigned long systemCode) OVERRIDE; | 121 virtual void error(MediaKeyErrorCode, unsigned long systemCode) OVERRIDE; |
120 | 122 |
121 String m_keySystem; | 123 String m_keySystem; |
122 RefPtr<MediaKeyError> m_error; | 124 RefPtr<MediaKeyError> m_error; |
123 OwnPtr<GenericEventQueue> m_asyncEventQueue; | 125 OwnPtr<GenericEventQueue> m_asyncEventQueue; |
124 OwnPtr<ContentDecryptionModuleSession> m_session; | 126 OwnPtr<blink::WebContentDecryptionModuleSession> m_session; |
125 | 127 |
126 // Used to determine if MediaKeys is still active. | 128 // Used to determine if MediaKeys is still active. |
127 WeakPtr<MediaKeys> m_keys; | 129 WeakPtr<MediaKeys> m_keys; |
128 | 130 |
129 // Is the CDM finished with this session? | 131 // Is the CDM finished with this session? |
130 bool m_isClosed; | 132 bool m_isClosed; |
131 | 133 |
132 Deque<OwnPtr<PendingAction> > m_pendingActions; | 134 Deque<OwnPtr<PendingAction> > m_pendingActions; |
133 Timer<MediaKeySession> m_actionTimer; | 135 Timer<MediaKeySession> m_actionTimer; |
134 }; | 136 }; |
135 | 137 |
136 } | 138 } |
137 | 139 |
138 #endif // MediaKeySession_h | 140 #endif // MediaKeySession_h |
OLD | NEW |