/* * NativePickDefaultDirectory * Platform-specific implementation of GetDirectoryPath */ char* nsFolderSpec::NativePickDefaultDirectory(void) { su_PickDirTimer callback; char * packageName; char prompt[200]; callback.context = XP_FindSomeContext(); callback.fileName = NULL; callback.done = FALSE; /* Get the name of the package to prompt for */ packageName = userPackageName; if (packageName) { /* In Java thread now, and need to call FE_PromptForFileName * from the main thread * post an event on a timer, and busy-wait until it completes. */ PR_snprintf(prompt, 200, XP_GetString(SU_INSTALL_ASK_FOR_DIRECTORY), packageName); callback.prompt = prompt; FE_SetTimeout( pickDirectoryCallback, &callback, 1 ); while (!callback.done) /* Busy loop for now */ PR_Sleep(PR_INTERVAL_NO_WAIT); /* java_lang_Thread_yield(WHAT?); */ } return callback.fileName; }
void FontDisplayerPeerObject::decideToUnload(void) { if (streamCount == 0 && fhList.isEmpty()) { // This displayer can be unloaded. // I really want to do something like unloading the displayer // after say 1 min. because say the navigator moves from one page // to another and both had use for this displayer, then this displayer // will get loaded twice and unloaded once causing thrashing. // // The problem in implementing this is how to we ensure we get // back control after this many seconds. We should use the // FE Timer callback. // Clear any previous timers if (unloadTimerId) { FE_ClearTimeout(unloadTimerId); } // Set the new timer unloadTimerId = FE_SetTimeout(wf_unloadTimer, this, WF_ONE_MINUTE); } else { // Unload should not happen if (unloadTimerId) { FE_ClearTimeout(unloadTimerId); } } }
void net_process_net_timer_callback(void *closure) { if(!NET_ProcessNet(NULL, NET_EVERYTIME_TYPE)) return; /* dont reset the timer */ if(net_calling_all_the_time_count) FE_SetTimeout(net_process_net_timer_callback, NULL, 1); }
void net_process_slow_net_timer_callback(void *closure) { if(!NET_ProcessNet(NULL, NET_EVERYTIME_TYPE)) net_slow_timer_on = FALSE; /* dont reset the timer */ else if (net_slow_timer_on) FE_SetTimeout(net_process_slow_net_timer_callback, NULL, SLOW_NETLIB_TIMER_INTERVAL_MILLISECONDS); }
/* this function turns on and off a reasonably slow timer that will * push the netlib along even when it doesn't get any onIdle time. * this is unfortunately necessary on windows because when a modal * dialog is up it won't call the OnIdle loop which is currently the * source of our events. */ MODULE_PRIVATE void NET_SetNetlibSlowKickTimer(XP_Bool set) { if(net_slow_timer_on == set) return; /* do nothing */ net_slow_timer_on = set; /* call immediately */ if(net_slow_timer_on) FE_SetTimeout(net_process_slow_net_timer_callback, NULL, SLOW_NETLIB_TIMER_INTERVAL_MILLISECONDS); }
void RDFglueInitialize() { timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10); /* once every 10 minutes */ if (gRLForbiddenDomains != NULL) { freeMem(gRLForbiddenDomains); gRLForbiddenDomains = NULL; } if (PREF_CopyCharPref("browser.relatedLinksDisabledForDomains", &gRLForbiddenDomains) != PREF_OK) { gRLForbiddenDomains = NULL; } }
void wfe_PostDelayedMessage(UINT uMsg, WPARAM wParam, LPARAM lParam, uint32 uMilli = HIDDENTIME) { HiddenMessage *pMsg = new HiddenMessage; if(pMsg) { memset(pMsg, 0, sizeof(*pMsg)); pMsg->m_uMsg = uMsg; pMsg->m_wParam = wParam; pMsg->m_lParam = lParam; void *pSet = FE_SetTimeout(wfe_HiddenRepost, (void *)pMsg, uMilli); if(NULL == pSet) { delete pMsg; pMsg = NULL; } } }
MODULE_PRIVATE void NET_SetCallNetlibAllTheTime(MWContext *context, char *caller) { if(net_calling_all_the_time_count < 0) { XP_ASSERT(0); net_calling_all_the_time_count = 0; } #ifdef USE_TIMERS_FOR_CALL_ALL_THE_TIME FE_SetTimeout(net_process_net_timer_callback, NULL, 1); #endif /* USE_TIMERS_FOR_CALL_ALL_THE_TIME */ net_calling_all_the_time_count++; }
void nsTopProgressManager::Tick(void) { TRACE_PROGRESS(("nsProgressManager.Tick: aggregating information for active objects\n")); AggregateTransferInfo info = { 0, 0, 0, 0, 0, 0, 0 }; PL_HashTableEnumerateEntries(fURLs, pm_AggregateTransferInfo, (void*) &info); TRACE_PROGRESS(("nsProgressManager.Tick: %ld of %ld objects complete, " "%ldms left, " "%ld of %ld bytes xferred\n", info.CompleteCount, info.ObjectCount, info.MSecRemaining, info.BytesReceived, info.ContentLength)); PR_ASSERT(info.ObjectCount > 0); if (info.ObjectCount == 0) return; UpdateProgressBar(info); UpdateStatusMessage(info); // Check to see if we're done. if (info.CompleteCount == info.ObjectCount) { TRACE_PROGRESS(("Complete: %ld/%ld objects loaded\n", info.CompleteCount, info.ObjectCount)); // XXX needs to go to allxpstr.h FE_Progress(fContext, " "); PL_HashTableDestroy(fURLs); fURLs = NULL; fTimeout = NULL; } else { // Reset the timeout to fire again... fTimeout = FE_SetTimeout(nsTopProgressManager::TimeoutCallback, (void*) this, 500); } }
nsTopProgressManager::nsTopProgressManager(MWContext* context) : nsProgressManager(context), fActualStart(PR_Now()), fProgressBarStart(PR_Now()), fDefaultStatus(NULL) { fURLs = PL_NewHashTable(OBJECT_TABLE_INIT_SIZE, pm_HashURL, pm_CompareURLs, PL_CompareValues, &AllocOps, NULL); // Start the progress manager fTimeout = FE_SetTimeout(nsTopProgressManager::TimeoutCallback, (void*) this, 500); PR_ASSERT(fTimeout); // to avoid "strobe" mode... fProgress = 1; FE_SetProgressBarPercent(fContext, fProgress); }
int rdf_GetURL (MWContext *cx, int method, Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile) { MozillaEvent_rdf_GetURL *event; URL_Struct *urls = NULL; char *url; #ifdef DEBUG_gagan return 0; #endif if (cx == NULL) return 0; if (rdfFile->refreshingp && rdfFile->updateURL) { url = rdfFile->updateURL; } else { url = rdfFile->url; } if (strcmp(url, gNavCntrUrl) == 0) { urls = NET_CreateURLStruct(url, NET_CACHE_ONLY_RELOAD); #ifdef NU_CACHE if (!CacheManager_Contains(url)) { #else if (NET_IsURLInDiskCache(urls) || NET_IsURLInMemCache(urls)) { } else { #endif NET_FreeURLStruct(urls); urls = NULL; } } if (!urls) urls = NET_CreateURLStruct(url, (rdfFile->refreshingp ? NET_SUPER_RELOAD : NET_NORMAL_RELOAD)); if (urls == NULL) return 0; urls->fe_data = rdfFile; if (method) urls->method = method; if (PR_CurrentThread() == mozilla_thread) { htLoadBegins(urls, url); NET_GetURL(urls, FO_CACHE_AND_RDF, cx, rdf_GetUrlExitFunc); } else { /* send event to Mozilla thread */ if (mozilla_event_queue == NULL) return(0); event = PR_NEW(MozillaEvent_rdf_GetURL); if (event == NULL) return(0); PR_InitEvent(&(event->ce.event), cx, (PRHandleEventProc)rdf_HandleEvent_GetURL, (PRDestroyEventProc)rdf_DisposeEvent_GetURL); event->url = copyString(url); event->urls = urls; event->method = FO_CACHE_AND_RDF; event->cx = cx; event->exitFunc = rdf_GetUrlExitFunc; PR_PostEvent(mozilla_event_queue, &(event->ce.event)); } return 1; } #endif /* MOZILLA_CLIENT */ void possiblyRereadRDFFiles (void* data) { possiblyRefreshRDFFiles(); /* timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10); once every 10 minutes diabled for legal reasons.*/ } void RDFglueInitialize() { #ifdef MOZILLA_CLIENT timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10); /* once every 10 minutes */ if (gRLForbiddenDomains != NULL) { freeMem(gRLForbiddenDomains); gRLForbiddenDomains = NULL; } if (PREF_CopyCharPref("browser.relatedLinksDisabledForDomains", &gRLForbiddenDomains) != PREF_OK) { gRLForbiddenDomains = NULL; } #endif /* MOZILLA_CLIENT */ }