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

Unified Diff: android_webview/native/aw_gl_functor.cc

Issue 1914433002: Assert that AwGLFunctor instances do not leak. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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/aw_gl_functor.cc
diff --git a/android_webview/native/aw_gl_functor.cc b/android_webview/native/aw_gl_functor.cc
index 60e3f05be8978d094df8e2ac460e2dbb9ca36a5f..722db8eddf2bf51e8912231b2f62987a963d2c16 100644
--- a/android_webview/native/aw_gl_functor.cc
+++ b/android_webview/native/aw_gl_functor.cc
@@ -26,14 +26,22 @@ static void DrawGLFunction(long view_context,
namespace android_webview {
+namespace {
+int g_instance_count = 0;
+}
+
AwGLFunctor::AwGLFunctor(const JavaObjectWeakGlobalRef& java_ref)
: java_ref_(java_ref),
render_thread_manager_(
this,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)),
- browser_view_renderer_(nullptr) {}
+ browser_view_renderer_(nullptr) {
+ ++g_instance_count;
boliu 2016/04/22 15:51:53 should add threadchecks to where g_instance_count
+}
-AwGLFunctor::~AwGLFunctor() {}
+AwGLFunctor::~AwGLFunctor() {
+ --g_instance_count;
+}
void AwGLFunctor::OnParentDrawConstraintsUpdated() {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
@@ -82,6 +90,11 @@ jlong AwGLFunctor::GetAwDrawGLViewContext(
return reinterpret_cast<intptr_t>(&render_thread_manager_);
}
+// static
+jint GetNativeInstanceCount(JNIEnv* env, const JavaParamRef<jclass>&) {
+ return g_instance_count;
+}
+
static jlong GetAwDrawGLFunction(JNIEnv* env, const JavaParamRef<jclass>&) {
return reinterpret_cast<intptr_t>(&DrawGLFunction);
}

Powered by Google App Engine
This is Rietveld 408576698