| Left: | ||
| Right: |
| 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-present eyeo GmbH | 3 * Copyright (C) 2006-present 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 1012 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 d("Requesting elemhide selectors from AdblockEngine for " + url + " in " + this); | 1025 d("Requesting elemhide selectors from AdblockEngine for " + url + " in " + this); |
| 1026 List<String> selectors = adblockEngine.getElementHidingSelectors(url, domain, referrers); | 1026 List<String> selectors = adblockEngine.getElementHidingSelectors(url, domain, referrers); |
| 1027 d("Finished requesting elemhide selectors, got " + selectors.size() + " in " + this); | 1027 d("Finished requesting elemhide selectors, got " + selectors.size() + " in " + this); |
| 1028 selectorsString = Utils.stringListToJsonArray(selectors); | 1028 selectorsString = Utils.stringListToJsonArray(selectors); |
| 1029 } | 1029 } |
| 1030 } | 1030 } |
| 1031 finally | 1031 finally |
| 1032 { | 1032 { |
| 1033 if (!isCancelled.get()) | 1033 if (isCancelled.get()) |
| 1034 { | 1034 { |
| 1035 finish(selectorsString); | 1035 w("This thread is cancelled, exiting silently " + this); |
| 1036 } | 1036 } |
| 1037 else | 1037 else |
| 1038 { | 1038 { |
| 1039 w("This thread is cancelled, exiting silently " + this); | 1039 finish(selectorsString); |
| 1040 } | 1040 } |
| 1041 } | 1041 } |
| 1042 } | 1042 } |
| 1043 | 1043 |
| 1044 private void onFinished() | 1044 private void onFinished() |
| 1045 { | 1045 { |
| 1046 finishedLatch.countDown(); | 1046 finishedLatch.countDown(); |
| 1047 synchronized (finishedRunnableLockObject) | 1047 synchronized (finishedRunnableLockObject) |
| 1048 { | 1048 { |
| 1049 if (finishedRunnable != null) | 1049 if (finishedRunnable != null) |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1068 { | 1068 { |
| 1069 synchronized (finishedRunnableLockObject) | 1069 synchronized (finishedRunnableLockObject) |
| 1070 { | 1070 { |
| 1071 this.finishedRunnable = runnable; | 1071 this.finishedRunnable = runnable; |
| 1072 } | 1072 } |
| 1073 } | 1073 } |
| 1074 | 1074 |
| 1075 public void cancel() | 1075 public void cancel() |
| 1076 { | 1076 { |
| 1077 w("Cancelling elemhide thread " + this); | 1077 w("Cancelling elemhide thread " + this); |
| 1078 if (!isFinished.get()) | 1078 if (isFinished.get()) |
|
jens
2018/01/17 08:28:43
To make the if statement more readable, I would pr
anton
2018/01/17 08:33:55
Done. See patch set #2
| |
| 1079 { | |
| 1080 w("This thread is finished, exiting silently " + this); | |
| 1081 } | |
| 1082 else | |
| 1079 { | 1083 { |
| 1080 isCancelled.set(true); | 1084 isCancelled.set(true); |
| 1081 finish(EMPTY_ELEMHIDE_ARRAY_STRING); | 1085 finish(EMPTY_ELEMHIDE_ARRAY_STRING); |
| 1082 } | |
| 1083 else | |
| 1084 { | |
| 1085 w("This thread is finished, exiting silently " + this); | |
| 1086 } | 1086 } |
| 1087 } | 1087 } |
| 1088 } | 1088 } |
| 1089 | 1089 |
| 1090 private Runnable elemHideThreadFinishedRunnable = new Runnable() | 1090 private Runnable elemHideThreadFinishedRunnable = new Runnable() |
| 1091 { | 1091 { |
| 1092 @Override | 1092 @Override |
| 1093 public void run() | 1093 public void run() |
| 1094 { | 1094 { |
| 1095 synchronized (elemHideThreadLockObject) | 1095 synchronized (elemHideThreadLockObject) |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1445 w("Busy with elemhide selectors, delayed disposing scheduled"); | 1445 w("Busy with elemhide selectors, delayed disposing scheduled"); |
| 1446 elemHideThread.setFinishedRunnable(disposeRunnable); | 1446 elemHideThread.setFinishedRunnable(disposeRunnable); |
| 1447 } | 1447 } |
| 1448 else | 1448 else |
| 1449 { | 1449 { |
| 1450 disposeRunnable.run(); | 1450 disposeRunnable.run(); |
| 1451 } | 1451 } |
| 1452 } | 1452 } |
| 1453 } | 1453 } |
| 1454 } | 1454 } |
| LEFT | RIGHT |