Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: jni/JniCallbacks.cpp

Issue 6606493159784448: New JNI bindings (Closed)
Patch Set: Added missing empty lines after file comments Created April 2, 2014, 8:49 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « jni/JniCallbacks.h ('k') | jni/JniEventCallback.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jni/JniCallbacks.cpp
diff --git a/jni/JniCallbacks.cpp b/jni/JniCallbacks.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..92097fd623df7a027cac6af300bc14ff7696fe6a
--- /dev/null
+++ b/jni/JniCallbacks.cpp
@@ -0,0 +1,49 @@
+/*
+ * This file is part of Adblock Plus <http://adblockplus.org/>,
+ * Copyright (C) 2006-2014 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "JniCallbacks.h"
+
+JniCallbackBase::JniCallbackBase(JNIEnv* env, jobject callbackObject)
+{
+ env->GetJavaVM(&javaVM);
+ this->callbackObject.reset(new JniGlobalReference<jobject>(env, callbackObject));
+ exceptionLoggerClass.reset(new JniGlobalReference<jclass>(env, env->FindClass(PKG("JniExceptionHandler"))));
+}
+
+JniCallbackBase::~JniCallbackBase()
+{
+
+}
+
+void JniCallbackBase::LogException(JNIEnv* env, jthrowable throwable) const
+{
+ jmethodID logMethod = env->GetStaticMethodID(exceptionLoggerClass->Get(), "logException", "(Ljava/lang/Throwable;)V");
+ if (logMethod)
+ {
+ env->CallStaticVoidMethod(exceptionLoggerClass->Get(), logMethod, throwable);
+ }
+}
+
+void JniCallbackBase::CheckAndLogJavaException(JNIEnv* env) const
+{
+ if (env->ExceptionCheck())
+ {
+ jthrowable throwable = env->ExceptionOccurred();
+ env->ExceptionClear();
+ LogException(env, throwable);
+ }
+}
« no previous file with comments | « jni/JniCallbacks.h ('k') | jni/JniEventCallback.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld