mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Only unsubscribe from specified parentId
PiperOrigin-RevId: 422331961
This commit is contained in:
parent
cd56084b3e
commit
86fdbd6f6b
1 changed files with 14 additions and 8 deletions
|
|
@ -183,9 +183,7 @@ import java.util.concurrent.Future;
|
||||||
() -> {
|
() -> {
|
||||||
@Nullable LibraryResult<Void> result = tryGetFutureResult(future);
|
@Nullable LibraryResult<Void> result = tryGetFutureResult(future);
|
||||||
if (result == null || result.resultCode != RESULT_SUCCESS) {
|
if (result == null || result.resultCode != RESULT_SUCCESS) {
|
||||||
synchronized (lock) {
|
removeSubscription(controller, parentId);
|
||||||
subscriptions.remove(checkStateNotNull(browser.getControllerCb()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
MoreExecutors.directExecutor());
|
MoreExecutors.directExecutor());
|
||||||
|
|
@ -203,11 +201,7 @@ import java.util.concurrent.Future;
|
||||||
"onUnsubscribe must return non-null future");
|
"onUnsubscribe must return non-null future");
|
||||||
|
|
||||||
future.addListener(
|
future.addListener(
|
||||||
() -> {
|
() -> removeSubscription(checkStateNotNull(browser.getControllerCb()), parentId),
|
||||||
synchronized (lock) {
|
|
||||||
subscriptions.remove(checkStateNotNull(browser.getControllerCb()));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
MoreExecutors.directExecutor());
|
MoreExecutors.directExecutor());
|
||||||
|
|
||||||
return future;
|
return future;
|
||||||
|
|
@ -307,4 +301,16 @@ import java.util.concurrent.Future;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeSubscription(ControllerCb controllerCb, String parentId) {
|
||||||
|
synchronized (lock) {
|
||||||
|
@Nullable Set<String> subscription = subscriptions.get(controllerCb);
|
||||||
|
if (subscription != null) {
|
||||||
|
subscription.remove(parentId);
|
||||||
|
if (subscription.isEmpty()) {
|
||||||
|
subscriptions.remove(controllerCb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue