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

Side by Side Diff: chromecast/browser/android/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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chromecast/browser/android/external_video_surface_container_impl.h" 5 #include "chromecast/browser/android/external_video_surface_container_impl.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "content/public/browser/android/content_view_core.h" 8 #include "content/public/browser/android/content_view_core.h"
9 #include "jni/ExternalVideoSurfaceContainer_jni.h" 9 #include "jni/ExternalVideoSurfaceContainer_jni.h"
10 #include "ui/gfx/geometry/rect_f.h" 10 #include "ui/gfx/geometry/rect_f.h"
11 11
12 namespace chromecast { 12 namespace chromecast {
13 namespace shell { 13 namespace shell {
14 14 // static
15 ExternalVideoSurfaceContainerImpl::ExternalVideoSurfaceContainerImpl( 15 ExternalVideoSurfaceContainerImpl* ExternalVideoSurfaceContainerImpl::Create(
16 content::WebContents* web_contents) { 16 content::WebContents* web_contents) {
17 content::ContentViewCore* cvc = 17 content::ContentViewCore* cvc =
18 content::ContentViewCore::FromWebContents(web_contents); 18 content::ContentViewCore::FromWebContents(web_contents);
19 if (cvc) { 19 if (!cvc)
20 JNIEnv* env = base::android::AttachCurrentThread(); 20 return nullptr;
21 jobject_.Reset( 21 base::android::ScopedJavaLocalRef<jobject> jcvc = cvc->GetJavaObject();
22 Java_ExternalVideoSurfaceContainer_create( 22 if (jcvc.is_null())
23 env, reinterpret_cast<intptr_t>(this), cvc->GetJavaObject().obj())); 23 return nullptr;
24 } 24 return new ExternalVideoSurfaceContainerImpl(jcvc);
25 }
26
27 ExternalVideoSurfaceContainerImpl::ExternalVideoSurfaceContainerImpl(
28 base::android::ScopedJavaLocalRef<jobject> java_content_view_core) {
29 JNIEnv* env = base::android::AttachCurrentThread();
30 jobject_.Reset(Java_ExternalVideoSurfaceContainer_create(
31 env, reinterpret_cast<intptr_t>(this), java_content_view_core.obj()));
25 } 32 }
26 33
27 ExternalVideoSurfaceContainerImpl::~ExternalVideoSurfaceContainerImpl() { 34 ExternalVideoSurfaceContainerImpl::~ExternalVideoSurfaceContainerImpl() {
28 JNIEnv* env = base::android::AttachCurrentThread(); 35 JNIEnv* env = base::android::AttachCurrentThread();
29 Java_ExternalVideoSurfaceContainer_destroy(env, jobject_.obj()); 36 Java_ExternalVideoSurfaceContainer_destroy(env, jobject_.obj());
30 jobject_.Reset(); 37 jobject_.Reset();
31 } 38 }
32 39
33 void ExternalVideoSurfaceContainerImpl::RequestExternalVideoSurface( 40 void ExternalVideoSurfaceContainerImpl::RequestExternalVideoSurface(
34 int player_id, 41 int player_id,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (!surface_destroyed_cb_.is_null()) 102 if (!surface_destroyed_cb_.is_null())
96 surface_destroyed_cb_.Run(static_cast<int>(player_id)); 103 surface_destroyed_cb_.Run(static_cast<int>(player_id));
97 } 104 }
98 105
99 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) { 106 bool RegisterExternalVideoSurfaceContainer(JNIEnv* env) {
100 return RegisterNativesImpl(env); 107 return RegisterNativesImpl(env);
101 } 108 }
102 109
103 } // namespace shell 110 } // namespace shell
104 } // namespace chromecast 111 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698