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

Delta Between Two Patch Sets: libadblockplus-android/src/org/adblockplus/libadblockplus/android/AdblockEngine.java

Issue 29401555: Issue 5088 - Remove code duplicate for refresh subscriptions (Closed)
Left Patch Set: Created April 3, 2017, 6:13 a.m.
Right Patch Set: using "update" instead of "refresh" terminology Created April 13, 2017, 9:36 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 | « no previous file | no next file » | 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 <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
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
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
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 }
LEFTRIGHT
« no previous file | no next file » | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld