LEFT | RIGHT |
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-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 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 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 } | 242 } |
243 | 243 |
244 public static Builder builder(AppInfo appInfo, String basePath) | 244 public static Builder builder(AppInfo appInfo, String basePath) |
245 { | 245 { |
246 return new Builder(appInfo, basePath); | 246 return new Builder(appInfo, basePath); |
247 } | 247 } |
248 | 248 |
249 private final AndroidWebRequestResourceWrapper.Listener resourceWrapperListene
r = | 249 private final AndroidWebRequestResourceWrapper.Listener resourceWrapperListene
r = |
250 new AndroidWebRequestResourceWrapper.Listener() | 250 new AndroidWebRequestResourceWrapper.Listener() |
251 { | 251 { |
252 private static final int REFRESH_DELAY_MS = 1 * 1000; | 252 private static final int UPDATE_DELAY_MS = 1 * 1000; |
253 | 253 |
254 private final Handler handler = new Handler(Looper.getMainLooper()); | 254 private final Handler handler = new Handler(Looper.getMainLooper()); |
255 | 255 |
256 private final Runnable forceRefreshRunnable = new Runnable() | 256 private final Runnable forceUpdateRunnable = new Runnable() |
257 { | 257 { |
258 public void run() { | 258 public void run() { |
259 // Filter Engine can be already disposed | 259 // Filter Engine can be already disposed |
260 if (filterEngine != null) | 260 if (filterEngine != null) |
261 { | 261 { |
262 Log.d(TAG, "Force refresh subscriptions"); | 262 Log.d(TAG, "Force update subscriptions"); |
263 AdblockEngine.this.refreshSubscriptions(); | 263 AdblockEngine.this.updateSubscriptions(); |
264 } | 264 } |
265 } | 265 } |
266 }; | 266 }; |
267 | 267 |
268 @Override | 268 @Override |
269 public void onIntercepted(String url, int resourceId) | 269 public void onIntercepted(String url, int resourceId) |
270 { | 270 { |
271 // we need to force refresh subscriptions ASAP after preloaded one is retu
rned | 271 // we need to force update subscriptions ASAP after preloaded one is retur
ned |
272 // but we should note that multiple interceptions (for main easylist and A
A) and force refresh once only | 272 // but we should note that multiple interceptions (for main easylist and A
A) and force update once only |
273 | 273 |
274 // adding into main thread queue to avoid concurrency issues (start refres
h while refreshing) | 274 // adding into main thread queue to avoid concurrency issues (start update
while updating) |
275 // as usually onIntercepted() is invoked in background thread | 275 // as usually onIntercepted() is invoked in background thread |
276 handler.removeCallbacks(forceRefreshRunnable); | 276 handler.removeCallbacks(forceUpdateRunnable); |
277 handler.postDelayed(forceRefreshRunnable, REFRESH_DELAY_MS); | 277 handler.postDelayed(forceUpdateRunnable, UPDATE_DELAY_MS); |
278 | 278 |
279 Log.d(TAG, "Scheduled force refresh in " + REFRESH_DELAY_MS); | 279 Log.d(TAG, "Scheduled force update in " + UPDATE_DELAY_MS); |
280 } | 280 } |
281 }; | 281 }; |
282 | 282 |
283 public void dispose() | 283 public void dispose() |
284 { | 284 { |
285 Log.w(TAG, "Dispose"); | 285 Log.w(TAG, "Dispose"); |
286 | 286 |
287 // engines first | 287 // engines first |
288 if (this.filterEngine != null) | 288 if (this.filterEngine != null) |
289 { | 289 { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 sub.addToList(); | 475 sub.addToList(); |
476 } | 476 } |
477 finally | 477 finally |
478 { | 478 { |
479 sub.dispose(); | 479 sub.dispose(); |
480 } | 480 } |
481 } | 481 } |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 public void refreshSubscriptions() | 485 public void updateSubscriptions() |
486 { | 486 { |
487 for (final Subscription s : this.filterEngine.getListedSubscriptions()) | 487 for (final Subscription s : this.filterEngine.getListedSubscriptions()) |
488 { | 488 { |
489 try | 489 try |
490 { | 490 { |
491 s.updateFilters(); | 491 s.updateFilters(); |
492 } | 492 } |
493 finally | 493 finally |
494 { | 494 { |
495 s.dispose(); | 495 s.dispose(); |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
714 public void setWhitelistedDomains(List<String> domains) | 714 public void setWhitelistedDomains(List<String> domains) |
715 { | 715 { |
716 this.whitelistedDomains = domains; | 716 this.whitelistedDomains = domains; |
717 } | 717 } |
718 | 718 |
719 public List<String> getWhitelistedDomains() | 719 public List<String> getWhitelistedDomains() |
720 { | 720 { |
721 return whitelistedDomains; | 721 return whitelistedDomains; |
722 } | 722 } |
723 } | 723 } |
LEFT | RIGHT |