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

Side by Side Diff: jni/JniCallbacks.h

Issue 6606493159784448: New JNI bindings (Closed)
Patch Set: Bug fix for global references (shadowing) Created March 31, 2014, 2:43 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « jni/Android.mk ('k') | jni/JniCallbacks.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH
4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation.
8 *
9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #ifndef JNICALLBACKS_H
19 #define JNICALLBACKS_H
20
21 #include <AdblockPlus.h>
22 #include "Utils.h"
23 #include "JniJsValue.h"
24
25 class JniCallbackBase
26 {
27 public:
28 JniCallbackBase(JNIEnv* env, jobject callbackObject);
29 virtual ~JniCallbackBase();
30 void LogException(JNIEnv* env, jthrowable throwable) const;
31 void CheckAndLogJavaException(JNIEnv* env) const;
32
33 JavaVM* GetJavaVM() const
34 {
35 return javaVM;
36 }
37
38 jobject GetCallbackObject() const
39 {
40 return callbackObject->Get();
41 }
42
43 private:
44 JavaVM* javaVM;
45 JniGlobalReference<jobject>::Ptr callbackObject;
46 JniGlobalReference<jclass>::Ptr exceptionLoggerClass;
47 };
48
49 class JniEventCallback : public JniCallbackBase
50 {
51 public:
52 JniEventCallback(JNIEnv* env, jobject callbackObject);
53 void Callback(AdblockPlus::JsValueList& params);
54 };
55
56 class JniUpdaterCallback : public JniCallbackBase
57 {
58 public:
59 JniUpdaterCallback(JNIEnv* env, jobject callbackObject);
60 void Callback(const std::string& arg);
61 };
62
63 class JniFilterChangeCallback : public JniCallbackBase
64 {
65 public:
66 JniFilterChangeCallback(JNIEnv* env, jobject callbackObject);
67 void Callback(const std::string& arg, const AdblockPlus::JsValuePtr jsValue);
68 };
69
70 class JniLogSystemCallback : public JniCallbackBase, public AdblockPlus::LogSyst em
71 {
72 public:
73 JniLogSystemCallback(JNIEnv* env, jobject callbackObject);
74 void operator()(AdblockPlus::LogSystem::LogLevel logLevel, const std::string& message, const std::string& source);
75
76 private:
77 JniGlobalReference<jclass>::Ptr logLevelClass;
78 };
79
80 class JniWebRequest : public JniCallbackBase, public AdblockPlus::WebRequest
81 {
82 public:
83 JniWebRequest(JNIEnv* env, jobject callbackObject);
84 AdblockPlus::ServerResponse GET(const std::string& url, const AdblockPlus::Hea derList& requestHeaders) const;
85
86 private:
87 jobject NewTuple(JNIEnv* env, const std::string& a, const std::string& b) cons t;
88
89 JniGlobalReference<jclass>::Ptr tupleClass;
90 JniGlobalReference<jclass>::Ptr serverResponseClass;
91 };
92
93 #endif /* JNICALLBACKS_H */
OLDNEW
« 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