Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions java/org/cef/browser/CefDevToolsClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public void onDevToolsMethodResult(
future.completeExceptionally(
new DevToolsException("DevTools method failed", result));
}
removeQueuedCommand(messageId);
}

@Override
Expand All @@ -63,10 +62,6 @@ private CompletableFuture<String> getQueuedCommand(Integer messageId) {
return queuedCommands_.computeIfAbsent(messageId, key -> new CompletableFuture<>());
}

private void removeQueuedCommand(Integer messageId) {
queuedCommands_.remove(messageId);
}

/**
* Execute a method call over the DevTools protocol. See the <a
* href=https://chromedevtools.github.io/devtools-protocol/> DevTools protocol documentation</a>
Expand Down Expand Up @@ -105,8 +100,11 @@ public CompletableFuture<String> executeDevToolsMethod(String method, String par
return future;
}

return browser_.executeDevToolsMethod(method, parametersAsJson)
.thenCompose(this::getQueuedCommand);
return browser_.executeDevToolsMethod(method, parametersAsJson).thenCompose(messageId -> {
CompletableFuture<String> queuedCommand = getQueuedCommand(messageId);
return queuedCommand.whenComplete(
(result, throwable) -> queuedCommands_.remove(messageId, queuedCommand));
});
}

/**
Expand Down