if (mDeleteCalled) {  return NS_ERROR_FAILURE;
nsIWindowMediator* service; if (NS_SUCCEEDED(nsServiceManager::GetService(kWindowMediatorCID, kIWindowMediatorIID, (nsISupports**) &service ) ) ) { service->UnregisterWindow( aWindow ); nsServiceManager::ReleaseService(kWindowMediatorCID, service); }  nsresult rv;  nsIWebShellContainer* wsc; rv = aWindow->QueryInterface(kIWebShellContainerIID, (void **) &wsc); if (NS_SUCCEEDED(rv)) { mWindowList->RemoveElement(wsc); NS_RELEASE(wsc);
nsAppShellService::UnregisterTopLevelWindow(nsIXULWindow* aWindow){  if (mDeleteCalled) {    /* return an error code in order to:       - avoid doing anything with other member variables while we are in         the destructor       - notify the caller not to release the AppShellService after         unregistering the window         (we don't want to be deleted twice consecutively to         mHiddenWindow->Close() in our destructor)    */    return NS_ERROR_FAILURE;  }    NS_ENSURE_ARG_POINTER(aWindow);  // tell the window mediator  if (mWindowMediator)    mWindowMediator->UnregisterWindow(aWindow);	  // tell the window watcher  if (mWindowWatcher) {    nsCOMPtr<nsIDocShell> docShell;    aWindow->GetDocShell(getter_AddRefs(docShell));    if (docShell) {      nsCOMPtr<nsIDOMWindow> domWindow(do_GetInterface(docShell));      if (domWindow)        mWindowWatcher->RemoveWindow(domWindow);    }  }  return NS_OK;}