mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 11:25:00 +00:00
Bug 1343743 - Part3: Set event target for TCPSocketChild and TCPServerSocketChild, r=jdm
Add an event target parameter in constructor, so we can call gNeckoChild->SetEventTargetForActor before sending constructor message to parent.
This commit is contained in:
parent
e592661572
commit
56e1084587
@ -64,7 +64,12 @@ TCPServerSocket::Init()
|
||||
}
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
mServerBridgeChild = new TCPServerSocketChild(this, mPort, mBacklog, mUseArrayBuffers);
|
||||
nsCOMPtr<nsIEventTarget> target;
|
||||
if (nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal()) {
|
||||
target = global->EventTargetFor(TaskCategory::Other);
|
||||
}
|
||||
mServerBridgeChild =
|
||||
new TCPServerSocketChild(this, mPort, mBacklog, mUseArrayBuffers, target);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -46,9 +46,13 @@ NS_IMETHODIMP_(MozExternalRefCountType) TCPServerSocketChild::Release(void)
|
||||
}
|
||||
|
||||
TCPServerSocketChild::TCPServerSocketChild(TCPServerSocket* aServerSocket, uint16_t aLocalPort,
|
||||
uint16_t aBacklog, bool aUseArrayBuffers)
|
||||
uint16_t aBacklog, bool aUseArrayBuffers,
|
||||
nsIEventTarget* aIPCEventTarget)
|
||||
{
|
||||
mServerSocket = aServerSocket;
|
||||
if (aIPCEventTarget) {
|
||||
gNeckoChild->SetEventTargetForActor(this, aIPCEventTarget);
|
||||
}
|
||||
AddIPDLReference();
|
||||
gNeckoChild->SendPTCPServerSocketConstructor(this, aLocalPort, aBacklog, aUseArrayBuffers);
|
||||
}
|
||||
|
@ -44,7 +44,8 @@ public:
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release() override;
|
||||
|
||||
TCPServerSocketChild(TCPServerSocket* aServerSocket, uint16_t aLocalPort,
|
||||
uint16_t aBacklog, bool aUseArrayBuffers);
|
||||
uint16_t aBacklog, bool aUseArrayBuffers,
|
||||
nsIEventTarget* aIPCEventTarget);
|
||||
~TCPServerSocketChild();
|
||||
|
||||
void Close();
|
||||
|
@ -270,7 +270,12 @@ TCPSocket::Init()
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
mReadyState = TCPReadyState::Connecting;
|
||||
mSocketBridgeChild = new TCPSocketChild(mHost, mPort);
|
||||
|
||||
nsCOMPtr<nsIEventTarget> target;
|
||||
if (nsCOMPtr<nsIGlobalObject> global = GetOwnerGlobal()) {
|
||||
target = global->EventTargetFor(TaskCategory::Other);
|
||||
}
|
||||
mSocketBridgeChild = new TCPSocketChild(mHost, mPort, target);
|
||||
mSocketBridgeChild->SendOpen(this, mSsl, mUseArrayBuffers);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -88,9 +88,12 @@ NS_IMETHODIMP_(MozExternalRefCountType) TCPSocketChild::Release(void)
|
||||
return refcnt;
|
||||
}
|
||||
|
||||
TCPSocketChild::TCPSocketChild(const nsAString& aHost, const uint16_t& aPort)
|
||||
TCPSocketChild::TCPSocketChild(const nsAString& aHost,
|
||||
const uint16_t& aPort,
|
||||
nsIEventTarget* aTarget)
|
||||
: mHost(aHost)
|
||||
, mPort(aPort)
|
||||
, mIPCEventTarget(aTarget)
|
||||
{
|
||||
}
|
||||
|
||||
@ -99,6 +102,10 @@ TCPSocketChild::SendOpen(nsITCPSocketCallback* aSocket, bool aUseSSL, bool aUseA
|
||||
{
|
||||
mSocket = aSocket;
|
||||
|
||||
if (mIPCEventTarget) {
|
||||
gNeckoChild->SetEventTargetForActor(this, mIPCEventTarget);
|
||||
}
|
||||
|
||||
AddIPDLReference();
|
||||
gNeckoChild->SendPTCPSocketConstructor(this, mHost, mPort);
|
||||
MOZ_ASSERT(mFilterName.IsEmpty()); // Currently nobody should use this
|
||||
@ -112,6 +119,11 @@ TCPSocketChild::SendWindowlessOpenBind(nsITCPSocketCallback* aSocket,
|
||||
bool aUseSSL, bool aReuseAddrPort)
|
||||
{
|
||||
mSocket = aSocket;
|
||||
|
||||
if (mIPCEventTarget) {
|
||||
gNeckoChild->SetEventTargetForActor(this, mIPCEventTarget);
|
||||
}
|
||||
|
||||
AddIPDLReference();
|
||||
gNeckoChild->SendPTCPSocketConstructor(this,
|
||||
NS_ConvertUTF8toUTF16(aRemoteHost),
|
||||
|
@ -49,7 +49,9 @@ class TCPSocketChild : public mozilla::net::PTCPSocketChild
|
||||
public:
|
||||
NS_IMETHOD_(MozExternalRefCountType) Release() override;
|
||||
|
||||
TCPSocketChild(const nsAString& aHost, const uint16_t& aPort);
|
||||
TCPSocketChild(const nsAString& aHost,
|
||||
const uint16_t& aPort,
|
||||
nsIEventTarget* aTarget);
|
||||
~TCPSocketChild();
|
||||
|
||||
void SendOpen(nsITCPSocketCallback* aSocket, bool aUseSSL, bool aUseArrayBuffers);
|
||||
@ -82,6 +84,7 @@ private:
|
||||
nsString mHost;
|
||||
uint16_t mPort;
|
||||
nsCString mFilterName;
|
||||
nsCOMPtr<nsIEventTarget> mIPCEventTarget;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -288,7 +288,7 @@ PTCPSocketChild*
|
||||
NeckoChild::AllocPTCPSocketChild(const nsString& host,
|
||||
const uint16_t& port)
|
||||
{
|
||||
TCPSocketChild* p = new TCPSocketChild(host, port);
|
||||
TCPSocketChild* p = new TCPSocketChild(host, port, nullptr);
|
||||
p->AddIPDLReference();
|
||||
return p;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user