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" |
17 #include "base/numerics/safe_conversions.h" | 18 #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" | |
24 #include "jni/MediaDrmBridge_jni.h" | 23 #include "jni/MediaDrmBridge_jni.h" |
25 #include "media/base/cdm_key_information.h" | 24 #include "media/base/cdm_key_information.h" |
26 | 25 |
27 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 26 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
28 | 27 |
29 using base::android::AttachCurrentThread; | 28 using base::android::AttachCurrentThread; |
30 using base::android::ConvertUTF8ToJavaString; | 29 using base::android::ConvertUTF8ToJavaString; |
31 using base::android::ConvertJavaStringToUTF8; | 30 using base::android::ConvertJavaStringToUTF8; |
32 using base::android::JavaByteArrayToByteVector; | 31 using base::android::JavaByteArrayToByteVector; |
33 using base::android::ScopedJavaLocalRef; | 32 using base::android::ScopedJavaLocalRef; |
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 | 531 |
533 void MediaDrmBridge::SetMediaCryptoReadyCB(const base::Closure& closure) { | 532 void MediaDrmBridge::SetMediaCryptoReadyCB(const base::Closure& closure) { |
534 if (closure.is_null()) { | 533 if (closure.is_null()) { |
535 media_crypto_ready_cb_.Reset(); | 534 media_crypto_ready_cb_.Reset(); |
536 return; | 535 return; |
537 } | 536 } |
538 | 537 |
539 DCHECK(media_crypto_ready_cb_.is_null()); | 538 DCHECK(media_crypto_ready_cb_.is_null()); |
540 | 539 |
541 if (!GetMediaCrypto().is_null()) { | 540 if (!GetMediaCrypto().is_null()) { |
542 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); | 541 base::MessageLoopProxy::current()->PostTask(FROM_HERE, closure); |
543 return; | 542 return; |
544 } | 543 } |
545 | 544 |
546 media_crypto_ready_cb_ = closure; | 545 media_crypto_ready_cb_ = closure; |
547 } | 546 } |
548 | 547 |
549 void MediaDrmBridge::OnMediaCryptoReady(JNIEnv* env, jobject) { | 548 void MediaDrmBridge::OnMediaCryptoReady(JNIEnv* env, jobject) { |
550 DCHECK(!GetMediaCrypto().is_null()); | 549 DCHECK(!GetMediaCrypto().is_null()); |
551 if (!media_crypto_ready_cb_.is_null()) | 550 if (!media_crypto_ready_cb_.is_null()) |
552 base::ResetAndReturn(&media_crypto_ready_cb_).Run(); | 551 base::ResetAndReturn(&media_crypto_ready_cb_).Run(); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 JNIEnv* env = AttachCurrentThread(); | 657 JNIEnv* env = AttachCurrentThread(); |
659 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); | 658 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); |
660 } | 659 } |
661 | 660 |
662 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( | 661 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( |
663 JNIEnv* env, jobject, bool success) { | 662 JNIEnv* env, jobject, bool success) { |
664 base::ResetAndReturn(&reset_credentials_cb_).Run(success); | 663 base::ResetAndReturn(&reset_credentials_cb_).Run(success); |
665 } | 664 } |
666 | 665 |
667 } // namespace media | 666 } // namespace media |
OLD | NEW |