nsresult nsPACMan::AsyncGetProxyForURI(nsIURI *uri, nsPACManCallback *callback) { NS_ENSURE_STATE(!mShutdown); MaybeReloadPAC(); PendingPACQuery *query = new PendingPACQuery(this, uri, callback); if (!query) return NS_ERROR_OUT_OF_MEMORY; NS_ADDREF(query); PR_APPEND_LINK(query, &mPendingQ); // If we're waiting for the PAC file to load, then delay starting the query. // See OnStreamComplete. However, if this is the PAC URI then query right // away since we know the result will be DIRECT. We could shortcut some code // in this case by issuing the callback directly from here, but that would // require extra code, so we just go through the usual async code path. int isPACURI = IsPACURI(uri); if (IsLoading() && !isPACURI) return NS_OK; nsresult rv = query->Start(isPACURI ? 0 : nsIDNSService::RESOLVE_SPECULATE); if (rv == NS_ERROR_DNS_LOOKUP_QUEUE_FULL && !isPACURI) { query->OnLookupComplete(NULL, NULL, NS_OK); rv = NS_OK; } else if (NS_FAILED(rv)) { NS_WARNING("failed to start PAC query"); PR_REMOVE_LINK(query); NS_RELEASE(query); } return rv; }
void nsPACMan::ProcessPendingQ(nsresult status) { // Now, start any pending queries PRCList *node = PR_LIST_HEAD(&mPendingQ); while (node != &mPendingQ) { PendingPACQuery *query = static_cast<PendingPACQuery *>(node); node = PR_NEXT_LINK(node); if (NS_SUCCEEDED(status)) { // keep the query in the list (so we can complete it from Shutdown if // necessary). status = query->Start(); } if (NS_FAILED(status)) { // remove the query from the list PR_REMOVE_LINK(query); query->Complete(status, EmptyCString()); NS_RELEASE(query); } } }
void nsPACMan::ProcessPendingQ(nsresult status) { // Now, start any pending queries PRCList *node = PR_LIST_HEAD(&mPendingQ); while (node != &mPendingQ) { PendingPACQuery *query = static_cast<PendingPACQuery *>(node); node = PR_NEXT_LINK(node); if (NS_SUCCEEDED(status)) { // keep the query in the list (so we can complete it from Shutdown if // necessary). status = query->Start(nsIDNSService::RESOLVE_SPECULATE); } if (status == NS_ERROR_DNS_LOOKUP_QUEUE_FULL) { query->OnLookupComplete(NULL, NULL, NS_OK); status = NS_OK; } else if (NS_FAILED(status)) { // remove the query from the list PR_REMOVE_LINK(query); query->Complete(status, EmptyCString()); NS_RELEASE(query); } } }