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

Delta Between Two Patch Sets: jni/Utils.cpp

Issue 5327480814567424: Issue 1108 - Support notifications (Closed)
Left Patch Set: Created Jan. 30, 2015, 12:44 p.m.
Right Patch Set: Only one Notification displayed now Created Feb. 18, 2015, 3:42 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « jni/Utils.h ('k') | src/org/adblockplus/android/ABPEngine.java » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 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
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 } 79 }
80 } 80 }
81 81
82 JNIEnvAcquire::~JNIEnvAcquire() 82 JNIEnvAcquire::~JNIEnvAcquire()
83 { 83 {
84 if (attachmentStatus == JNI_EDETACHED) 84 if (attachmentStatus == JNI_EDETACHED)
85 { 85 {
86 javaVM->DetachCurrentThread(); 86 javaVM->DetachCurrentThread();
87 } 87 }
88 } 88 }
89
90 template<typename T>
91 static jobject NewJniObject(JNIEnv* env, const T& value, const char* javaClass)
92 {
93 if (!value.get())
94 {
95 return 0;
96 }
97
98 JniLocalReference<jclass> clazz(
99 env,
100 env->FindClass(javaClass));
101 jmethodID method = env->GetMethodID(*clazz, "<init>", "(J)V");
102
103 return env->NewObject(
104 *clazz,
105 method,
106 JniPtrToLong(new T(value)));
107 }
108
109 jobject NewJniFilter(JNIEnv* env, const AdblockPlus::FilterPtr& filter)
110 {
111 return NewJniObject(env, filter, PKG("Filter"));
112 }
113
114 jobject NewJniSubscription(JNIEnv* env,
115 const AdblockPlus::SubscriptionPtr& subscription)
116 {
117 return NewJniObject(env, subscription, PKG("Subscription"));
118 }
119
120 jobject NewJniNotification(JNIEnv* env,
121 const AdblockPlus::NotificationPtr& notification)
122 {
123 return NewJniObject(env, notification, PKG("Notification"));
124 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld