NS_IMETHOD Run() { NS_ASSERTION(NS_IsMainThread(), "Must be on main thread."); // Explicitly release the MediaResource reference. We *must* do this on // the main thread, so we must explicitly release it here, we can't rely // on the destructor to release it, since if this event runs before its // dispatch call returns the destructor may run on the non-main thread. mResource = nullptr; NS_ASSERTION(sThreadPoolRefCnt > 0, "sThreadPoolRefCnt Should be non-negative"); sThreadPoolRefCnt--; if (sThreadPoolRefCnt == 0) { NS_ASSERTION(sThreadPool != nullptr, "Should have thread pool ref if sThreadPoolRefCnt==0."); // Note: store ref to thread pool, then clear global ref, then // Shutdown() using the stored ref. Events can run during the Shutdown() // call, so if we release after calling Shutdown(), another event may // have incremented the refcnt in the meantime, and have a dangling // pointer to the now destroyed threadpool! nsCOMPtr<nsIThreadPool> pool = sThreadPool; NS_IF_RELEASE(sThreadPool); pool->Shutdown(); } return NS_OK; }
NS_IMETHODIMP nsRenderingContextPh :: Init( nsIDeviceContext* aContext, nsIWidget *aWindow ) { nsresult res; mContext = aContext; NS_IF_ADDREF(mContext); PtWidget_t *widget = (PtWidget_t*) aWindow->GetNativeData( NS_NATIVE_WIDGET ); if( !widget ) { NS_IF_RELEASE( mContext ); // new NS_ASSERTION(widget,"nsRenderingContext::Init (with a widget) widget is NULL!"); return NS_ERROR_FAILURE; } mRegionID = PtWidgetRid( widget ); if( mRegionID ) { mSurface = new nsDrawingSurfacePh(); if( mSurface ) { mGC = PgCreateGC( 0 ); mOwner = PR_TRUE; /* use the dc you get by doing a PhDCSetCurrent( NULL ) */ res = mSurface->Init( _Ph_->dflt_draw_context, mGC ); if( res != NS_OK ) return NS_ERROR_FAILURE; mOffscreenSurface = mSurface; NS_ADDREF( mSurface ); mSurfaceDC = ((nsDrawingSurfacePh*)mSurface)->GetDC(); } else return NS_ERROR_FAILURE; } return CommonInit(); }
static void SupportedSocketTypesResponse(TpProxy *proxy, const GValue *out, const GError *error, gpointer user_data, GObject *weak_object) { csITpChannelTypeStreamTubeSupportedSocketTypesCB *callback = (csITpChannelTypeStreamTubeSupportedSocketTypesCB *)user_data; if (!callback) return; if (error != NULL) { callback->GetPropertySupportedSocketTypesError(nsDependentCString(g_quark_to_string(error->domain)), error->code, nsDependentCString(error->message)); return; } GHashTable * supportedsockettypes; supportedsockettypes = (GHashTable *)g_value_get_boxed(out); nsCOMPtr<nsIArray> cSupportedSocketTypes; csTpSupportedSocketMap::Create((gpointer)supportedsockettypes, getter_AddRefs(cSupportedSocketTypes)); callback->GetPropertySupportedSocketTypesDone(cSupportedSocketTypes); NS_IF_RELEASE(callback); }
static void HandleOwnersResponse(TpProxy *proxy, const GValue *out, const GError *error, gpointer user_data, GObject *weak_object) { csITpChannelInterfaceGroupHandleOwnersCB *callback = (csITpChannelInterfaceGroupHandleOwnersCB *)user_data; if (!callback) return; if (error != NULL) { callback->GetPropertyHandleOwnersError(nsDependentCString(g_quark_to_string(error->domain)), error->code, nsDependentCString(error->message)); return; } GHashTable * handleowners; handleowners = (GHashTable *)g_value_get_boxed(out); nsCOMPtr<nsIArray> cHandleOwners; csTpHandleOwnerMap::Create((gpointer)handleowners, getter_AddRefs(cHandleOwners)); callback->GetPropertyHandleOwnersDone(cHandleOwners); NS_IF_RELEASE(callback); }
static void LocationAccessControlResponse(TpProxy *proxy, const GValue *out, const GError *error, gpointer user_data, GObject *weak_object) { csITpConnectionInterfaceLocationLocationAccessControlCB *callback = (csITpConnectionInterfaceLocationLocationAccessControlCB *)user_data; if (!callback) return; if (error != NULL) { callback->GetPropertyLocationAccessControlError(nsDependentCString(g_quark_to_string(error->domain)), error->code, nsDependentCString(error->message)); return; } GValueArray * locationaccesscontrol; locationaccesscontrol = (GValueArray *)g_value_get_boxed(out); nsCOMPtr<csITpRichPresenceAccessControl> cLocationAccessControl; csTpRichPresenceAccessControl::Create((gpointer)locationaccesscontrol, getter_AddRefs(cLocationAccessControl)); callback->GetPropertyLocationAccessControlDone(cLocationAccessControl); NS_IF_RELEASE(callback); }
static void GetAvailableTubeTypesResponse(TpChannel *proxy, const GArray *available_tube_types, const GError *error, gpointer user_data, GObject *weak_object) { csITpChannelTypeTubesGetAvailableTubeTypesCB *callback = (csITpChannelTypeTubesGetAvailableTubeTypesCB *)user_data; if (!callback) return; if (error != NULL) { callback->OnGetAvailableTubeTypesError(nsDependentCString(g_quark_to_string(error->domain)), error->code, nsDependentCString(error->message)); return; } PRUint32 cAvailableTubeTypesCount = available_tube_types->len; PRUint32 *cAvailableTubeTypes = (PRUint32 *)nsMemory::Alloc(sizeof(PRUint32)*cAvailableTubeTypesCount); for (unsigned int i=0; i<cAvailableTubeTypesCount; i++) cAvailableTubeTypes[i] = g_array_index(available_tube_types, guint, i); callback->OnGetAvailableTubeTypesDone(cAvailableTubeTypesCount, cAvailableTubeTypes); NS_IF_RELEASE(callback); }
NS_IMETHODIMP nsRenderingContextPh :: SetFont( nsIFontMetrics *aFontMetrics ) { if( mFontMetrics == aFontMetrics ) return NS_OK; nsFontHandle fontHandle; /* really a nsString */ char *pFontHandle; NS_IF_RELEASE(mFontMetrics); mFontMetrics = aFontMetrics; NS_IF_ADDREF(mFontMetrics); if( mFontMetrics == nsnull ) return NS_OK; mFontMetrics->GetFontHandle( fontHandle ); pFontHandle = (char *) fontHandle; if( pFontHandle ) { if( mPhotonFontName ) free( mPhotonFontName ); mPhotonFontName = strdup( pFontHandle ); } return NS_OK; }
void nsTreeSanitizer::ReleaseStatics() { delete sElementsHTML; sElementsHTML = nsnull; delete sAttributesHTML; sAttributesHTML = nsnull; delete sElementsSVG; sElementsSVG = nsnull; delete sAttributesSVG; sAttributesSVG = nsnull; delete sElementsMathML; sElementsMathML = nsnull; delete sAttributesMathML; sAttributesMathML = nsnull; NS_IF_RELEASE(sNullPrincipal); }
static void GetRemotePendingMembersResponse(TpChannel *proxy, const GArray *handles, const GError *error, gpointer user_data, GObject *weak_object) { csITpChannelInterfaceGroupGetRemotePendingMembersCB *callback = (csITpChannelInterfaceGroupGetRemotePendingMembersCB *)user_data; if (!callback) return; if (error != NULL) { callback->OnGetRemotePendingMembersError(nsDependentCString(g_quark_to_string(error->domain)), error->code, nsDependentCString(error->message)); return; } PRUint32 cHandlesCount = handles->len; PRUint32 *cHandles = (PRUint32 *)nsMemory::Alloc(sizeof(PRUint32)*cHandlesCount); for (unsigned int i=0; i<cHandlesCount; i++) cHandles[i] = g_array_index(handles, guint, i); callback->OnGetRemotePendingMembersDone(cHandlesCount, cHandles); NS_IF_RELEASE(callback); }
NS_IMETHODIMP nsWidget::DispatchEvent( nsGUIEvent *aEvent, nsEventStatus &aStatus ) { NS_ADDREF(aEvent->widget); if( nsnull != mMenuListener ) { if( NS_MENU_EVENT == aEvent->eventStructType ) aStatus = mMenuListener->MenuSelected(NS_STATIC_CAST(nsMenuEvent&, *aEvent)); } aStatus = nsEventStatus_eIgnore; ///* ATENTIE */ printf( "mEventCallback call (%d %d) this=%p\n", aEvent->point.x, aEvent->point.y, this ); if( nsnull != mEventCallback ) aStatus = (*mEventCallback)(aEvent); // Dispatch to event listener if event was not consumed if( (aStatus != nsEventStatus_eIgnore) && (nsnull != mEventListener) ) aStatus = mEventListener->ProcessEvent(*aEvent); NS_IF_RELEASE(aEvent->widget); return NS_OK; }
NS_IMETHODIMP nsSmtpService::SendMailMessage(nsIFile * aFilePath, const char * aRecipients, nsIMsgIdentity * aSenderIdentity, const char * aPassword, nsIUrlListener * aUrlListener, nsIMsgStatusFeedback *aStatusFeedback, nsIInterfaceRequestor* aNotificationCallbacks, bool aRequestDSN, nsIURI ** aURL, nsIRequest ** aRequest) { nsIURI * urlToRun = nullptr; nsresult rv = NS_OK; nsCOMPtr<nsISmtpServer> smtpServer; rv = GetServerByIdentity(aSenderIdentity, getter_AddRefs(smtpServer)); if (NS_SUCCEEDED(rv) && smtpServer) { if (aPassword && *aPassword) smtpServer->SetPassword(nsDependentCString(aPassword)); // this ref counts urlToRun rv = NS_MsgBuildSmtpUrl(aFilePath, smtpServer, aRecipients, aSenderIdentity, aUrlListener, aStatusFeedback, aNotificationCallbacks, &urlToRun, aRequestDSN); if (NS_SUCCEEDED(rv) && urlToRun) rv = NS_MsgLoadSmtpUrl(urlToRun, nullptr, aRequest); if (aURL) // does the caller want a handle on the url? *aURL = urlToRun; // transfer our ref count to the caller.... else NS_IF_RELEASE(urlToRun); } return rv; }
txExecutionState::~txExecutionState() { MOZ_COUNT_DTOR(txExecutionState); delete mResultHandler; delete mLocalVariables; delete mEvalContext; PRInt32 i; for (i = 0; i < mTemplateRuleCount; ++i) { NS_IF_RELEASE(mTemplateRules[i].mModeLocalName); } delete [] mTemplateRules; txStackIterator varsIter(&mLocalVarsStack); while (varsIter.hasNext()) { delete (txVariableMap*)varsIter.next(); } txStackIterator contextIter(&mEvalContextStack); while (contextIter.hasNext()) { txIEvalContext* context = (txIEvalContext*)contextIter.next(); if (context != mInitialEvalContext) { delete context; } } txStackIterator handlerIter(&mResultHandlerStack); while (handlerIter.hasNext()) { delete (txAXMLEventHandler*)handlerIter.next(); } txStackIterator paramIter(&mParamStack); while (paramIter.hasNext()) { delete (txVariableMap*)paramIter.next(); } }
nsresult nsAbView::RemoveCardAt(PRInt32 row) { nsresult rv; AbCard *abcard = (AbCard*) (mCards.ElementAt(row)); NS_IF_RELEASE(abcard->card); mCards.RemoveElementAt(row); PR_FREEIF(abcard->primaryCollationKey); PR_FREEIF(abcard->secondaryCollationKey); PR_FREEIF(abcard); // This needs to happen after we remove the card, as RowCountChanged() will call GetRowCount() if (mTree) { rv = mTree->RowCountChanged(row, -1); NS_ENSURE_SUCCESS(rv,rv); } if (mAbViewListener && !mSuppressCountChange) { rv = mAbViewListener->OnCountChanged(mCards.Count()); NS_ENSURE_SUCCESS(rv,rv); } return NS_OK; }
static void RemotePendingMembersResponse(TpProxy *proxy, const GValue *out, const GError *error, gpointer user_data, GObject *weak_object) { csITpChannelInterfaceGroupRemotePendingMembersCB *callback = (csITpChannelInterfaceGroupRemotePendingMembersCB *)user_data; if (!callback) return; if (error != NULL) { callback->GetPropertyRemotePendingMembersError(nsDependentCString(g_quark_to_string(error->domain)), error->code, nsDependentCString(error->message)); return; } GArray * remotependingmembers; remotependingmembers = (GArray *)g_value_get_boxed(out); PRUint32 cRemotePendingMembersCount = remotependingmembers->len; PRUint32 *cRemotePendingMembers = (PRUint32 *)nsMemory::Alloc(sizeof(PRUint32)*cRemotePendingMembersCount); for (unsigned int i=0; i<cRemotePendingMembersCount; i++) cRemotePendingMembers[i] = g_array_index(remotependingmembers, guint, i); callback->GetPropertyRemotePendingMembersDone(cRemotePendingMembersCount, cRemotePendingMembers); NS_IF_RELEASE(callback); }
nsresult MailEwsMsgCompose::CreateComponents(void) { nsresult rv = NS_OK; if (!m_pIOService) { IMPORT_LOG0("Creating nsIOService\n"); m_pIOService = do_GetService(NS_IOSERVICE_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); } NS_IF_RELEASE(m_pMsgFields); if (NS_SUCCEEDED(rv)) { rv = CallCreateInstance(kMsgCompFieldsCID, &m_pMsgFields); if (NS_SUCCEEDED(rv) && m_pMsgFields) { IMPORT_LOG0("nsOutlookCompose - CreateComponents succeeded\n"); m_pMsgFields->SetForcePlainText(false); return NS_OK; } } return NS_ERROR_FAILURE; }
static void LocationAccessControlTypesResponse(TpProxy *proxy, const GValue *out, const GError *error, gpointer user_data, GObject *weak_object) { csITpConnectionInterfaceLocationLocationAccessControlTypesCB *callback = (csITpConnectionInterfaceLocationLocationAccessControlTypesCB *)user_data; if (!callback) return; if (error != NULL) { callback->GetPropertyLocationAccessControlTypesError(nsDependentCString(g_quark_to_string(error->domain)), error->code, nsDependentCString(error->message)); return; } GArray * locationaccesscontroltypes; locationaccesscontroltypes = (GArray *)g_value_get_boxed(out); PRUint32 cLocationAccessControlTypesCount = locationaccesscontroltypes->len; PRUint32 *cLocationAccessControlTypes = (PRUint32 *)nsMemory::Alloc(sizeof(PRUint32)*cLocationAccessControlTypesCount); for (unsigned int i=0; i<cLocationAccessControlTypesCount; i++) cLocationAccessControlTypes[i] = g_array_index(locationaccesscontroltypes, guint, i); callback->GetPropertyLocationAccessControlTypesDone(cLocationAccessControlTypesCount, cLocationAccessControlTypes); NS_IF_RELEASE(callback); }
nsresult ShutdownXPCOM(nsIServiceManager* servMgr) { // Make sure the hang monitor is enabled for shutdown. HangMonitor::NotifyActivity(); NS_ENSURE_STATE(NS_IsMainThread()); nsresult rv; nsCOMPtr<nsISimpleEnumerator> moduleLoaders; // Notify observers of xpcom shutting down { // Block it so that the COMPtr will get deleted before we hit // servicemanager shutdown nsCOMPtr<nsIThread> thread = do_GetCurrentThread(); NS_ENSURE_STATE(thread); nsRefPtr<nsObserverService> observerService; CallGetService("@mozilla.org/observer-service;1", (nsObserverService**) getter_AddRefs(observerService)); if (observerService) { (void) observerService-> NotifyObservers(nullptr, NS_XPCOM_WILL_SHUTDOWN_OBSERVER_ID, nullptr); nsCOMPtr<nsIServiceManager> mgr; rv = NS_GetServiceManager(getter_AddRefs(mgr)); if (NS_SUCCEEDED(rv)) { (void) observerService-> NotifyObservers(mgr, NS_XPCOM_SHUTDOWN_OBSERVER_ID, nullptr); } } NS_ProcessPendingEvents(thread); mozilla::scache::StartupCache::DeleteSingleton(); if (observerService) (void) observerService-> NotifyObservers(nullptr, NS_XPCOM_SHUTDOWN_THREADS_OBSERVER_ID, nullptr); nsCycleCollector_shutdownThreads(); NS_ProcessPendingEvents(thread); // Shutdown the timer thread and all timers that might still be alive before // shutting down the component manager nsTimerImpl::Shutdown(); NS_ProcessPendingEvents(thread); // Shutdown all remaining threads. This method does not return until // all threads created using the thread manager (with the exception of // the main thread) have exited. nsThreadManager::get()->Shutdown(); NS_ProcessPendingEvents(thread); HangMonitor::NotifyActivity(); // We save the "xpcom-shutdown-loaders" observers to notify after // the observerservice is gone. if (observerService) { observerService-> EnumerateObservers(NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID, getter_AddRefs(moduleLoaders)); observerService->Shutdown(); } } // Free ClearOnShutdown()'ed smart pointers. This needs to happen *after* // we've finished notifying observers of XPCOM shutdown, because shutdown // observers themselves might call ClearOnShutdown(). mozilla::KillClearOnShutdown(); // XPCOM is officially in shutdown mode NOW // Set this only after the observers have been notified as this // will cause servicemanager to become inaccessible. mozilla::services::Shutdown(); #ifdef DEBUG_dougt fprintf(stderr, "* * * * XPCOM shutdown. Access will be denied * * * * \n"); #endif // We may have AddRef'd for the caller of NS_InitXPCOM, so release it // here again: NS_IF_RELEASE(servMgr); // Shutdown global servicemanager if (nsComponentManagerImpl::gComponentManager) { nsComponentManagerImpl::gComponentManager->FreeServices(); } // Release the directory service NS_IF_RELEASE(nsDirectoryService::gService); SAMPLE_MARKER("Shutdown xpcom"); mozilla::PoisonWrite(); nsCycleCollector_shutdown(); if (moduleLoaders) { bool more; nsCOMPtr<nsISupports> el; while (NS_SUCCEEDED(moduleLoaders->HasMoreElements(&more)) && more) { moduleLoaders->GetNext(getter_AddRefs(el)); // Don't worry about weak-reference observers here: there is // no reason for weak-ref observers to register for // xpcom-shutdown-loaders nsCOMPtr<nsIObserver> obs(do_QueryInterface(el)); if (obs) (void) obs->Observe(nullptr, NS_XPCOM_SHUTDOWN_LOADERS_OBSERVER_ID, nullptr); } moduleLoaders = nullptr; } // Shutdown nsLocalFile string conversion NS_ShutdownLocalFile(); #ifdef XP_UNIX NS_ShutdownNativeCharsetUtils(); #endif // Shutdown xpcom. This will release all loaders and cause others holding // a refcount to the component manager to release it. if (nsComponentManagerImpl::gComponentManager) { rv = (nsComponentManagerImpl::gComponentManager)->Shutdown(); NS_ASSERTION(NS_SUCCEEDED(rv), "Component Manager shutdown failed."); } else NS_WARNING("Component Manager was never created ..."); // Release our own singletons // Do this _after_ shutting down the component manager, because the // JS component loader will use XPConnect to call nsIModule::canUnload, // and that will spin up the InterfaceInfoManager again -- bad mojo xptiInterfaceInfoManager::FreeInterfaceInfoManager(); // Finally, release the component manager last because it unloads the // libraries: if (nsComponentManagerImpl::gComponentManager) { nsrefcnt cnt; NS_RELEASE2(nsComponentManagerImpl::gComponentManager, cnt); NS_ASSERTION(cnt == 0, "Component Manager being held past XPCOM shutdown."); } nsComponentManagerImpl::gComponentManager = nullptr; nsCategoryManager::Destroy(); NS_PurgeAtomTable(); NS_IF_RELEASE(gDebug); if (sIOThread) { delete sIOThread; sIOThread = nullptr; } if (sMessageLoop) { delete sMessageLoop; sMessageLoop = nullptr; } if (sCommandLineWasInitialized) { CommandLine::Terminate(); sCommandLineWasInitialized = false; } if (sExitManager) { delete sExitManager; sExitManager = nullptr; } Omnijar::CleanUp(); HangMonitor::Shutdown(); eventtracer::Shutdown(); NS_LogTerm(); return NS_OK; }
/*static*/ void nsStackLayout::Shutdown() { NS_IF_RELEASE(gInstance); }
XPCJSRuntime::~XPCJSRuntime() { #ifdef XPC_DUMP_AT_SHUTDOWN { // count the total JSContexts in use JSContext* iter = nsnull; int count = 0; while(JS_ContextIterator(mJSRuntime, &iter)) count ++; if(count) printf("deleting XPCJSRuntime with %d live JSContexts\n", count); } #endif // clean up and destroy maps... if(mContextMap) { PurgeXPCContextList(); delete mContextMap; } if(mWrappedJSMap) { #ifdef XPC_DUMP_AT_SHUTDOWN uint32 count = mWrappedJSMap->Count(); if(count) printf("deleting XPCJSRuntime with %d live wrapped JSObject\n", (int)count); #endif mWrappedJSMap->Enumerate(WrappedJSShutdownMarker, mJSRuntime); delete mWrappedJSMap; } if(mWrappedJSClassMap) { #ifdef XPC_DUMP_AT_SHUTDOWN uint32 count = mWrappedJSClassMap->Count(); if(count) printf("deleting XPCJSRuntime with %d live nsXPCWrappedJSClass\n", (int)count); #endif delete mWrappedJSClassMap; } if(mIID2NativeInterfaceMap) { #ifdef XPC_DUMP_AT_SHUTDOWN uint32 count = mIID2NativeInterfaceMap->Count(); if(count) printf("deleting XPCJSRuntime with %d live XPCNativeInterfaces\n", (int)count); #endif delete mIID2NativeInterfaceMap; } if(mClassInfo2NativeSetMap) { #ifdef XPC_DUMP_AT_SHUTDOWN uint32 count = mClassInfo2NativeSetMap->Count(); if(count) printf("deleting XPCJSRuntime with %d live XPCNativeSets\n", (int)count); #endif delete mClassInfo2NativeSetMap; } if(mNativeSetMap) { #ifdef XPC_DUMP_AT_SHUTDOWN uint32 count = mNativeSetMap->Count(); if(count) printf("deleting XPCJSRuntime with %d live XPCNativeSets\n", (int)count); #endif delete mNativeSetMap; } if(mMapLock) XPCAutoLock::DestroyLock(mMapLock); NS_IF_RELEASE(mJSRuntimeService); if(mThisTranslatorMap) { #ifdef XPC_DUMP_AT_SHUTDOWN uint32 count = mThisTranslatorMap->Count(); if(count) printf("deleting XPCJSRuntime with %d live ThisTranslator\n", (int)count); #endif delete mThisTranslatorMap; } #ifdef XPC_CHECK_WRAPPERS_AT_SHUTDOWN if(DEBUG_WrappedNativeHashtable) { int LiveWrapperCount = 0; JS_DHashTableEnumerate(DEBUG_WrappedNativeHashtable, DEBUG_WrapperChecker, &LiveWrapperCount); if(LiveWrapperCount) printf("deleting XPCJSRuntime with %d live XPCWrappedNative (found in wrapper check)\n", (int)LiveWrapperCount); JS_DHashTableDestroy(DEBUG_WrappedNativeHashtable); } #endif if(mNativeScriptableSharedMap) { #ifdef XPC_DUMP_AT_SHUTDOWN uint32 count = mNativeScriptableSharedMap->Count(); if(count) printf("deleting XPCJSRuntime with %d live XPCNativeScriptableShared\n", (int)count); #endif delete mNativeScriptableSharedMap; } if(mDyingWrappedNativeProtoMap) { #ifdef XPC_DUMP_AT_SHUTDOWN uint32 count = mDyingWrappedNativeProtoMap->Count(); if(count) printf("deleting XPCJSRuntime with %d live but dying XPCWrappedNativeProto\n", (int)count); #endif delete mDyingWrappedNativeProtoMap; } if(mDetachedWrappedNativeProtoMap) { #ifdef XPC_DUMP_AT_SHUTDOWN uint32 count = mDetachedWrappedNativeProtoMap->Count(); if(count) printf("deleting XPCJSRuntime with %d live detached XPCWrappedNativeProto\n", (int)count); #endif delete mDetachedWrappedNativeProtoMap; } if(mExplicitNativeWrapperMap) { #ifdef XPC_DUMP_AT_SHUTDOWN uint32 count = mExplicitNativeWrapperMap->Count(); if(count) printf("deleting XPCJSRuntime with %d live explicit XPCNativeWrapper\n", (int)count); #endif delete mExplicitNativeWrapperMap; } // unwire the readable/JSString sharing magic XPCStringConvert::ShutdownDOMStringFinalizer(); XPCConvert::RemoveXPCOMUCStringFinalizer(); gOldJSGCCallback = NULL; gOldJSContextCallback = NULL; if(mJSHolders.ops) { JS_DHashTableFinish(&mJSHolders); mJSHolders.ops = nsnull; } if(mClearedGlobalObjects.ops) { JS_DHashTableFinish(&mClearedGlobalObjects); mClearedGlobalObjects.ops = nsnull; } }
void nsHttpTransaction::SetConnection(nsAHttpConnection *conn) { NS_IF_RELEASE(mConnection); NS_IF_ADDREF(mConnection = conn); }
/* static */ void nsBox::Shutdown() { gGotTheme = PR_FALSE; NS_IF_RELEASE(gTheme); }
void nsHttpChannelAuthProvider::SetAuthorizationHeader(nsHttpAuthCache *authCache, nsHttpAtom header, const char *scheme, const char *host, int32_t port, const char *path, nsHttpAuthIdentity &ident) { nsHttpAuthEntry *entry = nullptr; nsresult rv; // set informations that depend on whether // we're authenticating against a proxy // or a webserver nsISupports **continuationState; if (header == nsHttp::Proxy_Authorization) { continuationState = &mProxyAuthContinuationState; } else { continuationState = &mAuthContinuationState; } rv = authCache->GetAuthEntryForPath(scheme, host, port, path, &entry); if (NS_SUCCEEDED(rv)) { // if we are trying to add a header for origin server auth and if the // URL contains an explicit username, then try the given username first. // we only want to do this, however, if we know the URL requires auth // based on the presence of an auth cache entry for this URL (which is // true since we are here). but, if the username from the URL matches // the username from the cache, then we should prefer the password // stored in the cache since that is most likely to be valid. if (header == nsHttp::Authorization && entry->Domain()[0] == '\0') { GetIdentityFromURI(0, ident); // if the usernames match, then clear the ident so we will pick // up the one from the auth cache instead. if (nsCRT::strcmp(ident.User(), entry->User()) == 0) ident.Clear(); } bool identFromURI; if (ident.IsEmpty()) { ident.Set(entry->Identity()); identFromURI = false; } else identFromURI = true; nsXPIDLCString temp; const char *creds = entry->Creds(); const char *challenge = entry->Challenge(); // we can only send a preemptive Authorization header if we have either // stored credentials or a stored challenge from which to derive // credentials. if the identity is from the URI, then we cannot use // the stored credentials. if ((!creds[0] || identFromURI) && challenge[0]) { nsCOMPtr<nsIHttpAuthenticator> auth; nsCAutoString unused; rv = GetAuthenticator(challenge, unused, getter_AddRefs(auth)); if (NS_SUCCEEDED(rv)) { bool proxyAuth = (header == nsHttp::Proxy_Authorization); rv = GenCredsAndSetEntry(auth, proxyAuth, scheme, host, port, path, entry->Realm(), challenge, ident, entry->mMetaData, getter_Copies(temp)); if (NS_SUCCEEDED(rv)) creds = temp.get(); // make sure the continuation state is null since we do not // support mixing preemptive and 'multirequest' authentication. NS_IF_RELEASE(*continuationState); } } if (creds[0]) { LOG((" adding \"%s\" request header\n", header.get())); if (header == nsHttp::Proxy_Authorization) mAuthChannel->SetProxyCredentials(nsDependentCString(creds)); else mAuthChannel->SetWWWCredentials(nsDependentCString(creds)); // suppress defensive auth prompting for this channel since we know // that we already prompted at least once this session. we only do // this for non-proxy auth since the URL's userpass is not used for // proxy auth. if (header == nsHttp::Authorization) mSuppressDefensiveAuth = true; } else ident.Clear(); // don't remember the identity } }
nsresult nsHttpChannelAuthProvider::GetCredentials(const char *challenges, bool proxyAuth, nsAFlatCString &creds) { nsCOMPtr<nsIHttpAuthenticator> auth; nsCAutoString challenge; nsCString authType; // force heap allocation to enable string sharing since // we'll be assigning this value into mAuthType. // set informations that depend on whether we're authenticating against a // proxy or a webserver nsISupports **currentContinuationState; nsCString *currentAuthType; if (proxyAuth) { currentContinuationState = &mProxyAuthContinuationState; currentAuthType = &mProxyAuthType; } else { currentContinuationState = &mAuthContinuationState; currentAuthType = &mAuthType; } nsresult rv = NS_ERROR_NOT_AVAILABLE; bool gotCreds = false; // figure out which challenge we can handle and which authenticator to use. for (const char *eol = challenges - 1; eol; ) { const char *p = eol + 1; // get the challenge string (LF separated -- see nsHttpHeaderArray) if ((eol = strchr(p, '\n')) != nullptr) challenge.Assign(p, eol - p); else challenge.Assign(p); rv = GetAuthenticator(challenge.get(), authType, getter_AddRefs(auth)); if (NS_SUCCEEDED(rv)) { // // if we've already selected an auth type from a previous challenge // received while processing this channel, then skip others until // we find a challenge corresponding to the previously tried auth // type. // if (!currentAuthType->IsEmpty() && authType != *currentAuthType) continue; // // we allow the routines to run all the way through before we // decide if they are valid. // // we don't worry about the auth cache being altered because that // would have been the last step, and if the error is from updating // the authcache it wasn't really altered anyway. -CTN // // at this point the code is really only useful for client side // errors (it will not automatically fail over to do a different // auth type if the server keeps rejecting what is being sent, even // if a particular auth method only knows 1 thing, like a // non-identity based authentication method) // rv = GetCredentialsForChallenge(challenge.get(), authType.get(), proxyAuth, auth, creds); if (NS_SUCCEEDED(rv)) { gotCreds = true; *currentAuthType = authType; break; } else if (rv == NS_ERROR_IN_PROGRESS) { // authentication prompt has been invoked and result is // expected asynchronously, save current challenge being // processed and all remaining challenges to use later in // OnAuthAvailable and now immediately return mCurrentChallenge = challenge; mRemainingChallenges = eol ? eol+1 : nullptr; return rv; } // reset the auth type and continuation state NS_IF_RELEASE(*currentContinuationState); currentAuthType->Truncate(); } } if (!gotCreds && !currentAuthType->IsEmpty()) { // looks like we never found the auth type we were looking for. // reset the auth type and continuation state, and try again. currentAuthType->Truncate(); NS_IF_RELEASE(*currentContinuationState); rv = GetCredentials(challenges, proxyAuth, creds); } return rv; }
//------------------------------------------------------------------------- NS_IMETHODIMP nsDragService::StartInvokingDragSession(IDataObject * aDataObj, PRUint32 aActionType) { // To do the drag we need to create an object that // implements the IDataObject interface (for OLE) nsNativeDragSource* nativeDragSource = new nsNativeDragSource(mDataTransfer); if (!nativeDragSource) return NS_ERROR_OUT_OF_MEMORY; NS_IF_RELEASE(mNativeDragSrc); mNativeDragSrc = (IDropSource *)nativeDragSource; mNativeDragSrc->AddRef(); // Now figure out what the native drag effect should be DWORD winDropRes; DWORD effects = DROPEFFECT_SCROLL; if (aActionType & DRAGDROP_ACTION_COPY) { effects |= DROPEFFECT_COPY; } if (aActionType & DRAGDROP_ACTION_MOVE) { effects |= DROPEFFECT_MOVE; } if (aActionType & DRAGDROP_ACTION_LINK) { effects |= DROPEFFECT_LINK; } // XXX not sure why we bother to cache this, it can change during // the drag mDragAction = aActionType; mSentLocalDropEvent = PR_FALSE; // Start dragging StartDragSession(); OpenDragPopup(); nsRefPtr<IAsyncOperation> pAsyncOp; // Offer to do an async drag if (SUCCEEDED(aDataObj->QueryInterface(IID_IAsyncOperation, getter_AddRefs(pAsyncOp)))) { pAsyncOp->SetAsyncMode(VARIANT_TRUE); } else { NS_NOTREACHED("When did our data object stop being async"); } // Call the native D&D method HRESULT res = ::DoDragDrop(aDataObj, mNativeDragSrc, effects, &winDropRes); // In cases where the drop operation completed outside the application, update // the source node's nsIDOMNSDataTransfer dropEffect value so it is up to date. if (!mSentLocalDropEvent) { PRUint32 dropResult; // Order is important, since multiple flags can be returned. if (winDropRes & DROPEFFECT_COPY) dropResult = DRAGDROP_ACTION_COPY; else if (winDropRes & DROPEFFECT_LINK) dropResult = DRAGDROP_ACTION_LINK; else if (winDropRes & DROPEFFECT_MOVE) dropResult = DRAGDROP_ACTION_MOVE; else dropResult = DRAGDROP_ACTION_NONE; nsCOMPtr<nsIDOMNSDataTransfer> dataTransfer = do_QueryInterface(mDataTransfer); if (dataTransfer) { if (res == DRAGDROP_S_DROP) // Success dataTransfer->SetDropEffectInt(dropResult); else dataTransfer->SetDropEffectInt(DRAGDROP_ACTION_NONE); } } mUserCancelled = nativeDragSource->UserCancelled(); // We're done dragging, get the cursor position and end the drag // Use GetMessagePos to get the position of the mouse at the last message // seen by the event loop. (Bug 489729) DWORD pos = ::GetMessagePos(); POINT cpos; cpos.x = GET_X_LPARAM(pos); cpos.y = GET_Y_LPARAM(pos); SetDragEndPoint(nsIntPoint(cpos.x, cpos.y)); EndDragSession(PR_TRUE); mDoingDrag = PR_FALSE; return DRAGDROP_S_DROP == res ? NS_OK : NS_ERROR_FAILURE; }
//------------------------------------------------------------------------- // // DragService destructor // //------------------------------------------------------------------------- nsDragService::~nsDragService() { NS_IF_RELEASE(mNativeDragSrc); NS_IF_RELEASE(mNativeDragTarget); NS_IF_RELEASE(mDataObject); }
bool GRELoadAndLaunch(const char* firefoxDir, bool silentFail) { char xpcomDllPath[MAXPATHLEN]; snprintf(xpcomDllPath, MAXPATHLEN, "%s/%s", firefoxDir, XPCOM_DLL); if (silentFail && access(xpcomDllPath, F_OK) != 0) return false; if (NS_FAILED(XPCOMGlueStartup(xpcomDllPath))) { ErrorDialog("Couldn't load the XPCOM library"); return false; } if (NS_FAILED(XPCOMGlueLoadXULFunctions(kXULFuncs))) { ErrorDialog("Couldn't load libxul"); return false; } // NOTE: The GRE has successfully loaded, so we can use XPCOM now { // Scope for any XPCOM stuff we create ScopedLogging log; // Get the path to the runtime char rtPath[MAXPATHLEN]; snprintf(rtPath, MAXPATHLEN, "%s/%s", firefoxDir, kWEBAPPRT_PATH); // Get the path to the runtime's INI file char rtIniPath[MAXPATHLEN]; snprintf(rtIniPath, MAXPATHLEN, "%s/%s", rtPath, kWEBAPPRT_INI); // Load the runtime's INI from its path nsCOMPtr<nsIFile> rtINI; if (NS_FAILED(XRE_GetFileFromPath(rtIniPath, getter_AddRefs(rtINI)))) { ErrorDialog("Couldn't load the runtime INI"); return false; } bool exists; nsresult rv = rtINI->Exists(&exists); if (NS_FAILED(rv) || !exists) { ErrorDialog("The runtime INI doesn't exist"); return false; } nsXREAppData *webShellAppData; if (NS_FAILED(XRE_CreateAppData(rtINI, &webShellAppData))) { ErrorDialog("Couldn't read WebappRT application.ini"); return false; } if (!isProfileOverridden) { SetAllocatedString(webShellAppData->profile, profile); // nsXREAppData::name is used for the class name part of the WM_CLASS // property. Set it so that the DE can match our window to the correct // launcher. char programClass[MAXPATHLEN]; snprintf(programClass, MAXPATHLEN, "owa-%s", profile); SetAllocatedString(webShellAppData->name, programClass); } nsCOMPtr<nsIFile> directory; if (NS_FAILED(XRE_GetFileFromPath(rtPath, getter_AddRefs(directory)))) { ErrorDialog("Couldn't open runtime directory"); return false; } nsCOMPtr<nsIFile> xreDir; if (NS_FAILED(XRE_GetFileFromPath(firefoxDir, getter_AddRefs(xreDir)))) { ErrorDialog("Couldn't open XRE directory"); return false; } xreDir.forget(&webShellAppData->xreDirectory); NS_IF_RELEASE(webShellAppData->directory); directory.forget(&webShellAppData->directory); XRE_main(*pargc, *pargv, webShellAppData, 0); XRE_FreeAppData(webShellAppData); } return true; }
nsresult nsDNSPrefetch::Shutdown() { NS_IF_RELEASE(sDNSService); return NS_OK; }
/* static */ void nsXBLWindowKeyHandler::ShutDown() { NS_IF_RELEASE(sNativeEditorBindings); }
already_AddRefed<nsContentList> NS_GetContentList(nsINode* aRootNode, nsIAtom* aMatchAtom, PRInt32 aMatchNameSpaceId) { NS_ASSERTION(aRootNode, "content list has to have a root"); nsContentList* list = nsnull; static PLDHashTableOps hash_table_ops = { PL_DHashAllocTable, PL_DHashFreeTable, ContentListHashtableHashKey, ContentListHashtableMatchEntry, PL_DHashMoveEntryStub, PL_DHashClearEntryStub, PL_DHashFinalizeStub }; // Initialize the hashtable if needed. if (!gContentListHashTable.ops) { PRBool success = PL_DHashTableInit(&gContentListHashTable, &hash_table_ops, nsnull, sizeof(ContentListHashEntry), 16); if (!success) { gContentListHashTable.ops = nsnull; } } ContentListHashEntry *entry = nsnull; // First we look in our hashtable. Then we create a content list if needed if (gContentListHashTable.ops) { nsContentListKey hashKey(aRootNode, aMatchAtom, aMatchNameSpaceId); // A PL_DHASH_ADD is equivalent to a PL_DHASH_LOOKUP for cases // when the entry is already in the hashtable. entry = static_cast<ContentListHashEntry *> (PL_DHashTableOperate(&gContentListHashTable, &hashKey, PL_DHASH_ADD)); if (entry) list = entry->mContentList; } if (!list) { // We need to create a ContentList and add it to our new entry, if // we have an entry list = new nsContentList(aRootNode, aMatchAtom, aMatchNameSpaceId); if (entry) { if (list) entry->mContentList = list; else PL_DHashTableRawRemove(&gContentListHashTable, entry); } NS_ENSURE_TRUE(list, nsnull); } NS_ADDREF(list); // Hold on to the last requested content list to avoid having it be // removed from the cache immediately when it's released. Avoid // bumping the refcount on the list if the requested list is the one // that's already cached. if (gCachedContentList != list) { NS_IF_RELEASE(gCachedContentList); gCachedContentList = list; NS_ADDREF(gCachedContentList); } return list; }
//static void nsBaseContentList::Shutdown() { NS_IF_RELEASE(gCachedContentList); }