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 30 matching lines...) Expand all Loading... | |
41 { | 41 { |
42 return adoptRef(new MediaKeySession(context, cdm, keys)); | 42 return adoptRef(new MediaKeySession(context, cdm, keys)); |
43 } | 43 } |
44 | 44 |
45 MediaKeySession::MediaKeySession(ExecutionContext* context, ContentDecryptionMod ule* cdm, MediaKeys* keys) | 45 MediaKeySession::MediaKeySession(ExecutionContext* context, ContentDecryptionMod ule* cdm, MediaKeys* keys) |
46 : ContextLifecycleObserver(context) | 46 : ContextLifecycleObserver(context) |
47 , m_keySystem(keys->keySystem()) | 47 , m_keySystem(keys->keySystem()) |
48 , m_asyncEventQueue(GenericEventQueue::create(this)) | 48 , m_asyncEventQueue(GenericEventQueue::create(this)) |
49 , m_session(cdm->createSession(this)) | 49 , m_session(cdm->createSession(this)) |
50 , m_keys(keys) | 50 , m_keys(keys) |
51 , m_initializeNewSessionTimer(this, &MediaKeySession::initializeNewSessionTi merFired) | |
52 , m_updateTimer(this, &MediaKeySession::updateTimerFired) | 51 , m_updateTimer(this, &MediaKeySession::updateTimerFired) |
53 { | 52 { |
54 ScriptWrappable::init(this); | 53 ScriptWrappable::init(this); |
55 ASSERT(m_session); | 54 ASSERT(m_session); |
56 } | 55 } |
57 | 56 |
58 MediaKeySession::~MediaKeySession() | 57 MediaKeySession::~MediaKeySession() |
59 { | 58 { |
60 m_session.clear(); | 59 m_session.clear(); |
61 m_asyncEventQueue->cancelAllEvents(); | 60 m_asyncEventQueue->cancelAllEvents(); |
(...skipping 11 matching lines...) Expand all Loading... | |
73 void MediaKeySession::release(ExceptionState& exceptionState) | 72 void MediaKeySession::release(ExceptionState& exceptionState) |
74 { | 73 { |
75 m_session->release(); | 74 m_session->release(); |
76 } | 75 } |
77 | 76 |
78 String MediaKeySession::sessionId() const | 77 String MediaKeySession::sessionId() const |
79 { | 78 { |
80 return m_session->sessionId(); | 79 return m_session->sessionId(); |
81 } | 80 } |
82 | 81 |
83 void MediaKeySession::initializeNewSession(const String& mimeType, Uint8Array* i nitData) | 82 void MediaKeySession::initializeNewSession(const String& mimeType, Uint8Array* i nitData) |
acolwell GONE FROM CHROMIUM
2014/01/13 18:35:37
nit: Make initData const Uint8Array& here too so t
xhwang
2014/01/13 19:06:03
Done.
| |
84 { | 83 { |
85 m_pendingInitializeNewSessionData.append(InitializeNewSessionData(mimeType, initData)); | 84 m_session->initializeNewSession(mimeType, *initData); |
86 m_initializeNewSessionTimer.startOneShot(0); | |
87 } | |
88 | |
89 void MediaKeySession::initializeNewSessionTimerFired(Timer<MediaKeySession>*) | |
90 { | |
91 ASSERT(m_pendingInitializeNewSessionData.size()); | |
92 | |
93 while (!m_pendingInitializeNewSessionData.isEmpty()) { | |
94 InitializeNewSessionData data = m_pendingInitializeNewSessionData.takeFi rst(); | |
95 // FIXME: Refer to the spec to see what needs to be done in blink. | |
96 m_session->initializeNewSession(data.mimeType, *data.initData); | |
97 } | |
98 } | 85 } |
99 | 86 |
100 void MediaKeySession::update(Uint8Array* response, ExceptionState& exceptionStat e) | 87 void MediaKeySession::update(Uint8Array* response, ExceptionState& exceptionStat e) |
101 { | 88 { |
102 // From <https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/ encrypted-media.html#dom-update>: | 89 // From <https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/ encrypted-media.html#dom-update>: |
103 // The update(response) method must run the following steps: | 90 // The update(response) method must run the following steps: |
104 // 1. If the argument is null or an empty array, throw an INVALID_ACCESS_ERR . | 91 // 1. If the argument is null or an empty array, throw an INVALID_ACCESS_ERR . |
105 if (!response || !response->length()) { | 92 if (!response || !response->length()) { |
106 exceptionState.throwDOMException(InvalidAccessError, String::format("The response argument provided is %s.", response ? "an empty array" : "invalid")); | 93 exceptionState.throwDOMException(InvalidAccessError, String::format("The response argument provided is %s.", response ? "an empty array" : "invalid")); |
107 return; | 94 return; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 { | 169 { |
183 return EventTargetNames::MediaKeySession; | 170 return EventTargetNames::MediaKeySession; |
184 } | 171 } |
185 | 172 |
186 ExecutionContext* MediaKeySession::executionContext() const | 173 ExecutionContext* MediaKeySession::executionContext() const |
187 { | 174 { |
188 return ContextLifecycleObserver::executionContext(); | 175 return ContextLifecycleObserver::executionContext(); |
189 } | 176 } |
190 | 177 |
191 } | 178 } |
OLD | NEW |