Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nsXMLHttpRequest.cpp File Reference
#include "nsXMLHttpRequest.h"
#include "nsISimpleEnumerator.h"
#include "nsIXPConnect.h"
#include "nsIUnicodeEncoder.h"
#include "nsIServiceManager.h"
#include "nsICharsetConverterManager.h"
#include "nsLayoutCID.h"
#include "nsIDOMDOMImplementation.h"
#include "nsIPrivateDOMImplementation.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsCRT.h"
#include "nsIURI.h"
#include "nsILoadGroup.h"
#include "nsNetUtil.h"
#include "nsIUploadChannel.h"
#include "nsIDOMSerializer.h"
#include "nsXPCOM.h"
#include "nsISupportsPrimitives.h"
#include "nsIDOMEventReceiver.h"
#include "nsIEventListenerManager.h"
#include "nsGUIEvent.h"
#include "nsIPrivateDOMEvent.h"
#include "prprf.h"
#include "nsIDOMEventListener.h"
#include "nsIJSContextStack.h"
#include "nsIScriptSecurityManager.h"
#include "nsWeakPtr.h"
#include "nsICharsetAlias.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDOMClassInfo.h"
#include "nsIDOMElement.h"
#include "nsIDOMWindow.h"
#include "nsIVariant.h"
#include "nsIParser.h"
#include "nsLoadListenerProxy.h"
#include "nsIWindowWatcher.h"
#include "nsIAuthPrompt.h"
#include "nsIStringStream.h"
#include "nsIStreamConverterService.h"
#include "nsICachingChannel.h"
#include "nsContentUtils.h"
#include "nsCOMArray.h"
#include "nsDOMClassInfo.h"
#include "nsIContentPolicy.h"
#include "nsContentPolicyUtils.h"
#include "nsContentErrors.h"
#include "nsLayoutStatics.h"
#include "nsIScriptObjectPrincipal.h"

Go to the source code of this file.

Classes

class  nsMultipartProxyListener

Defines

#define LOADSTR   NS_LITERAL_STRING("load")
#define ERRORSTR   NS_LITERAL_STRING("error")
#define XML_HTTP_REQUEST_UNINITIALIZED   (1 << 0)
#define XML_HTTP_REQUEST_OPENED   (1 << 1)
#define XML_HTTP_REQUEST_LOADED   (1 << 2)
#define XML_HTTP_REQUEST_INTERACTIVE   (1 << 3)
#define XML_HTTP_REQUEST_COMPLETED   (1 << 4)
#define XML_HTTP_REQUEST_SENT   (1 << 5)
#define XML_HTTP_REQUEST_STOPPED   (1 << 6)
#define XML_HTTP_REQUEST_ABORTED   (1 << 7)
#define XML_HTTP_REQUEST_ASYNC   (1 << 8)
#define XML_HTTP_REQUEST_PARSEBODY   (1 << 9)
#define XML_HTTP_REQUEST_XSITEENABLED   (1 << 10)
#define XML_HTTP_REQUEST_SYNCLOOPING   (1 << 11)
#define XML_HTTP_REQUEST_MULTIPART   (1 << 12)
#define XML_HTTP_REQUEST_ROOTED   (1 << 13)
#define XML_HTTP_REQUEST_LOADSTATES

Functions

static NS_DEFINE_CID (kCharsetAliasCID, NS_CHARSETALIAS_CID)
static NS_DEFINE_CID (kIDOMDOMImplementationCID, NS_DOM_IMPLEMENTATION_CID)
static NS_DEFINE_CID (kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID)
static NS_DEFINE_CID (kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID)
static void AddLoadFlags (nsIRequest *request, nsLoadFlags newFlags)
 NS_IMPL_ISUPPORTS2 (nsMultipartProxyListener, nsIStreamListener, nsIRequestObserver) NS_IMETHODIMP nsMultipartProxyListener
 nsIRequestObserver methods
static already_AddRefed
< nsIDocument
GetDocumentFromScriptContext (nsIScriptContext *aScriptContext)
 Gets the nsIDocument given the script context.
PRBool IsSystemPrincipal (nsIPrincipal *aPrincipal)

Variables

static const char * kLoadAsData = "loadAsData"

Define Documentation

Definition at line 90 of file nsXMLHttpRequest.cpp.

Definition at line 89 of file nsXMLHttpRequest.cpp.

Definition at line 108 of file nsXMLHttpRequest.cpp.

Definition at line 109 of file nsXMLHttpRequest.cpp.

Definition at line 103 of file nsXMLHttpRequest.cpp.

Definition at line 102 of file nsXMLHttpRequest.cpp.

Definition at line 101 of file nsXMLHttpRequest.cpp.

