OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "media/base/android/media_drm_bridge.h" | 5 #include "media/base/android/media_drm_bridge.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/android/jni_array.h" | 10 #include "base/android/jni_array.h" |
11 #include "base/android/jni_string.h" | 11 #include "base/android/jni_string.h" |
12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
15 #include "base/location.h" | 15 #include "base/location.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/message_loop/message_loop_proxy.h" | |
18 #include "base/numerics/safe_conversions.h" | 17 #include "base/numerics/safe_conversions.h" |
| 18 #include "base/single_thread_task_runner.h" |
19 #include "base/stl_util.h" | 19 #include "base/stl_util.h" |
20 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
21 #include "base/sys_byteorder.h" | 21 #include "base/sys_byteorder.h" |
22 #include "base/sys_info.h" | 22 #include "base/sys_info.h" |
| 23 #include "base/thread_task_runner_handle.h" |
23 #include "jni/MediaDrmBridge_jni.h" | 24 #include "jni/MediaDrmBridge_jni.h" |
24 #include "media/base/cdm_key_information.h" | 25 #include "media/base/cdm_key_information.h" |
25 | 26 |
26 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 27 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
27 | 28 |
28 using base::android::AttachCurrentThread; | 29 using base::android::AttachCurrentThread; |
29 using base::android::ConvertUTF8ToJavaString; | 30 using base::android::ConvertUTF8ToJavaString; |
30 using base::android::ConvertJavaStringToUTF8; | 31 using base::android::ConvertJavaStringToUTF8; |
31 using base::android::JavaByteArrayToByteVector; | 32 using base::android::JavaByteArrayToByteVector; |
32 using base::android::ScopedJavaLocalRef; | 33 using base::android::ScopedJavaLocalRef; |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 532 |
532 void MediaDrmBridge::SetMediaCryptoReadyCB(const base::Closure& closure) { | 533 void MediaDrmBridge::SetMediaCryptoReadyCB(const base::Closure& closure) { |
533 if (closure.is_null()) { | 534 if (closure.is_null()) { |
534 media_crypto_ready_cb_.Reset(); | 535 media_crypto_ready_cb_.Reset(); |
535 return; | 536 return; |
536 } | 537 } |
537 | 538 |
538 DCHECK(media_crypto_ready_cb_.is_null()); | 539 DCHECK(media_crypto_ready_cb_.is_null()); |
539 | 540 |
540 if (!GetMediaCrypto().is_null()) { | 541 if (!GetMediaCrypto().is_null()) { |
541 base::MessageLoopProxy::current()->PostTask(FROM_HERE, closure); | 542 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); |
542 return; | 543 return; |
543 } | 544 } |
544 | 545 |
545 media_crypto_ready_cb_ = closure; | 546 media_crypto_ready_cb_ = closure; |
546 } | 547 } |
547 | 548 |
548 void MediaDrmBridge::OnMediaCryptoReady(JNIEnv* env, jobject) { | 549 void MediaDrmBridge::OnMediaCryptoReady(JNIEnv* env, jobject) { |
549 DCHECK(!GetMediaCrypto().is_null()); | 550 DCHECK(!GetMediaCrypto().is_null()); |
550 if (!media_crypto_ready_cb_.is_null()) | 551 if (!media_crypto_ready_cb_.is_null()) |
551 base::ResetAndReturn(&media_crypto_ready_cb_).Run(); | 552 base::ResetAndReturn(&media_crypto_ready_cb_).Run(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 JNIEnv* env = AttachCurrentThread(); | 658 JNIEnv* env = AttachCurrentThread(); |
658 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); | 659 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); |
659 } | 660 } |
660 | 661 |
661 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( | 662 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( |
662 JNIEnv* env, jobject, bool success) { | 663 JNIEnv* env, jobject, bool success) { |
663 base::ResetAndReturn(&reset_credentials_cb_).Run(success); | 664 base::ResetAndReturn(&reset_credentials_cb_).Run(success); |
664 } | 665 } |
665 | 666 |
666 } // namespace media | 667 } // namespace media |
OLD | NEW |