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

Unified Diff: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java

Issue 29465639: Issue 5309 - Subscriptions update causes ANR (Closed) Base URL: github.com:abby-sergz/libadblockplus-android.git
Patch Set: remove changes of another codereview@sergz Created June 16, 2017, 1:24 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libadblockplus-android/src/org/adblockplus/libadblockplus/FilterEngine.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
diff --git a/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
index 3afec963c4a28cd2c762b6522536e2daad8c69f9..ab028869be4851aef5b2d266c1cefd7d18c1c4ac 100644
--- a/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
+++ b/libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java
@@ -202,7 +202,18 @@ public final class AdblockEngine
{
AndroidWebRequestResourceWrapper wrapper = new AndroidWebRequestResourceWrapper(
context, engine.webRequest, urlToResourceIdMap, resourceStorage);
- wrapper.setListener(engine.resourceWrapperListener);
+ wrapper.setListener(new AndroidWebRequestResourceWrapper.Listener()
+ {
+ @Override
+ public void onIntercepted(String url, int resourceId)
+ {
+ Log.d(TAG, "Force subscription update for intercepted URL " + url);
+ if (engine.filterEngine != null)
+ {
+ engine.filterEngine.updateFiltersAsync(url);
+ }
+ }
+ });
engine.webRequest = wrapper;
}
@@ -259,40 +270,6 @@ public final class AdblockEngine
return new Builder(appInfo, basePath);
}
- private final AndroidWebRequestResourceWrapper.Listener resourceWrapperListener =
- new AndroidWebRequestResourceWrapper.Listener()
- {
- private static final int UPDATE_DELAY_MS = 1 * 1000;
-
- private final Handler handler = new Handler(Looper.getMainLooper());
-
- private final Runnable forceUpdateRunnable = new Runnable()
- {
- public void run() {
- // Filter Engine can be already disposed
- if (filterEngine != null)
- {
- Log.d(TAG, "Force update subscriptions");
- AdblockEngine.this.updateSubscriptions();
- }
- }
- };
-
- @Override
- public void onIntercepted(String url, int resourceId)
- {
- // we need to force update subscriptions ASAP after preloaded one is returned
- // but we should note that multiple interceptions (for main easylist and AA) and force update once only
-
- // adding into main thread queue to avoid concurrency issues (start update while updating)
- // as usually onIntercepted() is invoked in background thread
- handler.removeCallbacks(forceUpdateRunnable);
- handler.postDelayed(forceUpdateRunnable, UPDATE_DELAY_MS);
-
- Log.d(TAG, "Scheduled force update in " + UPDATE_DELAY_MS);
- }
- };
-
public void dispose()
{
Log.w(TAG, "Dispose");
@@ -495,21 +472,6 @@ public final class AdblockEngine
}
}
- public void updateSubscriptions()
- {
- for (final Subscription s : this.filterEngine.getListedSubscriptions())
- {
- try
- {
- s.updateFilters();
- }
- finally
- {
- s.dispose();
- }
- }
- }
-
public void setEnabled(final boolean enabled)
{
this.enabled = enabled;
« no previous file with comments | « libadblockplus-android/src/org/adblockplus/libadblockplus/FilterEngine.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld