зеркало из https://github.com/mozilla/gecko-dev.git
fix for #39853. when populating the subscribe dialog from disk, we'd
block the entire ui. this was bad if the hostinfo.dat file was big. r=mscott
This commit is contained in:
Родитель
db7b98397e
Коммит
edcae4fdcf
|
@ -707,8 +707,6 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
|
|||
// if we don't have a news host already, go get one...
|
||||
if (!m_newsHost)
|
||||
{
|
||||
PRInt32 port = 0;
|
||||
|
||||
m_newsHost = do_CreateInstance(kNNTPHostCID, &rv);
|
||||
if (NS_FAILED(rv) || (!m_newsHost)) goto FAIL;
|
||||
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
#define PREF_MAIL_NEWSRC_ROOT "mail.newsrc_root"
|
||||
#define HOSTINFO_FILE_NAME "hostinfo.dat"
|
||||
|
||||
#define HOSTINFO_COUNT_MAX 200 /* number of groups to process at a time when reading the list from the hostinfo.dat file */
|
||||
#define HOSTINFO_TIMEOUT 5 /* uSec to wait until doing more */
|
||||
|
||||
// this platform specific junk is so the newsrc filenames we create
|
||||
// will resemble the migrated newsrc filenames.
|
||||
#if defined(XP_UNIX) || defined(XP_BEOS)
|
||||
|
@ -73,6 +76,7 @@ NS_INTERFACE_MAP_BEGIN(nsNntpIncomingServer)
|
|||
NS_INTERFACE_MAP_ENTRY(nsINntpIncomingServer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIUrlListener)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISubscribableServer)
|
||||
NS_INTERFACE_MAP_ENTRY(nsITimerCallback)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsMsgIncomingServer)
|
||||
|
||||
nsNntpIncomingServer::nsNntpIncomingServer() : nsMsgLineBuffer(nsnull, PR_FALSE)
|
||||
|
@ -89,6 +93,8 @@ nsNntpIncomingServer::nsNntpIncomingServer() : nsMsgLineBuffer(nsnull, PR_FALSE)
|
|||
mPushAuth = PR_FALSE;
|
||||
mHasSeenBeginGroups = PR_FALSE;
|
||||
mVersion = 0;
|
||||
mGroupsOnServerIndex = 0;
|
||||
mGroupsOnServerCount = 0;
|
||||
}
|
||||
|
||||
nsNntpIncomingServer::~nsNntpIncomingServer()
|
||||
|
@ -99,6 +105,12 @@ nsNntpIncomingServer::~nsNntpIncomingServer()
|
|||
delete mGroupsEnumerator;
|
||||
mGroupsEnumerator = nsnull;
|
||||
}
|
||||
|
||||
if (mUpdateTimer) {
|
||||
mUpdateTimer->Cancel();
|
||||
mUpdateTimer = nsnull;
|
||||
}
|
||||
|
||||
rv = CloseCachedConnections();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "CloseCachedConnections failed");
|
||||
}
|
||||
|
@ -686,19 +698,6 @@ writeGroupToHostInfo(nsCString &aElement, void *aData)
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
addGroupFunction(nsCString &aElement, void *aData)
|
||||
{
|
||||
nsresult rv;
|
||||
nsNntpIncomingServer *server;
|
||||
server = (nsNntpIncomingServer *)aData;
|
||||
|
||||
rv = server->AddToSubscribeDS((const char *)aElement, PR_FALSE, PR_TRUE);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"AddToSubscribeDS failed");
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsNntpIncomingServer::WriteHostInfoFile()
|
||||
{
|
||||
|
@ -803,18 +802,61 @@ nsNntpIncomingServer::PopulateSubscribeDatasourceFromHostInfo(nsIMsgWindow *aMsg
|
|||
#ifdef DEBUG_sspitzer
|
||||
printf("PopulateSubscribeDatasourceFromHostInfo()\n");
|
||||
#endif
|
||||
mGroupsOnServerCount = mGroupsOnServer.Count();
|
||||
nsCString currentGroup;
|
||||
|
||||
mGroupsOnServer.EnumerateForwards((nsCStringArrayEnumFunc)addGroupFunction, (void *)this);
|
||||
while (mGroupsOnServerIndex < mGroupsOnServerCount) {
|
||||
mGroupsOnServer.CStringAt(mGroupsOnServerIndex, currentGroup);
|
||||
rv = AddToSubscribeDS((const char *)currentGroup, PR_FALSE, PR_TRUE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#ifdef DEBUG_seth
|
||||
printf("%d = %s\n",mGroupsOnServerIndex,(const char *)currentGroup);
|
||||
#endif
|
||||
|
||||
rv = UpdateSubscribedInSubscribeDS();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
mGroupsOnServerIndex++;
|
||||
if ((mGroupsOnServerIndex % HOSTINFO_COUNT_MAX) == 0) break;
|
||||
}
|
||||
|
||||
rv = StopPopulatingSubscribeDS();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (mGroupsOnServerIndex < mGroupsOnServerCount) {
|
||||
#ifdef DEBUG_seth
|
||||
printf("there is more to do...\n");
|
||||
#endif
|
||||
if (mUpdateTimer) {
|
||||
mUpdateTimer->Cancel();
|
||||
mUpdateTimer = nsnull;
|
||||
}
|
||||
|
||||
mUpdateTimer = do_CreateInstance("component://netscape/timer", &rv);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to create timer");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
const PRUint32 kUpdateTimerDelay = HOSTINFO_TIMEOUT;
|
||||
rv = mUpdateTimer->Init(NS_STATIC_CAST(nsITimerCallback*,this), kUpdateTimerDelay);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to init timer");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
else {
|
||||
#ifdef DEBUG_seth
|
||||
printf("we are done\n");
|
||||
#endif
|
||||
rv = UpdateSubscribedInSubscribeDS();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = StopPopulatingSubscribeDS();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsNntpIncomingServer::Notify(nsITimer *timer)
|
||||
{
|
||||
NS_ASSERTION(timer == mUpdateTimer.get(), "Hey, this ain't my timer!");
|
||||
mUpdateTimer = nsnull; // release my hold
|
||||
PopulateSubscribeDatasourceFromHostInfo(mMsgWindow);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpIncomingServer::PopulateSubscribeDatasourceWithUri(nsIMsgWindow *aMsgWindow, PRBool aForceToServer, const char *uri)
|
||||
{
|
||||
|
@ -863,6 +905,10 @@ nsNntpIncomingServer::PopulateSubscribeDatasource(nsIMsgWindow *aMsgWindow, PRBo
|
|||
}
|
||||
|
||||
if (!aForceToServer && mHostInfoLoaded && (mVersion == VALID_VERSION)) {
|
||||
mGroupsOnServerIndex = 0;
|
||||
mGroupsOnServerCount = mGroupsOnServer.Count();
|
||||
mMsgWindow = aMsgWindow;
|
||||
|
||||
rv = PopulateSubscribeDatasourceFromHostInfo(aMsgWindow);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#include "nsISubscribableServer.h"
|
||||
#include "nsMsgLineBuffer.h"
|
||||
#include "nsVoidArray.h"
|
||||
#include "nsITimer.h"
|
||||
#include "nsITimerCallback.h"
|
||||
|
||||
class nsINntpUrl;
|
||||
class nsIMsgMailNewsUrl;
|
||||
|
@ -47,6 +49,7 @@ class nsNntpIncomingServer : public nsMsgIncomingServer,
|
|||
public nsINntpIncomingServer,
|
||||
public nsIUrlListener,
|
||||
public nsISubscribableServer,
|
||||
public nsITimerCallback,
|
||||
public nsMsgLineBuffer
|
||||
|
||||
{
|
||||
|
@ -56,6 +59,9 @@ public:
|
|||
NS_DECL_NSIURLLISTENER
|
||||
NS_DECL_NSISUBSCRIBABLESERVER
|
||||
|
||||
// nsITimerCallback interfaces
|
||||
NS_IMETHOD_(void) Notify(nsITimer *timer);
|
||||
|
||||
nsNntpIncomingServer();
|
||||
virtual ~nsNntpIncomingServer();
|
||||
|
||||
|
@ -76,6 +82,8 @@ protected:
|
|||
nsByteArray mHostInfoInputStream;
|
||||
|
||||
private:
|
||||
PRInt32 mGroupsOnServerIndex;
|
||||
PRInt32 mGroupsOnServerCount;
|
||||
nsCStringArray mGroupsOnServer;
|
||||
nsCStringArray mSubscribedNewsgroups;
|
||||
|
||||
|
@ -90,12 +98,15 @@ private:
|
|||
PRBool mHostInfoHasChanged;
|
||||
nsCOMPtr <nsISubscribableServer> mInner;
|
||||
nsCOMPtr <nsIFileSpec> mHostInfoFile;
|
||||
|
||||
|
||||
PRUint32 mLastGroupDate;
|
||||
PRTime mFirstNewDate;
|
||||
PRInt32 mUniqueId;
|
||||
PRBool mPushAuth;
|
||||
PRInt32 mVersion;
|
||||
|
||||
nsCOMPtr <nsITimer> mUpdateTimer;
|
||||
nsCOMPtr <nsIMsgWindow> mMsgWindow;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -154,7 +154,8 @@ nsNntpService::SaveMessageToDisk(const char *aMessageURI,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayConsumer,
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayConsumer,
|
||||
nsIMsgWindow *aMsgWindow, nsIUrlListener * aUrlListener, const PRUnichar * aCharsetOverride, nsIURI ** aURL)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
@ -342,7 +343,8 @@ nsresult nsNntpService::ConvertNewsMessageURI2NewsURI(const char *messageURI, ns
|
|||
}
|
||||
|
||||
|
||||
nsresult nsNntpService::CopyMessage(const char * aSrcMailboxURI, nsIStreamListener * aMailboxCopyHandler, PRBool moveMessage,
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::CopyMessage(const char * aSrcMailboxURI, nsIStreamListener * aMailboxCopyHandler, PRBool moveMessage,
|
||||
nsIUrlListener * aUrlListener, nsIURI **aURL)
|
||||
{
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
|
@ -354,7 +356,8 @@ nsresult nsNntpService::CopyMessage(const char * aSrcMailboxURI, nsIStreamListen
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsNntpService::CopyMessages(nsMsgKeyArray *keys, nsIMsgFolder *srcFolder, nsIStreamListener * aMailboxCopyHandler, PRBool moveMessage,
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::CopyMessages(nsMsgKeyArray *keys, nsIMsgFolder *srcFolder, nsIStreamListener * aMailboxCopyHandler, PRBool moveMessage,
|
||||
nsIUrlListener * aUrlListener, nsIURI **aURL)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
@ -585,7 +588,8 @@ nsNntpService::SetUpNntpUrlForPosting(nsINntpUrl *nntpUrl, const char *newsgroup
|
|||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// nsINntpService support
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
nsresult nsNntpService::ConvertNewsgroupsString(const char *newsgroupsNames, char **_retval)
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::ConvertNewsgroupsString(const char *newsgroupsNames, char **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -733,7 +737,8 @@ nsresult nsNntpService::ConvertNewsgroupsString(const char *newsgroupsNames, cha
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames, nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **_retval)
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames, nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **_retval)
|
||||
{
|
||||
#ifdef DEBUG_NEWS
|
||||
printf("nsNntpService::PostMessage(??,%s,??,??)\n",newsgroupsNames);
|
||||
|
@ -1271,7 +1276,7 @@ nsNntpService::GetDefaultCopiesAndFoldersPrefsToServer(PRBool *aDefaultCopiesAnd
|
|||
// rhp: Right now, this is the same as simple DisplayMessage, but it will change
|
||||
// to support print rendering.
|
||||
//
|
||||
nsresult nsNntpService::DisplayMessageForPrinting(const char* aMessageURI, nsISupports * aDisplayConsumer,
|
||||
NS_IMETHODIMP nsNntpService::DisplayMessageForPrinting(const char* aMessageURI, nsISupports * aDisplayConsumer,
|
||||
nsIMsgWindow *aMsgWindow, nsIUrlListener * aUrlListener, nsIURI ** aURL)
|
||||
{
|
||||
mPrintingOperation = PR_TRUE;
|
||||
|
|
Загрузка…
Ссылка в новой задаче