Value:
(XML_HTTP_REQUEST_UNINITIALIZED |         \
   XML_HTTP_REQUEST_OPENED |                \
   XML_HTTP_REQUEST_LOADED |                \
   XML_HTTP_REQUEST_INTERACTIVE |           \
   XML_HTTP_REQUEST_COMPLETED |             \
   XML_HTTP_REQUEST_SENT |                  \
   XML_HTTP_REQUEST_STOPPED)

Definition at line 116 of file nsXMLHttpRequest.cpp.

Definition at line 113 of file nsXMLHttpRequest.cpp.

Definition at line 100 of file nsXMLHttpRequest.cpp.

Definition at line 110 of file nsXMLHttpRequest.cpp.

Definition at line 114 of file nsXMLHttpRequest.cpp.

#define XML_HTTP_REQUEST_SENT   (1 << 5)

Definition at line 104 of file nsXMLHttpRequest.cpp.

Definition at line 105 of file nsXMLHttpRequest.cpp.

Definition at line 112 of file nsXMLHttpRequest.cpp.

Definition at line 99 of file nsXMLHttpRequest.cpp.

Definition at line 111 of file nsXMLHttpRequest.cpp.


Function Documentation

static void AddLoadFlags ( nsIRequest request,
nsLoadFlags  newFlags 
) [static]

Definition at line 127 of file nsXMLHttpRequest.cpp.

{
  nsLoadFlags flags;
  request->GetLoadFlags(&flags);
  flags |= newFlags;
  request->SetLoadFlags(flags);
}

Gets the nsIDocument given the script context.

Will return nsnull on failure.

Parameters:
aScriptContextthe script context to get the document for; can be null
Returns:
the document associated with the script context

Definition at line 296 of file nsXMLHttpRequest.cpp.

{
  if (!aScriptContext)
    return nsnull;

  nsCOMPtr<nsIDOMWindow> window =
    do_QueryInterface(aScriptContext->GetGlobalObject());
  nsIDocument *doc = nsnull;
  if (window) {
    nsCOMPtr<nsIDOMDocument> domdoc;
    window->GetDocument(getter_AddRefs(domdoc));
    if (domdoc) {
      CallQueryInterface(domdoc, &doc);
    }
  }
  return doc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PRBool IsSystemPrincipal ( nsIPrincipal aPrincipal) [inline]

Definition at line 934 of file nsXMLHttpRequest.cpp.

{
  nsCOMPtr<nsIPrincipal> systemPrincipal;
  nsresult rv = nsContentUtils::GetSecurityManager()->
                  GetSystemPrincipal(getter_AddRefs(systemPrincipal));
  if (NS_FAILED(rv))
    return PR_FALSE;

  return (aPrincipal == systemPrincipal);
}

Here is the call graph for this function:

static NS_DEFINE_CID ( kCharsetAliasCID  ,
NS_CHARSETALIAS_CID   
) [static]
static NS_DEFINE_CID ( kIDOMDOMImplementationCID  ,
NS_DOM_IMPLEMENTATION_CID   
) [static]
static NS_DEFINE_CID ( kCharsetConverterManagerCID  ,
NS_ICHARSETCONVERTERMANAGER_CID   
) [static]

nsIRequestObserver methods

Definition at line 163 of file nsXMLHttpRequest.cpp.

{
  nsCOMPtr<nsIChannel> channel(do_QueryInterface(aRequest));
  NS_ENSURE_TRUE(channel, NS_ERROR_UNEXPECTED);

  nsCAutoString contentType;
  nsresult rv = channel->GetContentType(contentType);

  if (!contentType.EqualsLiteral("multipart/x-mixed-replace")) {
    return NS_ERROR_INVALID_ARG;
  }

  // If multipart/x-mixed-replace content, we'll insert a MIME
  // decoder in the pipeline to handle the content and pass it along
  // to our original listener.

  nsCOMPtr<nsIStreamConverterService> convServ =
    do_GetService("@mozilla.org/streamConverters;1", &rv);
  if (NS_SUCCEEDED(rv)) {
    nsCOMPtr<nsIStreamListener> toListener(mDestListener);
    nsCOMPtr<nsIStreamListener> fromListener;

    rv = convServ->AsyncConvertData("multipart/x-mixed-replace",
                                    "*/*",
                                    toListener,
                                    nsnull,
                                    getter_AddRefs(fromListener));
    NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && fromListener, NS_ERROR_UNEXPECTED);

    mDestListener = fromListener;
  }

  return mDestListener->OnStartRequest(aRequest, ctxt);
}

Here is the call graph for this function:


Variable Documentation

const char* kLoadAsData = "loadAsData" [static]

Definition at line 88 of file nsXMLHttpRequest.cpp.