/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set sw=2 ts=8 et tw=80 : */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
if (aSecure) {
mChannel =
do_CreateInstance("@mozilla.org/network/protocol;1?name=wss", &rv);
} else {
mChannel =
do_CreateInstance("@mozilla.org/network/protocol;1?name=ws", &rv);
} if (NS_FAILED(rv)) goto fail;
rv = mChannel->SetSerial(mSerial); if (NS_WARN_IF(NS_FAILED(rv))) { goto fail;
}
rv = mChannel->SetLoadInfo(loadInfo); if (NS_FAILED(rv)) { goto fail;
}
rv = mChannel->SetNotificationCallbacks(this); if (NS_FAILED(rv)) goto fail;
rv = mChannel->SetProtocol(aProtocol); if (NS_FAILED(rv)) goto fail;
if (aTransportProvider.isSome()) {
RefPtr<TransportProviderParent> provider = static_cast<TransportProviderParent*>(aTransportProvider.value());
rv = mChannel->SetServerParameters(provider, aNegotiatedExtensions); if (NS_FAILED(rv)) { goto fail;
}
} else {
uri = aURI; if (!uri) {
rv = NS_ERROR_FAILURE; goto fail;
}
}
// only use ping values from child if they were overridden by client code. if (aClientSetPingInterval) { // IDL allows setting in seconds, so must be multiple of 1000 ms
MOZ_ASSERT(aPingInterval >= 1000 && !(aPingInterval % 1000));
DebugOnly<nsresult> rv = mChannel->SetPingInterval(aPingInterval / 1000);
MOZ_ASSERT(NS_SUCCEEDED(rv));
} if (aClientSetPingTimeout) {
MOZ_ASSERT(aPingTimeout >= 1000 && !(aPingTimeout % 1000));
DebugOnly<nsresult> rv = mChannel->SetPingTimeout(aPingTimeout / 1000);
MOZ_ASSERT(NS_SUCCEEDED(rv));
}
staticbool SendOnMessageAvailableHelper( const nsACString& aMsg, const std::function<bool(const nsDependentCSubstring&, bool)>& aSendFunc) { // To avoid the crash caused by too large IPC message, we have to split the // data in small chunks and send them to child process. Note that the chunk // size used here is the same as what we used for PHttpChannel. static uint32_t const kCopyChunkSize = 128 * 1024;
uint32_t count = aMsg.Length(); if (count <= kCopyChunkSize) { return aSendFunc(nsDependentCSubstring(aMsg), false);
}
// Make sure we close the channel if the content process dies without going // through a clean shutdown. if (mChannel) {
Unused << mChannel->Close(nsIWebSocketChannel::CLOSE_GOING_AWAY, "Child was killed"_ns);
}
}
// Only support nsILoadContext if child channel's callbacks did too if (iid.Equals(NS_GET_IID(nsILoadContext)) && mLoadContext) {
nsCOMPtr<nsILoadContext> copy = mLoadContext;
copy.forget(result); return NS_OK;
}
return QueryInterface(iid, result);
}
} // namespace net
} // namespace mozilla
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.