| 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/single_thread_task_runner.h" |
| 18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 19 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 20 #include "base/sys_byteorder.h" | 20 #include "base/sys_byteorder.h" |
| 21 #include "base/sys_info.h" | 21 #include "base/sys_info.h" |
| 22 #include "base/thread_task_runner_handle.h" |
| 22 #include "jni/MediaDrmBridge_jni.h" | 23 #include "jni/MediaDrmBridge_jni.h" |
| 23 #include "media/base/android/media_client_android.h" | 24 #include "media/base/android/media_client_android.h" |
| 24 #include "media/base/android/media_drm_bridge_delegate.h" | 25 #include "media/base/android/media_drm_bridge_delegate.h" |
| 25 #include "media/base/cdm_key_information.h" | 26 #include "media/base/cdm_key_information.h" |
| 26 | 27 |
| 27 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. | 28 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. |
| 28 | 29 |
| 29 using base::android::AttachCurrentThread; | 30 using base::android::AttachCurrentThread; |
| 30 using base::android::ConvertUTF8ToJavaString; | 31 using base::android::ConvertUTF8ToJavaString; |
| 31 using base::android::ConvertJavaStringToUTF8; | 32 using base::android::ConvertJavaStringToUTF8; |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 | 408 |
| 408 void MediaDrmBridge::SetMediaCryptoReadyCB(const base::Closure& closure) { | 409 void MediaDrmBridge::SetMediaCryptoReadyCB(const base::Closure& closure) { |
| 409 if (closure.is_null()) { | 410 if (closure.is_null()) { |
| 410 media_crypto_ready_cb_.Reset(); | 411 media_crypto_ready_cb_.Reset(); |
| 411 return; | 412 return; |
| 412 } | 413 } |
| 413 | 414 |
| 414 DCHECK(media_crypto_ready_cb_.is_null()); | 415 DCHECK(media_crypto_ready_cb_.is_null()); |
| 415 | 416 |
| 416 if (!GetMediaCrypto().is_null()) { | 417 if (!GetMediaCrypto().is_null()) { |
| 417 base::MessageLoopProxy::current()->PostTask(FROM_HERE, closure); | 418 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, closure); |
| 418 return; | 419 return; |
| 419 } | 420 } |
| 420 | 421 |
| 421 media_crypto_ready_cb_ = closure; | 422 media_crypto_ready_cb_ = closure; |
| 422 } | 423 } |
| 423 | 424 |
| 424 void MediaDrmBridge::OnMediaCryptoReady(JNIEnv* env, jobject) { | 425 void MediaDrmBridge::OnMediaCryptoReady(JNIEnv* env, jobject) { |
| 425 DCHECK(!GetMediaCrypto().is_null()); | 426 DCHECK(!GetMediaCrypto().is_null()); |
| 426 if (!media_crypto_ready_cb_.is_null()) | 427 if (!media_crypto_ready_cb_.is_null()) |
| 427 base::ResetAndReturn(&media_crypto_ready_cb_).Run(); | 428 base::ResetAndReturn(&media_crypto_ready_cb_).Run(); |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 JNIEnv* env = AttachCurrentThread(); | 534 JNIEnv* env = AttachCurrentThread(); |
| 534 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); | 535 Java_MediaDrmBridge_resetDeviceCredentials(env, j_media_drm_.obj()); |
| 535 } | 536 } |
| 536 | 537 |
| 537 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( | 538 void MediaDrmBridge::OnResetDeviceCredentialsCompleted( |
| 538 JNIEnv* env, jobject, bool success) { | 539 JNIEnv* env, jobject, bool success) { |
| 539 base::ResetAndReturn(&reset_credentials_cb_).Run(success); | 540 base::ResetAndReturn(&reset_credentials_cb_).Run(success); |
| 540 } | 541 } |
| 541 | 542 |
| 542 } // namespace media | 543 } // namespace media |
| OLD | NEW |