mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 02:14:43 +00:00
Bug 1809755 - Dispatch TCPSocket.ActivateTLS() to the socket thread. r=keeler
Differential Revision: https://phabricator.services.mozilla.com/D168125
This commit is contained in:
parent
a8f8b6f751
commit
4ca8cc8ef0
@ -10,6 +10,7 @@
|
||||
#include "TCPSocketParent.h"
|
||||
#include "mozilla/BasePrincipal.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/SyncRunnable.h"
|
||||
#include "mozilla/dom/RootedDictionary.h"
|
||||
#include "mozilla/dom/ScriptSettings.h"
|
||||
#include "mozilla/dom/TCPSocketBinding.h"
|
||||
@ -455,6 +456,33 @@ void TCPSocket::NotifyCopyComplete(nsresult aStatus) {
|
||||
}
|
||||
|
||||
void TCPSocket::ActivateTLS() {
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIEventTarget> socketThread =
|
||||
do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool alreadyOnSTST = false;
|
||||
if (NS_FAILED(socketThread->IsOnCurrentThread(&alreadyOnSTST))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (alreadyOnSTST) {
|
||||
ActivateTLSHelper();
|
||||
return;
|
||||
}
|
||||
|
||||
auto CallActivateTLS = [sock = RefPtr{this}]() mutable {
|
||||
sock->ActivateTLSHelper();
|
||||
};
|
||||
mozilla::SyncRunnable::DispatchToThread(
|
||||
socketThread,
|
||||
NS_NewRunnableFunction("TCPSocket::UpgradeToSecure->ActivateTLSHelper",
|
||||
CallActivateTLS));
|
||||
}
|
||||
|
||||
void TCPSocket::ActivateTLSHelper() {
|
||||
nsCOMPtr<nsITLSSocketControl> tlsSocketControl;
|
||||
mTransport->GetTlsSocketControl(getter_AddRefs(tlsSocketControl));
|
||||
if (tlsSocketControl) {
|
||||
|
@ -166,7 +166,9 @@ class TCPSocket final : public DOMEventTargetHelper,
|
||||
nsresult EnsureCopying();
|
||||
// Re-calculate buffered amount.
|
||||
void CalculateBufferedAmount();
|
||||
// Enable TLS on this socket.
|
||||
// Helper function, should be called by ActivateTLS(), only.
|
||||
void ActivateTLSHelper();
|
||||
// Enable TLS on this socket, dispatch to STSThread if necessary.
|
||||
void ActivateTLS();
|
||||
// Dispatch an error event if necessary, then dispatch a "close" event.
|
||||
nsresult MaybeReportErrorAndCloseIfOpen(nsresult status);
|
||||
|
Loading…
Reference in New Issue
Block a user