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

Side by Side Diff: Source/modules/encryptedmedia/MediaKeys.cpp

Issue 257503003: Oilpan: Enable Oilpan by default in modules/encryptedmedia (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/modules/encryptedmedia/MediaKeys.h ('k') | Source/modules/encryptedmedia/MediaKeys.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 static bool isKeySystemSupportedWithContentType(const String& keySystem, const S tring& contentType) 47 static bool isKeySystemSupportedWithContentType(const String& keySystem, const S tring& contentType)
48 { 48 {
49 ASSERT(!keySystem.isEmpty()); 49 ASSERT(!keySystem.isEmpty());
50 50
51 ContentType type(contentType); 51 ContentType type(contentType);
52 String codecs = type.parameter("codecs"); 52 String codecs = type.parameter("codecs");
53 return MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, type.t ype(), codecs); 53 return MIMETypeRegistry::isSupportedEncryptedMediaMIMEType(keySystem, type.t ype(), codecs);
54 } 54 }
55 55
56 PassRefPtrWillBeRawPtr<MediaKeys> MediaKeys::create(ExecutionContext* context, c onst String& keySystem, ExceptionState& exceptionState) 56 MediaKeys* MediaKeys::create(ExecutionContext* context, const String& keySystem, ExceptionState& exceptionState)
57 { 57 {
58 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-media-keys-constructor>: 58 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-media-keys-constructor>:
59 // The MediaKeys(keySystem) constructor must run the following steps: 59 // The MediaKeys(keySystem) constructor must run the following steps:
60 60
61 // 1. If keySystem is an empty string, throw an InvalidAccessError exception and abort these steps. 61 // 1. If keySystem is an empty string, throw an InvalidAccessError exception and abort these steps.
62 if (keySystem.isEmpty()) { 62 if (keySystem.isEmpty()) {
63 exceptionState.throwDOMException(InvalidAccessError, "The key system pro vided is invalid."); 63 exceptionState.throwDOMException(InvalidAccessError, "The key system pro vided is invalid.");
64 return nullptr; 64 return 0;
65 } 65 }
66 66
67 // 2. If keySystem is not one of the user agent's supported Key Systems, thr ow a NotSupportedError and abort these steps. 67 // 2. If keySystem is not one of the user agent's supported Key Systems, thr ow a NotSupportedError and abort these steps.
68 if (!isKeySystemSupportedWithContentType(keySystem, "")) { 68 if (!isKeySystemSupportedWithContentType(keySystem, "")) {
69 exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem + "' key system is not supported."); 69 exceptionState.throwDOMException(NotSupportedError, "The '" + keySystem + "' key system is not supported.");
70 return nullptr; 70 return 0;
71 } 71 }
72 72
73 // 3. Let cdm be the content decryption module corresponding to keySystem. 73 // 3. Let cdm be the content decryption module corresponding to keySystem.
74 // 4. Load cdm if necessary. 74 // 4. Load cdm if necessary.
75 Document* document = toDocument(context); 75 Document* document = toDocument(context);
76 MediaKeysController* controller = MediaKeysController::from(document->page() ); 76 MediaKeysController* controller = MediaKeysController::from(document->page() );
77 OwnPtr<blink::WebContentDecryptionModule> cdm = controller->createContentDec ryptionModule(context, keySystem); 77 OwnPtr<blink::WebContentDecryptionModule> cdm = controller->createContentDec ryptionModule(context, keySystem);
78 if (!cdm) { 78 if (!cdm) {
79 exceptionState.throwDOMException(NotSupportedError, "A content decryptio n module could not be loaded for the '" + keySystem + "' key system."); 79 exceptionState.throwDOMException(NotSupportedError, "A content decryptio n module could not be loaded for the '" + keySystem + "' key system.");
80 return nullptr; 80 return 0;
81 } 81 }
82 82
83 // 5. Create a new MediaKeys object. 83 // 5. Create a new MediaKeys object.
84 // 5.1 Let the keySystem attribute be keySystem. 84 // 5.1 Let the keySystem attribute be keySystem.
85 // 6. Return the new object to the caller. 85 // 6. Return the new object to the caller.
86 return adoptRefWillBeNoop(new MediaKeys(context, keySystem, cdm.release())); 86 return new MediaKeys(context, keySystem, cdm.release());
87 } 87 }
88 88
89 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwn Ptr<blink::WebContentDecryptionModule> cdm) 89 MediaKeys::MediaKeys(ExecutionContext* context, const String& keySystem, PassOwn Ptr<blink::WebContentDecryptionModule> cdm)
90 : ContextLifecycleObserver(context) 90 : ContextLifecycleObserver(context)
91 , m_mediaElement(0)
92 , m_keySystem(keySystem) 91 , m_keySystem(keySystem)
93 , m_cdm(cdm) 92 , m_cdm(cdm)
94 , m_initializeNewSessionTimer(this, &MediaKeys::initializeNewSessionTimerFir ed) 93 , m_initializeNewSessionTimer(this, &MediaKeys::initializeNewSessionTimerFir ed)
95 #if !ENABLE(OILPAN)
96 , m_weakFactory(this)
97 #endif
98 { 94 {
99 WTF_LOG(Media, "MediaKeys::MediaKeys"); 95 WTF_LOG(Media, "MediaKeys::MediaKeys");
100 ScriptWrappable::init(this); 96 ScriptWrappable::init(this);
101 } 97 }
102 98
103 MediaKeys::~MediaKeys() 99 MediaKeys::~MediaKeys()
104 { 100 {
105 } 101 }
106 102
107 PassRefPtrWillBeRawPtr<MediaKeySession> MediaKeys::createSession(ExecutionContex t* context, const String& contentType, Uint8Array* initData, ExceptionState& exc eptionState) 103 MediaKeySession* MediaKeys::createSession(ExecutionContext* context, const Strin g& contentType, Uint8Array* initData, ExceptionState& exceptionState)
108 { 104 {
109 WTF_LOG(Media, "MediaKeys::createSession"); 105 WTF_LOG(Media, "MediaKeys::createSession");
110 106
111 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-createsession>: 107 // From <http://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/e ncrypted-media.html#dom-createsession>:
112 // The createSession(type, initData) method must run the following steps: 108 // The createSession(type, initData) method must run the following steps:
113 // Note: The contents of initData are container-specific Initialization Data . 109 // Note: The contents of initData are container-specific Initialization Data .
114 110
115 if (contentType.isEmpty()) { 111 if (contentType.isEmpty()) {
116 exceptionState.throwDOMException(InvalidAccessError, "The contentType pr ovided ('" + contentType + "') is empty."); 112 exceptionState.throwDOMException(InvalidAccessError, "The contentType pr ovided ('" + contentType + "') is empty.");
117 return nullptr; 113 return 0;
118 } 114 }
119 115
120 if (!initData->length()) { 116 if (!initData->length()) {
121 exceptionState.throwDOMException(InvalidAccessError, "The initData provi ded is empty."); 117 exceptionState.throwDOMException(InvalidAccessError, "The initData provi ded is empty.");
122 return nullptr; 118 return 0;
123 } 119 }
124 120
125 // 1. If type contains a MIME type that is not supported or is not supported by the keySystem, 121 // 1. If type contains a MIME type that is not supported or is not supported by the keySystem,
126 // throw a NOT_SUPPORTED_ERR exception and abort these steps. 122 // throw a NOT_SUPPORTED_ERR exception and abort these steps.
127 if (!isKeySystemSupportedWithContentType(m_keySystem, contentType)) { 123 if (!isKeySystemSupportedWithContentType(m_keySystem, contentType)) {
128 exceptionState.throwDOMException(NotSupportedError, "The type provided ( '" + contentType + "') is unsupported."); 124 exceptionState.throwDOMException(NotSupportedError, "The type provided ( '" + contentType + "') is unsupported.");
129 return nullptr; 125 return 0;
130 } 126 }
131 127
132 // 2. Create a new MediaKeySession object. 128 // 2. Create a new MediaKeySession object.
133 #if ENABLE(OILPAN)
134 MediaKeySession* session = MediaKeySession::create(context, m_cdm.get(), thi s); 129 MediaKeySession* session = MediaKeySession::create(context, m_cdm.get(), thi s);
135 #else
136 RefPtr<MediaKeySession> session = MediaKeySession::create(context, m_cdm.get (), m_weakFactory.createWeakPtr());
137 #endif
138 // 2.1 Let the keySystem attribute be keySystem. 130 // 2.1 Let the keySystem attribute be keySystem.
139 ASSERT(!session->keySystem().isEmpty()); 131 ASSERT(!session->keySystem().isEmpty());
140 // FIXME: 2.2 Let the state of the session be CREATED. 132 // FIXME: 2.2 Let the state of the session be CREATED.
141 133
142 // 3. Add the new object to an internal list of session objects (not needed) . 134 // 3. Add the new object to an internal list of session objects (not needed) .
143 135
144 // 4. Schedule a task to initialize the session, providing type, initData, a nd the new object. 136 // 4. Schedule a task to initialize the session, providing type, initData, a nd the new object.
145 m_pendingInitializeNewSessionData.append(InitializeNewSessionData(session, c ontentType, initData)); 137 m_pendingInitializeNewSessionData.append(InitializeNewSessionData(session, c ontentType, initData));
146 138
147 if (!m_initializeNewSessionTimer.isActive()) 139 if (!m_initializeNewSessionTimer.isActive())
(...skipping 18 matching lines...) Expand all
166 158
167 // 3. If contentType is an empty string, return true and abort these steps. 159 // 3. If contentType is an empty string, return true and abort these steps.
168 if (contentType.isEmpty()) 160 if (contentType.isEmpty())
169 return true; 161 return true;
170 162
171 // 4. If the Key System specified by keySystem does not support decrypting t he container and/or 163 // 4. If the Key System specified by keySystem does not support decrypting t he container and/or
172 // codec specified by contentType, return false and abort these steps. 164 // codec specified by contentType, return false and abort these steps.
173 return isKeySystemSupportedWithContentType(keySystem, contentType); 165 return isKeySystemSupportedWithContentType(keySystem, contentType);
174 } 166 }
175 167
176 void MediaKeys::setMediaElement(HTMLMediaElement* element)
177 {
178 // FIXME: Cause HTMLMediaElement::setMediaKeys() to throw an exception if m_ mediaElement is not 0
179 // and remove the code that prevents the assert below in HTMLMediaElement.
180 ASSERT(!m_mediaElement != !element);
181 m_mediaElement = element;
182 }
183
184 blink::WebContentDecryptionModule* MediaKeys::contentDecryptionModule() 168 blink::WebContentDecryptionModule* MediaKeys::contentDecryptionModule()
185 { 169 {
186 return m_cdm.get(); 170 return m_cdm.get();
187 } 171 }
188 172
189 void MediaKeys::initializeNewSessionTimerFired(Timer<MediaKeys>*) 173 void MediaKeys::initializeNewSessionTimerFired(Timer<MediaKeys>*)
190 { 174 {
191 ASSERT(m_pendingInitializeNewSessionData.size()); 175 ASSERT(m_pendingInitializeNewSessionData.size());
192 176
193 while (!m_pendingInitializeNewSessionData.isEmpty()) { 177 while (!m_pendingInitializeNewSessionData.isEmpty()) {
(...skipping 15 matching lines...) Expand all
209 193
210 void MediaKeys::contextDestroyed() 194 void MediaKeys::contextDestroyed()
211 { 195 {
212 ContextLifecycleObserver::contextDestroyed(); 196 ContextLifecycleObserver::contextDestroyed();
213 197
214 // We don't need the CDM anymore. 198 // We don't need the CDM anymore.
215 m_cdm.clear(); 199 m_cdm.clear();
216 } 200 }
217 201
218 } 202 }
OLDNEW
« no previous file with comments | « Source/modules/encryptedmedia/MediaKeys.h ('k') | Source/modules/encryptedmedia/MediaKeys.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698