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

Unified Diff: android_webview/native/external_video_surface_container_impl.cc

Issue 1067023005: Null check ContentViewCore::GetJavaObject (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix chromecast build 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 side-by-side diff with in-line comments
Download patch
Index: android_webview/native/external_video_surface_container_impl.cc
diff --git a/android_webview/native/external_video_surface_container_impl.cc b/android_webview/native/external_video_surface_container_impl.cc
index 84d5ad462651849de4e0f161217c9771d865f85c..64270ef2ac99c8597dec8897bfb6d552e5c5866c 100644
--- a/android_webview/native/external_video_surface_container_impl.cc
+++ b/android_webview/native/external_video_surface_container_impl.cc
@@ -14,15 +14,23 @@ using content::ContentViewCore;
namespace android_webview {
-ExternalVideoSurfaceContainerImpl::ExternalVideoSurfaceContainerImpl(
+// static
+ExternalVideoSurfaceContainerImpl* ExternalVideoSurfaceContainerImpl::Create(
content::WebContents* web_contents) {
ContentViewCore* cvc = ContentViewCore::FromWebContents(web_contents);
- if (cvc) {
- JNIEnv* env = AttachCurrentThread();
- jobject_.Reset(
- Java_ExternalVideoSurfaceContainer_create(
- env, reinterpret_cast<intptr_t>(this), cvc->GetJavaObject().obj()));
- }
+ if (!cvc)
+ return nullptr;
+ base::android::ScopedJavaLocalRef<jobject> jcvc = cvc->GetJavaObject();
+ if (jcvc.is_null())
+ return nullptr;
+ return new ExternalVideoSurfaceContainerImpl(jcvc);
+}
+
+ExternalVideoSurfaceContainerImpl::ExternalVideoSurfaceContainerImpl(
+ base::android::ScopedJavaLocalRef<jobject> java_content_view_core) {
+ JNIEnv* env = AttachCurrentThread();
+ jobject_.Reset(Java_ExternalVideoSurfaceContainer_create(
+ env, reinterpret_cast<intptr_t>(this), java_content_view_core.obj()));
}
ExternalVideoSurfaceContainerImpl::~ExternalVideoSurfaceContainerImpl() {

Powered by Google App Engine
This is Rietveld 408576698