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

Delta Between Two Patch Sets: jni/JniCallbacks.h

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

Powered by Google App Engine
This is Rietveld