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

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

Issue 1414553002: Fix out-of-memory crashes related to ArrayBuffer allocation Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase+more tweaks Created 5 years, 1 month 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
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 scriptState, DOMException::create(InvalidAccessError, "The serverCer tificate parameter is empty.")); 144 scriptState, DOMException::create(InvalidAccessError, "The serverCer tificate parameter is empty."));
145 } 145 }
146 146
147 // 2. If the keySystem does not support server certificates, return a 147 // 2. If the keySystem does not support server certificates, return a
148 // promise rejected with a new DOMException whose name is 148 // promise rejected with a new DOMException whose name is
149 // "NotSupportedError". 149 // "NotSupportedError".
150 // (Let the CDM decide whether to support this or not.) 150 // (Let the CDM decide whether to support this or not.)
151 151
152 // 3. Let certificate be a copy of the contents of the serverCertificate 152 // 3. Let certificate be a copy of the contents of the serverCertificate
153 // parameter. 153 // parameter.
154 RefPtr<DOMArrayBuffer> serverCertificateBuffer = DOMArrayBuffer::create(serv erCertificate.data(), serverCertificate.byteLength()); 154 //
155 // TODO(junov): crbug.com/536816
156 // Use createOrNull instead of deprecatedCreateOrCrash. It would probably
157 // be appropriate to reject the promise with a RangeError exception when
158 // array buffer allocation fails, but that behavior probably needs
159 // clarification in the spec.
160 RefPtr<DOMArrayBuffer> serverCertificateBuffer = DOMArrayBuffer::deprecatedC reateOrCrash(serverCertificate.data(), serverCertificate.byteLength());
155 161
156 // 4. Let promise be a new promise. 162 // 4. Let promise be a new promise.
157 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp tionModuleResultPromise(scriptState); 163 SimpleContentDecryptionModuleResultPromise* result = new SimpleContentDecryp tionModuleResultPromise(scriptState);
158 ScriptPromise promise = result->promise(); 164 ScriptPromise promise = result->promise();
159 165
160 // 5. Run the following steps asynchronously (documented in timerFired()). 166 // 5. Run the following steps asynchronously (documented in timerFired()).
161 m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(res ult, serverCertificateBuffer.release())); 167 m_pendingActions.append(PendingAction::CreatePendingSetServerCertificate(res ult, serverCertificateBuffer.release()));
162 if (!m_timer.isActive()) 168 if (!m_timer.isActive())
163 m_timer.startOneShot(0, BLINK_FROM_HERE); 169 m_timer.startOneShot(0, BLINK_FROM_HERE);
164 170
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 void MediaKeys::stop() 270 void MediaKeys::stop()
265 { 271 {
266 ActiveDOMObject::stop(); 272 ActiveDOMObject::stop();
267 273
268 if (m_timer.isActive()) 274 if (m_timer.isActive())
269 m_timer.stop(); 275 m_timer.stop();
270 m_pendingActions.clear(); 276 m_pendingActions.clear();
271 } 277 }
272 278
273 } // namespace blink 279 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698