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

Delta Between Two Patch Sets: src/org/adblockplus/android/ABPEngine.java

Issue 5697499218051072: Usage of new API, cleanups (reduced) (Closed)
Left Patch Set: Adressed first batch of review issues. Created April 16, 2014, 5:36 p.m.
Right Patch Set: Even more review issues fixed. Created April 28, 2014, 10:18 a.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 | « src/org/adblockplus/ChunkedOutputStream.java ('k') | src/org/adblockplus/android/AboutDialog.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
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
(...skipping 24 matching lines...) Expand all
35 import android.content.pm.PackageManager.NameNotFoundException; 35 import android.content.pm.PackageManager.NameNotFoundException;
36 import android.os.Build.VERSION; 36 import android.os.Build.VERSION;
37 import android.util.Log; 37 import android.util.Log;
38 38
39 public final class ABPEngine 39 public final class ABPEngine
40 { 40 {
41 private static final String TAG = Utils.getTag(ABPEngine.class); 41 private static final String TAG = Utils.getTag(ABPEngine.class);
42 42
43 private final Context context; 43 private final Context context;
44 44
45 /*
46 * The fields below are volatile because:
47 *
48 * I encountered JNI related bugs/crashes caused by JNI backed Java objects. I t seemed that under
49 * certain conditions the objects were optimized away which resulted in crashe s when trying to
50 * release the object, sometimes even on access.
51 *
52 * The only solution that really worked was to declare the variables holding t he references
53 * volatile, this seems to prevent the JNI from 'optimizing away' those object s (as a volatile
54 * variable might be changed at any time from any thread).
55 */
45 private volatile JsEngine jsEngine; 56 private volatile JsEngine jsEngine;
46 private volatile FilterEngine filterEngine; 57 private volatile FilterEngine filterEngine;
47 private volatile LogSystem logSystem; 58 private volatile LogSystem logSystem;
48 private volatile WebRequest webRequest; 59 private volatile WebRequest webRequest;
49 private volatile EventCallback updateCallback; 60 private volatile EventCallback updateCallback;
50 private volatile UpdaterCallback updaterCallback; 61 private volatile UpdaterCallback updaterCallback;
51 private volatile FilterChangeCallback filterChangeCallback; 62 private volatile FilterChangeCallback filterChangeCallback;
52 63
53 private ABPEngine(final Context context) 64 private ABPEngine(final Context context)
54 { 65 {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 private static org.adblockplus.android.Subscription convertJsSubscription(fina l Subscription jsSubscription) 169 private static org.adblockplus.android.Subscription convertJsSubscription(fina l Subscription jsSubscription)
159 { 170 {
160 final org.adblockplus.android.Subscription subscription = new org.adblockplu s.android.Subscription(); 171 final org.adblockplus.android.Subscription subscription = new org.adblockplu s.android.Subscription();
161 172
162 subscription.title = jsSubscription.getProperty("title").toString(); 173 subscription.title = jsSubscription.getProperty("title").toString();
163 subscription.url = jsSubscription.getProperty("url").toString(); 174 subscription.url = jsSubscription.getProperty("url").toString();
164 175
165 return subscription; 176 return subscription;
166 } 177 }
167 178
168 private static org.adblockplus.android.Subscription[] convertJsSubscriptions(f inal List<Subscription> subs) 179 private static org.adblockplus.android.Subscription[] convertJsSubscriptions(f inal List<Subscription> jsSubscriptions)
169 { 180 {
170 final org.adblockplus.android.Subscription[] ret = new org.adblockplus.andro id.Subscription[subs.size()]; 181 final org.adblockplus.android.Subscription[] subscriptions = new org.adblock plus.android.Subscription[jsSubscriptions.size()];
171 182
172 for (int i = 0; i < ret.length; i++) 183 for (int i = 0; i < subscriptions.length; i++)
173 { 184 {
174 ret[i] = convertJsSubscription(subs.get(i)); 185 subscriptions[i] = convertJsSubscription(jsSubscriptions.get(i));
175 } 186 }
176 187
177 return ret; 188 return subscriptions;
178 } 189 }
179 190
180 public org.adblockplus.android.Subscription[] getRecommendedSubscriptions() 191 public org.adblockplus.android.Subscription[] getRecommendedSubscriptions()
181 { 192 {
182 return convertJsSubscriptions(this.filterEngine.fetchAvailableSubscriptions( )); 193 return convertJsSubscriptions(this.filterEngine.fetchAvailableSubscriptions( ));
183 } 194 }
184 195
185 public org.adblockplus.android.Subscription[] getListedSubscriptions() 196 public org.adblockplus.android.Subscription[] getListedSubscriptions()
186 { 197 {
187 return convertJsSubscriptions(this.filterEngine.getListedSubscriptions()); 198 return convertJsSubscriptions(this.filterEngine.getListedSubscriptions());
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 272
262 public void updateSubscriptionStatus(final String url) 273 public void updateSubscriptionStatus(final String url)
263 { 274 {
264 final Subscription sub = this.filterEngine.getSubscription(url); 275 final Subscription sub = this.filterEngine.getSubscription(url);
265 if (sub != null) 276 if (sub != null)
266 { 277 {
267 Utils.updateSubscriptionStatus(this.context, sub); 278 Utils.updateSubscriptionStatus(this.context, sub);
268 } 279 }
269 } 280 }
270 } 281 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld