NS_IMETHODIMP HttpServer::Connection::OnInputStreamReady(nsIAsyncInputStream* aStream) { MOZ_ASSERT(!mInput || aStream == mInput); LOG_I("HttpServer::Connection::OnInputStreamReady(%p)", this); if (!mInput || mState == ePause) { return NS_OK; } uint64_t avail; nsresult rv = mInput->Available(&avail); if (NS_FAILED(rv)) { LOG_I("HttpServer::Connection::OnInputStreamReady(%p) - Connection closed", this); mServer->mConnections.RemoveElement(this); // Connection closed. Handle errors here. return NS_OK; } uint32_t numRead; rv = mInput->ReadSegments(ReadSegmentsFunc, this, UINT32_MAX, &numRead); NS_ENSURE_SUCCESS(rv, rv); rv = mInput->AsyncWait(this, 0, 0, GetCurrentThreadEventTarget()); NS_ENSURE_SUCCESS(rv, rv); return NS_OK; }
// static nsresult IDBFactory::CreateForJSInternal(JSContext* aCx, JS::Handle<JSObject*> aOwningObject, nsAutoPtr<PrincipalInfo>& aPrincipalInfo, uint64_t aInnerWindowID, IDBFactory** aFactory) { MOZ_ASSERT(aCx); MOZ_ASSERT(aOwningObject); MOZ_ASSERT(aPrincipalInfo); MOZ_ASSERT(aPrincipalInfo->type() != PrincipalInfo::T__None); MOZ_ASSERT(aFactory); MOZ_ASSERT(JS_IsGlobalObject(aOwningObject)); if (aPrincipalInfo->type() != PrincipalInfo::TContentPrincipalInfo && aPrincipalInfo->type() != PrincipalInfo::TSystemPrincipalInfo) { NS_WARNING("IndexedDB not allowed for this principal!"); aPrincipalInfo = nullptr; *aFactory = nullptr; return NS_OK; } RefPtr<IDBFactory> factory = new IDBFactory(); factory->mPrincipalInfo = aPrincipalInfo.forget(); factory->mOwningObject = aOwningObject; mozilla::HoldJSObjects(factory.get()); factory->mEventTarget = GetCurrentThreadEventTarget(); factory->mInnerWindowID = aInnerWindowID; factory.forget(aFactory); return NS_OK; }
HttpServer::Connection::Connection(nsISocketTransport* aTransport, HttpServer* aServer, nsresult& rv) : mServer(aServer) , mTransport(aTransport) , mState(eRequestLine) , mPendingReqVersion() , mRemainingBodySize() , mCloseAfterRequest(false) { nsCOMPtr<nsIInputStream> input; rv = mTransport->OpenInputStream(0, 0, 0, getter_AddRefs(input)); NS_ENSURE_SUCCESS_VOID(rv); mInput = do_QueryInterface(input); nsCOMPtr<nsIOutputStream> output; rv = mTransport->OpenOutputStream(0, 0, 0, getter_AddRefs(output)); NS_ENSURE_SUCCESS_VOID(rv); mOutput = do_QueryInterface(output); if (mServer->mHttps) { SetSecurityObserver(true); } else { mInput->AsyncWait(this, 0, 0, GetCurrentThreadEventTarget()); } }
// Proxy the Connect() request to the STS thread, since it may block and // should be done there. mozilla::ipc::IPCResult UDPSocketParent::RecvConnect( const UDPAddressInfo& aAddressInfo) { nsCOMPtr<nsIEventTarget> target = GetCurrentThreadEventTarget(); Unused << NS_WARN_IF(NS_FAILED(GetSTSThread()->Dispatch( WrapRunnable(RefPtr<UDPSocketParent>(this), &UDPSocketParent::DoConnect, mSocket, target, aAddressInfo), NS_DISPATCH_NORMAL))); return IPC_OK(); }
void HttpServer::Connection::HandleWebSocketResponse(InternalResponse* aResponse) { MOZ_ASSERT(mPendingWebSocketRequest); mState = eRequestLine; mPendingWebSocketRequest = nullptr; mInput->AsyncWait(this, 0, 0, GetCurrentThreadEventTarget()); QueueResponse(aResponse); }
NS_IMETHODIMP HttpServer::Connection::OnHandshakeDone(nsITLSServerSocket* aServer, nsITLSClientStatus* aStatus) { LOG_I("HttpServer::Connection::OnHandshakeDone(%p)", this); // XXX Verify connection security SetSecurityObserver(false); mInput->AsyncWait(this, 0, 0, GetCurrentThreadEventTarget()); return NS_OK; }
FileSystemTaskParentBase::FileSystemTaskParentBase( FileSystemBase* aFileSystem, const FileSystemParams& aParam, FileSystemRequestParent* aParent) : Runnable("dom::FileSystemTaskParentBase") , mErrorValue(NS_OK) , mFileSystem(aFileSystem) , mRequestParent(aParent) , mBackgroundEventTarget(GetCurrentThreadEventTarget()) { MOZ_ASSERT(XRE_IsParentProcess(), "Only call from parent process!"); MOZ_ASSERT(aFileSystem, "aFileSystem should not be null."); MOZ_ASSERT(aParent); MOZ_ASSERT(mBackgroundEventTarget); AssertIsOnBackgroundThread(); }