nsLoadGroup::~nsLoadGroup() { DebugOnly<nsresult> rv = Cancel(NS_BINDING_ABORTED); NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed"); mDefaultLoadRequest = 0; if (mRequestContext) { nsID rcid; mRequestContext->GetID(&rcid); if (IsNeckoChild() && gNeckoChild) { char rcid_str[NSID_LENGTH]; rcid.ToProvidedString(rcid_str); nsCString rcid_nscs; rcid_nscs.AssignASCII(rcid_str); gNeckoChild->SendRemoveRequestContext(rcid_nscs); } else { mRequestContextService->RemoveRequestContext(rcid); } } LOG(("LOADGROUP [%x]: Destroyed.\n", this)); }
NS_IMETHODIMP RtspHandler::NewChannel2(nsIURI* aURI, nsILoadInfo* aLoadInfo, nsIChannel** aResult) { bool isRtsp = false; nsRefPtr<nsBaseChannel> rtspChannel; nsresult rv = aURI->SchemeIs("rtsp", &isRtsp); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(isRtsp, NS_ERROR_UNEXPECTED); if (IsNeckoChild()) { rtspChannel = new RtspChannelChild(aURI); } else { rtspChannel = new RtspChannelParent(aURI); } rv = rtspChannel->Init(); NS_ENSURE_SUCCESS(rv, rv); // set the loadInfo on the new channel rv = rtspChannel->SetLoadInfo(aLoadInfo); NS_ENSURE_SUCCESS(rv, rv); rtspChannel.forget(aResult); return NS_OK; }
bool NeckoChild::DeallocPHttpChannelChild(PHttpChannelChild* channel) { NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPHttpChannelChild called by non-child!"); HttpChannelChild* child = static_cast<HttpChannelChild*>(channel); child->ReleaseIPDLReference(); return true; }
bool NeckoChild::DeallocPWyciwygChannelChild(PWyciwygChannelChild* channel) { NS_ABORT_IF_FALSE(IsNeckoChild(), "DeallocPWyciwygChannelChild called by non-child!"); WyciwygChannelChild *p = static_cast<WyciwygChannelChild*>(channel); p->ReleaseIPDLReference(); return true; }
bool NeckoChild::DeallocPCookieServiceChild(PCookieServiceChild* cs) { NS_ASSERTION(IsNeckoChild(), "DeallocPCookieServiceChild called by non-child!"); CookieServiceChild *p = static_cast<CookieServiceChild*>(cs); p->Release(); return true; }
bool NeckoChild::DeallocPFTPChannelChild(PFTPChannelChild* channel) { MOZ_ASSERT(IsNeckoChild(), "DeallocPFTPChannelChild called by non-child!"); FTPChannelChild* child = static_cast<FTPChannelChild*>(channel); child->ReleaseIPDLReference(); return true; }
NS_IMETHODIMP RequestContextService::RemoveRequestContext(const uint64_t rcID) { if (IsNeckoChild() && gNeckoChild) { gNeckoChild->SendRemoveRequestContext(rcID); } MOZ_ASSERT(NS_IsMainThread()); mTable.Remove(rcID); return NS_OK; }
// Note: not actually called; has some lifespan as child process, so // automatically destroyed at exit. void NeckoChild::DestroyNeckoChild() { NS_ABORT_IF_FALSE(IsNeckoChild(), "DestroyNeckoChild called by non-child!"); static bool alreadyDestroyed = false; NS_ABORT_IF_FALSE(!alreadyDestroyed, "DestroyNeckoChild already called!"); if (!alreadyDestroyed) { Send__delete__(gNeckoChild); gNeckoChild = nullptr; alreadyDestroyed = true; } }
void NeckoChild::InitNeckoChild() { NS_ABORT_IF_FALSE(IsNeckoChild(), "InitNeckoChild called by non-child!"); if (!gNeckoChild) { mozilla::dom::ContentChild * cpc = mozilla::dom::ContentChild::GetSingleton(); NS_ASSERTION(cpc, "Content Protocol is NULL!"); gNeckoChild = cpc->SendPNeckoConstructor(); NS_ASSERTION(gNeckoChild, "PNecko Protocol init failed!"); } }
// Note: not actually called; has some lifespan as child process, so // automatically destroyed at exit. void NeckoChild::DestroyNeckoChild() { MOZ_ASSERT(IsNeckoChild(), "DestroyNeckoChild called by non-child!"); static bool alreadyDestroyed = false; MOZ_ASSERT(!alreadyDestroyed, "DestroyNeckoChild already called!"); if (!alreadyDestroyed) { Send__delete__(gNeckoChild); gNeckoChild = nullptr; alreadyDestroyed = true; } }
void RequestContext::ScheduleUnblock() { MOZ_ASSERT(!IsNeckoChild()); MOZ_ASSERT(NS_IsMainThread()); if (!gHttpHandler) { return; } uint32_t quantum = gHttpHandler->TailBlockingDelayQuantum(mAfterDOMContentLoaded); uint32_t delayMax = gHttpHandler->TailBlockingDelayMax(); uint32_t totalMax = gHttpHandler->TailBlockingTotalMax(); if (!mBeginLoadTime.IsNull()) { // We decrease the maximum delay progressively with the time since the page load // begin. This seems like a reasonable and clear heuristic allowing us to start // loading tailed requests in a deterministic time after the load has started. uint32_t sinceBeginLoad = static_cast<uint32_t>( (TimeStamp::NowLoRes() - mBeginLoadTime).ToMilliseconds()); uint32_t tillTotal = totalMax - std::min(sinceBeginLoad, totalMax); uint32_t proportion = totalMax // values clamped between 0 and 60'000 ? (delayMax * tillTotal) / totalMax : 0; delayMax = std::min(delayMax, proportion); } CheckedInt<uint32_t> delay = quantum * mNonTailRequests; if (!mAfterDOMContentLoaded) { // Before DOMContentLoaded notification we want to make sure that tailed // requests don't start when there is a short delay during which we may // not have any active requests on the page happening. delay += quantum; } if (!delay.isValid() || delay.value() > delayMax) { delay = delayMax; } LOG(("RequestContext::ScheduleUnblock this=%p non-tails=%u tail-queue=%zu delay=%u after-DCL=%d", this, mNonTailRequests, mTailQueue.Length(), delay.value(), mAfterDOMContentLoaded)); TimeStamp now = TimeStamp::NowLoRes(); mUntailAt = now + TimeDuration::FromMilliseconds(delay.value()); if (mTimerScheduledAt.IsNull() || mUntailAt < mTimerScheduledAt) { LOG(("RequestContext %p timer would fire too late, rescheduling", this)); RescheduleUntailTimer(now); } }
nsresult nsFtpProtocolHandler::Init() { #ifdef MOZ_IPC if (IsNeckoChild()) NeckoChild::InitNeckoChild(); #endif if (mIdleTimeout == -1) { nsresult rv; nsCOMPtr<nsIPrefBranch> branch = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv; rv = branch->GetIntPref(IDLE_TIMEOUT_PREF, &mIdleTimeout); if (NS_FAILED(rv)) mIdleTimeout = 5*60; // 5 minute default rv = branch->AddObserver(IDLE_TIMEOUT_PREF, this, true); if (NS_FAILED(rv)) return rv; int32_t val; rv = branch->GetIntPref(QOS_DATA_PREF, &val); if (NS_SUCCEEDED(rv)) mDataQoSBits = (uint8_t) clamped(val, 0, 0xff); rv = branch->AddObserver(QOS_DATA_PREF, this, true); if (NS_FAILED(rv)) return rv; rv = branch->GetIntPref(QOS_CONTROL_PREF, &val); if (NS_SUCCEEDED(rv)) mControlQoSBits = (uint8_t) clamped(val, 0, 0xff); rv = branch->AddObserver(QOS_CONTROL_PREF, this, true); if (NS_FAILED(rv)) return rv; } nsCOMPtr<nsIObserverService> observerService = mozilla::services::GetObserverService(); if (observerService) { observerService->AddObserver(this, "network:offline-about-to-go-offline", true); observerService->AddObserver(this, "net:clear-active-logins", true); } return NS_OK; }
NS_IMETHODIMP nsFtpProtocolHandler::NewProxiedChannel(nsIURI* uri, nsIProxyInfo* proxyInfo, nsIChannel* *result) { NS_ENSURE_ARG_POINTER(uri); nsRefPtr<nsBaseChannel> channel; #ifdef MOZ_IPC if (IsNeckoChild()) channel = new FTPChannelChild(uri); else #endif channel = new nsFtpChannel(uri, proxyInfo); nsresult rv = channel->Init(); if (NS_FAILED(rv)) { return rv; } channel.forget(result); return rv; }