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

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

Issue 6680224334872576: Issue 303 - Don't load element hiding rules (Closed)
Left Patch Set: Created Nov. 6, 2014, 1:36 p.m.
Right Patch Set: URL query removal Created Feb. 4, 2015, 12:08 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 | « no previous file | src/org/adblockplus/android/AndroidWebRequest.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 12 matching lines...) Expand all
23 import org.adblockplus.libadblockplus.AppInfo; 23 import org.adblockplus.libadblockplus.AppInfo;
24 import org.adblockplus.libadblockplus.Filter; 24 import org.adblockplus.libadblockplus.Filter;
25 import org.adblockplus.libadblockplus.FilterChangeCallback; 25 import org.adblockplus.libadblockplus.FilterChangeCallback;
26 import org.adblockplus.libadblockplus.FilterEngine; 26 import org.adblockplus.libadblockplus.FilterEngine;
27 import org.adblockplus.libadblockplus.FilterEngine.ContentType; 27 import org.adblockplus.libadblockplus.FilterEngine.ContentType;
28 import org.adblockplus.libadblockplus.JsEngine; 28 import org.adblockplus.libadblockplus.JsEngine;
29 import org.adblockplus.libadblockplus.LogSystem; 29 import org.adblockplus.libadblockplus.LogSystem;
30 import org.adblockplus.libadblockplus.Subscription; 30 import org.adblockplus.libadblockplus.Subscription;
31 import org.adblockplus.libadblockplus.UpdateAvailableCallback; 31 import org.adblockplus.libadblockplus.UpdateAvailableCallback;
32 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback; 32 import org.adblockplus.libadblockplus.UpdateCheckDoneCallback;
33 import org.adblockplus.libadblockplus.WebRequest;
34 33
35 import android.content.Context; 34 import android.content.Context;
36 import android.content.pm.PackageInfo; 35 import android.content.pm.PackageInfo;
37 import android.content.pm.PackageManager.NameNotFoundException; 36 import android.content.pm.PackageManager.NameNotFoundException;
38 import android.os.Build.VERSION; 37 import android.os.Build.VERSION;
39 import android.util.Log; 38 import android.util.Log;
40 39
41 public final class ABPEngine 40 public final class ABPEngine
42 { 41 {
43 private static final String TAG = Utils.getTag(ABPEngine.class); 42 private static final String TAG = Utils.getTag(ABPEngine.class);
44 43
45 private final Context context; 44 private final Context context;
46 45
47 /* 46 /*
48 * The fields below are volatile because: 47 * The fields below are volatile because:
49 * 48 *
50 * I encountered JNI related bugs/crashes caused by JNI backed Java objects. I t seemed that under 49 * I encountered JNI related bugs/crashes caused by JNI backed Java objects. I t seemed that under
51 * certain conditions the objects were optimized away which resulted in crashe s when trying to 50 * certain conditions the objects were optimized away which resulted in crashe s when trying to
52 * release the object, sometimes even on access. 51 * release the object, sometimes even on access.
53 * 52 *
54 * The only solution that really worked was to declare the variables holding t he references 53 * The only solution that really worked was to declare the variables holding t he references
55 * volatile, this seems to prevent the JNI from 'optimizing away' those object s (as a volatile 54 * volatile, this seems to prevent the JNI from 'optimizing away' those object s (as a volatile
56 * variable might be changed at any time from any thread). 55 * variable might be changed at any time from any thread).
57 */ 56 */
58 private volatile JsEngine jsEngine; 57 private volatile JsEngine jsEngine;
59 private volatile FilterEngine filterEngine; 58 private volatile FilterEngine filterEngine;
60 private volatile LogSystem logSystem; 59 private volatile LogSystem logSystem;
61 private volatile WebRequest webRequest; 60 private volatile AndroidWebRequest webRequest;
62 private volatile UpdateAvailableCallback updateAvailableCallback; 61 private volatile UpdateAvailableCallback updateAvailableCallback;
63 private volatile UpdateCheckDoneCallback updateCheckDoneCallback; 62 private volatile UpdateCheckDoneCallback updateCheckDoneCallback;
64 private volatile FilterChangeCallback filterChangeCallback; 63 private volatile FilterChangeCallback filterChangeCallback;
65 64
66 private ABPEngine(final Context context) 65 private ABPEngine(final Context context)
67 { 66 {
68 this.context = context; 67 this.context = context;
69 } 68 }
70 69
71 public static AppInfo generateAppInfo(final Context context) 70 public static AppInfo generateAppInfo(final Context context)
(...skipping 29 matching lines...) Expand all
101 engine.jsEngine = new JsEngine(appInfo); 100 engine.jsEngine = new JsEngine(appInfo);
102 engine.jsEngine.setDefaultFileSystem(basePath); 101 engine.jsEngine.setDefaultFileSystem(basePath);
103 102
104 engine.logSystem = new AndroidLogSystem(); 103 engine.logSystem = new AndroidLogSystem();
105 engine.jsEngine.setLogSystem(engine.logSystem); 104 engine.jsEngine.setLogSystem(engine.logSystem);
106 105
107 engine.webRequest = new AndroidWebRequest(); 106 engine.webRequest = new AndroidWebRequest();
108 engine.jsEngine.setWebRequest(engine.webRequest); 107 engine.jsEngine.setWebRequest(engine.webRequest);
109 108
110 engine.filterEngine = new FilterEngine(engine.jsEngine); 109 engine.filterEngine = new FilterEngine(engine.jsEngine);
110
111 engine.webRequest.updateSubscriptionURLs(engine.filterEngine);
112
111 engine.updateAvailableCallback = new AndroidUpdateAvailableCallback(context) ; 113 engine.updateAvailableCallback = new AndroidUpdateAvailableCallback(context) ;
112 engine.filterEngine.setUpdateAvailableCallback(engine.updateAvailableCallbac k); 114 engine.filterEngine.setUpdateAvailableCallback(engine.updateAvailableCallbac k);
113 engine.filterChangeCallback = new AndroidFilterChangeCallback(context); 115 engine.filterChangeCallback = new AndroidFilterChangeCallback(context);
114 engine.filterEngine.setFilterChangeCallback(engine.filterChangeCallback); 116 engine.filterEngine.setFilterChangeCallback(engine.filterChangeCallback);
115 117
116 engine.updateCheckDoneCallback = new AndroidUpdateCheckDoneCallback(context) ; 118 engine.updateCheckDoneCallback = new AndroidUpdateCheckDoneCallback(context) ;
117 119
118 return engine; 120 return engine;
119 } 121 }
120 122
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 274
273 public void updateSubscriptionStatus(final String url) 275 public void updateSubscriptionStatus(final String url)
274 { 276 {
275 final Subscription sub = this.filterEngine.getSubscription(url); 277 final Subscription sub = this.filterEngine.getSubscription(url);
276 if (sub != null) 278 if (sub != null)
277 { 279 {
278 Utils.updateSubscriptionStatus(this.context, sub); 280 Utils.updateSubscriptionStatus(this.context, sub);
279 } 281 }
280 } 282 }
281 } 283 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld