DocumentLoaderObserverImpl *observerImpl = new DocumentLoaderObserverImpl(env, initContext, listener);  wsAddDocLoaderObserverEvent *actionEvent = new wsAddDocLoaderObserverEvent(initContext->docShell, observerImpl);  PLEvent			* event       = (PLEvent*) *actionEvent;  ::util_PostEvent(initContext, event);
PR_ASSERT(nsnull != initContext->docShell);     rv = initContext->docShell->GetDocLoaderObserver(getter_AddRefs(curObserver)); if (NS_FAILED(rv) || !curObserver) {     curObserver =  new DocumentLoaderObserverImpl(env, initContext); if (nsnull == curObserver) { return; }  wsAddDocLoaderObserverEvent *actionEvent = new wsAddDocLoaderObserverEvent(initContext->docShell, curObserver);  PLEvent			* event       = (PLEvent*) *actionEvent;  ::util_PostSynchronousEvent(initContext, event); }  if (curObserver) {    rv = curObserver->QueryInterface(kIDocumentLoaderObserverImplIID, getter_AddRefs(myListener)); if (NS_SUCCEEDED(rv) && myListener) { myListener->SetTarget(listener); } }
void addDocumentLoadListener(JNIEnv *env, WebShellInitContext *initContext,                             jobject listener){    if (initContext == nsnull) {        ::util_ThrowExceptionToJava(env, "Exception: null initContext passed toaddDocumentLoadListener");        return;    }    if (initContext->initComplete) {        // Assert (nsnull != initContext->nativeEventThread)                // create the c++ "peer" for the DocumentLoadListener, which is an        // nsIDocumentLoaderObserver.        DocumentLoaderObserverImpl *observerImpl =             new DocumentLoaderObserverImpl(env, initContext, listener);                wsAddDocLoaderObserverEvent *actionEvent =             new wsAddDocLoaderObserverEvent(initContext->docShell,                                            observerImpl);                PLEvent			* event       = (PLEvent*) *actionEvent;                ::util_PostEvent(initContext, event);    }}