improve imap performance by not putting up same status msg or frequent percent progress

This commit is contained in:
bienvenu%netscape.com 1999-09-08 18:55:22 +00:00
Родитель 7688b3e6c0
Коммит 2df5db0a75
6 изменённых файлов: 49 добавлений и 9 удалений

Просмотреть файл

@ -238,4 +238,7 @@
## @loc None ## @loc None
5049=The current command did not succeed. The mail server responded:\n 5049=The current command did not succeed. The mail server responded:\n
## @name IMAP_DONE
## @loc None
5050=Document: Done

Просмотреть файл

@ -2931,6 +2931,9 @@ nsImapMailFolder::SetUrlState(nsIImapProtocol* aProtocol,
PRBool isRunning, PRBool isRunning,
nsresult statusCode) nsresult statusCode)
{ {
if (!isRunning)
ProgressStatus(aProtocol, IMAP_DONE, nsnull);
if (aUrl) if (aUrl)
return aUrl->SetUrlState(isRunning, statusCode); return aUrl->SetUrlState(isRunning, statusCode);
return statusCode; return statusCode;

Просмотреть файл

@ -204,6 +204,9 @@ nsImapProtocol::nsImapProtocol() :
LL_I2L(m_startTime, 0); LL_I2L(m_startTime, 0);
LL_I2L(m_endTime, 0); LL_I2L(m_endTime, 0);
LL_I2L(m_lastActiveTime, 0); LL_I2L(m_lastActiveTime, 0);
LL_I2L(m_lastProgressTime, 0);
ResetProgressInfo();
m_tooFastTime = 0; m_tooFastTime = 0;
m_idealTime = 0; m_idealTime = 0;
m_chunkAddSize = 0; m_chunkAddSize = 0;
@ -898,13 +901,6 @@ void nsImapProtocol::ProcessCurrentURL()
else // must be a url that requires us to be in the selected stae else // must be a url that requires us to be in the selected stae
ProcessSelectedStateURL(); ProcessSelectedStateURL();
#ifdef DEBUG_bienvenu1
nsresult rv;
nsCOMPtr<nsIImapIncomingServer> aImapServer = do_QueryInterface(m_server, &rv);
if (NS_SUCCEEDED(rv))
aImapServer->RemoveConnection(this);
TellThreadToDie(PR_TRUE);
#endif
// The URL has now been processed // The URL has now been processed
if (!logonFailed && GetConnectionStatus() < 0) if (!logonFailed && GetConnectionStatus() < 0)
HandleCurrentUrlError(); HandleCurrentUrlError();
@ -926,6 +922,7 @@ void nsImapProtocol::ProcessCurrentURL()
m_imapMiscellaneousSink->SetUrlState(this, mailnewsurl, PR_FALSE, m_imapMiscellaneousSink->SetUrlState(this, mailnewsurl, PR_FALSE,
NS_OK); // we are done with this NS_OK); // we are done with this
// url. // url.
WaitForFEEventCompletion();
} }
m_lastActiveTime = PR_Now(); // ** jt -- is this the best place for time stamp m_lastActiveTime = PR_Now(); // ** jt -- is this the best place for time stamp
PseudoInterrupt(PR_FALSE); // clear this, because we must be done interrupting? PseudoInterrupt(PR_FALSE); // clear this, because we must be done interrupting?
@ -1014,6 +1011,7 @@ NS_IMETHODIMP nsImapProtocol::OnStartRequest(nsIChannel * /* aChannel */, nsISup
{ {
m_imapMiscellaneousSink->SetUrlState(this, mailnewsurl, PR_TRUE, m_imapMiscellaneousSink->SetUrlState(this, mailnewsurl, PR_TRUE,
NS_OK); NS_OK);
WaitForFEEventCompletion();
} }
PR_CExitMonitor(this); PR_CExitMonitor(this);
return NS_OK; return NS_OK;
@ -1029,6 +1027,7 @@ NS_IMETHODIMP nsImapProtocol::OnStopRequest(nsIChannel * /* aChannel */, nsISupp
{ {
m_imapMiscellaneousSink->SetUrlState(this, mailnewsurl, PR_FALSE, m_imapMiscellaneousSink->SetUrlState(this, mailnewsurl, PR_FALSE,
aStatus); // set change in url aStatus); // set change in url
WaitForFEEventCompletion();
} }
m_channel = null_nsCOMPtr(); m_channel = null_nsCOMPtr();
m_outputStream = null_nsCOMPtr(); m_outputStream = null_nsCOMPtr();
@ -3720,6 +3719,13 @@ nsImapProtocol::AlertUserEventFromServer(const char * aServerEvent)
m_imapServerSink->FEAlertFromServer(aServerEvent); m_imapServerSink->FEAlertFromServer(aServerEvent);
} }
void nsImapProtocol::ResetProgressInfo()
{
LL_I2L(m_lastProgressTime, 0);
m_lastPercent = -1;
m_lastProgressStringId = -1;
}
void void
nsImapProtocol::ShowProgress() nsImapProtocol::ShowProgress()
{ {
@ -3752,9 +3758,10 @@ nsImapProtocol::ShowProgress()
void void
nsImapProtocol::ProgressEventFunctionUsingId(PRUint32 aMsgId) nsImapProtocol::ProgressEventFunctionUsingId(PRUint32 aMsgId)
{ {
if (m_imapMiscellaneousSink) if (m_imapMiscellaneousSink && aMsgId != m_lastProgressStringId)
{ {
m_imapMiscellaneousSink->ProgressStatus(this, aMsgId, nsnull); m_imapMiscellaneousSink->ProgressStatus(this, aMsgId, nsnull);
m_lastProgressStringId = aMsgId;
// who's going to free this? Does ProgressStatus complete synchronously? // who's going to free this? Does ProgressStatus complete synchronously?
} }
} }
@ -3774,9 +3781,30 @@ nsImapProtocol::ProgressEventFunctionUsingIdWithString(PRUint32 aMsgId, const
void void
nsImapProtocol::PercentProgressUpdateEvent(PRUnichar *message, PRInt32 percent) nsImapProtocol::PercentProgressUpdateEvent(PRUnichar *message, PRInt32 percent)
{ {
int64 nowMS;
if (percent == m_lastPercent)
return; // hasn't changed, right? So just return. Do we need to clear this anywhere?
if (percent < 100) // always need to do 100%
{
int64 minIntervalBetweenProgress;
LL_I2L(minIntervalBetweenProgress, 250);
int64 diffSinceLastProgress;
LL_I2L(nowMS, PR_IntervalToMilliseconds(PR_IntervalNow()));
LL_SUB(diffSinceLastProgress, nowMS, m_lastProgressTime); // r = a - b
LL_SUB(diffSinceLastProgress, diffSinceLastProgress, minIntervalBetweenProgress); // r = a - b
if (!LL_GE_ZERO(diffSinceLastProgress))
return;
}
ProgressInfo aProgressInfo; ProgressInfo aProgressInfo;
aProgressInfo.message = message; aProgressInfo.message = message;
aProgressInfo.percent = percent; aProgressInfo.percent = percent;
m_lastPercent = percent;
m_lastProgressTime = nowMS;
if (m_imapMiscellaneousSink) if (m_imapMiscellaneousSink)
m_imapMiscellaneousSink->PercentProgress(this, &aProgressInfo); m_imapMiscellaneousSink->PercentProgress(this, &aProgressInfo);
} }

Просмотреть файл

@ -193,11 +193,12 @@ public:
void AlertUserEventUsingId(PRUint32 aMessageId); void AlertUserEventUsingId(PRUint32 aMessageId);
void AlertUserEvent(const char * message); void AlertUserEvent(const char * message);
void AlertUserEventFromServer(const char * aServerEvent); void AlertUserEventFromServer(const char * aServerEvent);
void ShowProgress();
void ProgressEventFunctionUsingId(PRUint32 aMsgId); void ProgressEventFunctionUsingId(PRUint32 aMsgId);
void ProgressEventFunctionUsingIdWithString(PRUint32 aMsgId, const char * void ProgressEventFunctionUsingIdWithString(PRUint32 aMsgId, const char *
aExtraInfo); aExtraInfo);
void PercentProgressUpdateEvent(PRUnichar *message, PRInt32 percent); void PercentProgressUpdateEvent(PRUnichar *message, PRInt32 percent);
void ShowProgress();
// utility function calls made by the server // utility function calls made by the server
char * CreateUtf7ConvertedString(const char * aSourceString, PRBool char * CreateUtf7ConvertedString(const char * aSourceString, PRBool
@ -483,6 +484,9 @@ private:
PRInt32 m_progressStringId; PRInt32 m_progressStringId;
PRInt32 m_progressIndex; PRInt32 m_progressIndex;
PRInt32 m_progressCount; PRInt32 m_progressCount;
PRUint32 m_lastProgressStringId;
PRInt32 m_lastPercent;
PRInt64 m_lastProgressTime;
PRBool m_notifySearchHit; PRBool m_notifySearchHit;
PRBool m_mailToFetch; PRBool m_mailToFetch;

Просмотреть файл

@ -1356,6 +1356,7 @@ nsImapMiscellaneousSinkProxy::SetUrlState(nsIImapProtocol* aProtocol,
res = NS_ERROR_OUT_OF_MEMORY; res = NS_ERROR_OUT_OF_MEMORY;
else else
{ {
ev->SetNotifyCompletion(PR_TRUE);
ev->PostEvent(m_eventQueue); ev->PostEvent(m_eventQueue);
} }
} }

Просмотреть файл

@ -77,4 +77,5 @@ NS_END_EXTERN_C
#define IMAP_ENTER_PASSWORD_PROMPT 5047 #define IMAP_ENTER_PASSWORD_PROMPT 5047
#define IMAP_SERVER_NOT_IMAP4 5048 #define IMAP_SERVER_NOT_IMAP4 5048
#define IMAP_SERVER_SAID 5049 #define IMAP_SERVER_SAID 5049
#define IMAP_DONE 5050
#endif /* _nsImapStringBundle_H__ */ #endif /* _nsImapStringBundle_H__ */