Back to index

lightning-sunbird  0.9+nobinonly
Classes | Functions
nsPACMan.cpp File Reference
#include "nsPACMan.h"
#include "nsIDNSService.h"
#include "nsIDNSListener.h"
#include "nsICancelable.h"
#include "nsIAuthPrompt.h"
#include "nsIHttpChannel.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#include "nsEventQueueUtils.h"
#include "nsNetUtil.h"
#include "nsAutoLock.h"
#include "nsAutoPtr.h"
#include "nsCRT.h"
#include "prmon.h"

Go to the source code of this file.


class  PendingPACQuery


static PRBool HttpRequestSucceeded (nsIStreamLoader *loader)
 NS_IMPL_ISUPPORTS3 (nsPACMan, nsIStreamLoaderObserver, nsIInterfaceRequestor, nsIChannelEventSink) NS_IMETHODIMP nsPACMan

Function Documentation

static PRBool HttpRequestSucceeded ( nsIStreamLoader loader) [static]

Definition at line 59 of file nsPACMan.cpp.

  nsCOMPtr<nsIRequest> request;

  PRBool result = PR_TRUE;  // default to assuming success

  nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(request);
  if (httpChannel)

  return result;

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 413 of file nsPACMan.cpp.

  if (mLoader != loader) {
    // If this happens, then it means that LoadPACFromURI was called more
    // than once before the initial call completed.  In this case, status
    // should be NS_ERROR_ABORT, and if so, then we know that we can and
    // should delay any processing.
    if (status == NS_ERROR_ABORT)
      return NS_OK;

  mLoader = nsnull;

  if (NS_SUCCEEDED(status) && HttpRequestSucceeded(loader)) {
    // Get the URI spec used to load this PAC script.
    nsCAutoString pacURI;
      nsCOMPtr<nsIRequest> request;
      nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
      if (channel) {
        nsCOMPtr<nsIURI> uri;
        if (uri)

    if (!mPAC) {
      mPAC = do_CreateInstance(NS_PROXYAUTOCONFIG_CONTRACTID, &status);
      if (!mPAC)
        NS_WARNING("failed to instantiate PAC component");
    if (NS_SUCCEEDED(status)) {
      // We assume that the PAC text is ASCII (or ISO-Latin-1).  We've had this
      // assumption forever, and some real-world PAC scripts actually have some
      // non-ASCII text in comment blocks (see bug 296163).
      const char *text = (const char *) data;
      status = mPAC->Init(pacURI, NS_ConvertASCIItoUTF16(text, dataLen));

    // Even if the PAC file could not be parsed, we did succeed in loading the
    // data for it.
    mLoadFailureCount = 0;
  } else {
    // We were unable to load the PAC file (presumably because of a network
    // failure).  Try again a little later.

  // Reset mPAC if necessary
  if (mPAC && NS_FAILED(status))
    mPAC = nsnull;

  return NS_OK;

Here is the call graph for this function: