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

Side by Side Diff: media/base/android/java/src/org/chromium/media/MediaDrmBridge.java

Issue 1071413002: MediaDrmBridge: guards MediaDrm.removeKeys call in case of failure. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.media; 5 package org.chromium.media;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.media.MediaCrypto; 8 import android.media.MediaCrypto;
9 import android.media.MediaDrm; 9 import android.media.MediaDrm;
10 import android.os.AsyncTask; 10 import android.os.AsyncTask;
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 // Do not reset mHandler so that we can still post tasks back to native code. 371 // Do not reset mHandler so that we can still post tasks back to native code.
372 // Note that mNativeMediaDrmBridge may have already been reset (see dest roy()). 372 // Note that mNativeMediaDrmBridge may have already been reset (see dest roy()).
373 373
374 for (PendingCreateSessionData data : mPendingCreateSessionDataQueue) { 374 for (PendingCreateSessionData data : mPendingCreateSessionDataQueue) {
375 onPromiseRejected(data.promiseId(), "Create session aborted."); 375 onPromiseRejected(data.promiseId(), "Create session aborted.");
376 } 376 }
377 mPendingCreateSessionDataQueue.clear(); 377 mPendingCreateSessionDataQueue.clear();
378 mPendingCreateSessionDataQueue = null; 378 mPendingCreateSessionDataQueue = null;
379 379
380 for (ByteBuffer sessionId : mSessionIds.keySet()) { 380 for (ByteBuffer sessionId : mSessionIds.keySet()) {
381 mMediaDrm.removeKeys(sessionId.array()); 381 try {
382 mMediaDrm.removeKeys(sessionId.array());
383 } catch (Exception e) {
384 Log.e(TAG, "removeKeys failed: ", e);
xhwang 2015/04/10 04:44:22 add a comment with bug number
gunsch 2015/04/10 20:47:17 Done.
385 }
382 mMediaDrm.closeSession(sessionId.array()); 386 mMediaDrm.closeSession(sessionId.array());
383 onSessionClosed(sessionId.array()); 387 onSessionClosed(sessionId.array());
384 } 388 }
385 mSessionIds.clear(); 389 mSessionIds.clear();
386 mSessionIds = null; 390 mSessionIds = null;
387 391
388 // This session was closed in the "for" loop above. 392 // This session was closed in the "for" loop above.
389 mMediaCryptoSession = null; 393 mMediaCryptoSession = null;
390 394
391 if (mMediaCrypto != null) { 395 if (mMediaCrypto != null) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 onPromiseRejected(promiseId, "closeSession() called when MediaDrm is null."); 565 onPromiseRejected(promiseId, "closeSession() called when MediaDrm is null.");
562 return; 566 return;
563 } 567 }
564 568
565 if (!sessionExists(sessionId)) { 569 if (!sessionExists(sessionId)) {
566 onPromiseRejected(promiseId, 570 onPromiseRejected(promiseId,
567 "Invalid sessionId in closeSession(): " + bytesToHexString(s essionId)); 571 "Invalid sessionId in closeSession(): " + bytesToHexString(s essionId));
568 return; 572 return;
569 } 573 }
570 574
571 mMediaDrm.removeKeys(sessionId); 575 try {
576 mMediaDrm.removeKeys(sessionId);
577 } catch (Exception e) {
578 Log.e(TAG, "removeKeys failed: ", e);
xhwang 2015/04/10 04:44:22 add a comment with bug number
gunsch 2015/04/10 20:47:17 Done.
579 }
572 mMediaDrm.closeSession(sessionId); 580 mMediaDrm.closeSession(sessionId);
573 mSessionIds.remove(ByteBuffer.wrap(sessionId)); 581 mSessionIds.remove(ByteBuffer.wrap(sessionId));
574 onPromiseResolved(promiseId); 582 onPromiseResolved(promiseId);
575 onSessionClosed(sessionId); 583 onSessionClosed(sessionId);
576 Log.d(TAG, "Session " + bytesToHexString(sessionId) + " closed."); 584 Log.d(TAG, "Session " + bytesToHexString(sessionId) + " closed.");
577 } 585 }
578 586
579 /** 587 /**
580 * Update a session with response. 588 * Update a session with response.
581 * 589 *
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 private native void nativeOnSessionKeysChange(long nativeMediaDrmBridge, byt e[] sessionId, 954 private native void nativeOnSessionKeysChange(long nativeMediaDrmBridge, byt e[] sessionId,
947 boolean hasAdditionalUsableKey, int keyStatus); 955 boolean hasAdditionalUsableKey, int keyStatus);
948 private native void nativeOnLegacySessionError( 956 private native void nativeOnLegacySessionError(
949 long nativeMediaDrmBridge, byte[] sessionId, String errorMessage); 957 long nativeMediaDrmBridge, byte[] sessionId, String errorMessage);
950 958
951 private native void nativeOnResetDeviceCredentialsCompleted( 959 private native void nativeOnResetDeviceCredentialsCompleted(
952 long nativeMediaDrmBridge, boolean success); 960 long nativeMediaDrmBridge, boolean success);
953 961
954 private static native void nativeAddKeySystemUuidMapping(String keySystem, B yteBuffer uuid); 962 private static native void nativeAddKeySystemUuidMapping(String keySystem, B yteBuffer uuid);
955 } 963 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698