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

Unified Diff: jni/JniCallbacks.h

Issue 6606493159784448: New JNI bindings (Closed)
Patch Set: Removed TODO from AppInfo. Created April 11, 2014, 1:28 p.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/Android.mk ('k') | jni/JniCallbacks.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: jni/JniCallbacks.h
diff --git a/jni/JniCallbacks.h b/jni/JniCallbacks.h
new file mode 100644
index 0000000000000000000000000000000000000000..38e520bc53732fe3ca0bb68a093426be5f0556f6
--- /dev/null
+++ b/jni/JniCallbacks.h
@@ -0,0 +1,93 @@
+/*
+ * 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/>.
+ */
+
+#ifndef JNICALLBACKS_H
+#define JNICALLBACKS_H
+
+#include <AdblockPlus.h>
+#include "Utils.h"
+#include "JniJsValue.h"
+
+class JniCallbackBase
+{
+public:
+ JniCallbackBase(JNIEnv* env, jobject callbackObject);
+ virtual ~JniCallbackBase();
+ void LogException(JNIEnv* env, jthrowable throwable) const;
+ void CheckAndLogJavaException(JNIEnv* env) const;
+
+ JavaVM* GetJavaVM() const
+ {
+ return javaVM;
+ }
+
+ jobject GetCallbackObject() const
+ {
+ return callbackObject->Get();
+ }
+
+private:
+ JavaVM* javaVM;
+ JniGlobalReference<jobject>::Ptr callbackObject;
+ JniGlobalReference<jclass>::Ptr exceptionLoggerClass;
+};
+
+class JniEventCallback : public JniCallbackBase
+{
+public:
+ JniEventCallback(JNIEnv* env, jobject callbackObject);
+ void Callback(AdblockPlus::JsValueList& params);
+};
+
+class JniUpdaterCallback : public JniCallbackBase
+{
+public:
+ JniUpdaterCallback(JNIEnv* env, jobject callbackObject);
+ void Callback(const std::string& arg);
+};
+
+class JniFilterChangeCallback : public JniCallbackBase
+{
+public:
+ JniFilterChangeCallback(JNIEnv* env, jobject callbackObject);
+ void Callback(const std::string& arg, const AdblockPlus::JsValuePtr jsValue);
+};
+
+class JniLogSystemCallback : public JniCallbackBase, public AdblockPlus::LogSystem
+{
+public:
+ JniLogSystemCallback(JNIEnv* env, jobject callbackObject);
+ void operator()(AdblockPlus::LogSystem::LogLevel logLevel, const std::string& message, const std::string& source);
+
+private:
+ JniGlobalReference<jclass>::Ptr logLevelClass;
+};
+
+class JniWebRequest : public JniCallbackBase, public AdblockPlus::WebRequest
+{
+public:
+ JniWebRequest(JNIEnv* env, jobject callbackObject);
+ AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::HeaderList& requestHeaders) const;
+
+private:
+ jobject NewTuple(JNIEnv* env, const std::string& a, const std::string& b) const;
+
+ JniGlobalReference<jclass>::Ptr tupleClass;
+ JniGlobalReference<jclass>::Ptr serverResponseClass;
+};
+
+#endif /* JNICALLBACKS_H */
« no previous file with comments | « jni/Android.mk ('k') | jni/JniCallbacks.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld