(215094) - Opera Migrator hangs at the end occasionally because of null observer service

git-svn-id: svn://10.0.0.236/trunk@153363 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
ben%bengoodger.com
2004-02-29 01:49:53 +00:00
parent 4b69e4d1b3
commit e913f4cd09
22 changed files with 48 additions and 51 deletions

View File

@@ -208,6 +208,7 @@ var MigrationWizard = {
observe: function (aSubject, aTopic, aData)
{
dump("*** aSubject = " + aSubject + ", aTopic = " + aTopic + ", aData = " + aData + "\n");
switch (aTopic) {
case "Migration:Started":
dump("*** started\n");

View File

@@ -44,8 +44,7 @@
#define MIGRATION_ENDED "Migration:Ended"
#define NOTIFY_OBSERVERS(message, item) \
if (sObserverService) \
sObserverService->NotifyObservers(nsnull, message, item)
mObserverService->NotifyObservers(nsnull, message, item)
#define COPY_DATA(func, replace, itemIndex) \
if (NS_SUCCEEDED(rv) && (aItems & itemIndex || !aItems)) { \

View File

@@ -49,16 +49,13 @@
NS_IMPL_ISUPPORTS1(nsCaminoProfileMigrator, nsIBrowserProfileMigrator)
static nsIObserverService* sObserverService = nsnull;
nsCaminoProfileMigrator::nsCaminoProfileMigrator()
{
CallGetService("@mozilla.org/observer-service;1", &sObserverService);
mObserverService = do_GetService("@mozilla.org/observer-service;1");
}
nsCaminoProfileMigrator::~nsCaminoProfileMigrator()
{
NS_IF_RELEASE(sObserverService);
}
///////////////////////////////////////////////////////////////////////////////

View File

@@ -39,6 +39,7 @@
#define caminoprofilemigrator___h___
#include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsString.h"
@@ -54,6 +55,7 @@ public:
protected:
private:
nsCOMPtr<nsIObserverService> mObserverService;
};
#endif

View File

@@ -93,16 +93,13 @@
NS_IMPL_ISUPPORTS1(nsDogbertProfileMigrator, nsIBrowserProfileMigrator)
static nsIObserverService* sObserverService = nsnull;
nsDogbertProfileMigrator::nsDogbertProfileMigrator()
{
CallGetService("@mozilla.org/observer-service;1", &sObserverService);
mObserverService = do_GetService("@mozilla.org/observer-service;1");
}
nsDogbertProfileMigrator::~nsDogbertProfileMigrator()
{
NS_IF_RELEASE(sObserverService);
}
///////////////////////////////////////////////////////////////////////////////

View File

@@ -40,6 +40,7 @@
#include "nsIBrowserProfileMigrator.h"
#include "nsILocalFile.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsNetscapeProfileMigratorBase.h"
#include "nsString.h"
@@ -82,6 +83,7 @@ protected:
private:
nsCOMPtr<nsISupportsArray> mProfiles;
nsCOMPtr<nsIObserverService> mObserverService;
};
#endif

View File

@@ -49,16 +49,13 @@
NS_IMPL_ISUPPORTS1(nsICabProfileMigrator, nsIBrowserProfileMigrator)
static nsIObserverService* sObserverService = nsnull;
nsICabProfileMigrator::nsICabProfileMigrator()
{
CallGetService("@mozilla.org/observer-service;1", &sObserverService);
mObserverService = do_GetService("@mozilla.org/observer-service;1");
}
nsICabProfileMigrator::~nsICabProfileMigrator()
{
NS_IF_RELEASE(sObserverService);
}
///////////////////////////////////////////////////////////////////////////////

View File

@@ -39,6 +39,7 @@
#define icabprofilemigrator___h___
#include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsString.h"
@@ -54,6 +55,7 @@ public:
protected:
private:
nsCOMPtr<nsIObserverService> mObserverService;
};
#endif

View File

@@ -99,8 +99,6 @@ const int sInitialCookieBufferSize = 1024; // but it can grow
const int sUsernameLengthLimit = 80;
const int sHostnameLengthLimit = 255;
static nsIObserverService* sObserverService = nsnull;
//***********************************************************************
//*** windows registry to mozilla prefs data type translation functions
//***********************************************************************
@@ -489,11 +487,11 @@ NS_IMPL_ISUPPORTS1(nsIEProfileMigrator, nsIBrowserProfileMigrator);
nsIEProfileMigrator::nsIEProfileMigrator()
{
CallGetService("@mozilla.org/observer-service;1", &sObserverService);
mObserverService = do_GetService("@mozilla.org/observer-service;1");
}
nsIEProfileMigrator::~nsIEProfileMigrator() {
NS_IF_RELEASE(sObserverService);
nsIEProfileMigrator::~nsIEProfileMigrator()
{
}
nsresult

View File

@@ -44,6 +44,7 @@
#include <time.h>
#include <windows.h>
#include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h"
#include "nsVoidArray.h"
class nsIFile;
@@ -63,7 +64,7 @@ public:
nsIEProfileMigrator();
virtual ~nsIEProfileMigrator();
private:
protected:
nsresult CopyPreferences(PRBool aReplace);
nsresult CopyStyleSheet(PRBool aReplace);
nsresult CopyCookies(PRBool aReplace);
@@ -97,6 +98,9 @@ private:
time_t FileTimeToTimeT(const char *aLowDateIntString,
const char *aHighDateIntString);
void GetUserStyleSheetFile(nsIFile **aUserFile);
private:
nsCOMPtr<nsIObserverService> mObserverService;
};
#endif

View File

@@ -49,16 +49,13 @@
NS_IMPL_ISUPPORTS1(nsMacIEProfileMigrator, nsIBrowserProfileMigrator)
static nsIObserverService* sObserverService = nsnull;
nsMacIEProfileMigrator::nsMacIEProfileMigrator()
{
CallGetService("@mozilla.org/observer-service;1", &sObserverService);
mObserverService = do_GetService("@mozilla.org/observer-service;1");
}
nsMacIEProfileMigrator::~nsMacIEProfileMigrator()
{
NS_IF_RELEASE(sObserverService);
}
///////////////////////////////////////////////////////////////////////////////

View File

@@ -39,6 +39,7 @@
#define maciebprofilemigrator___h___
#include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsString.h"
@@ -54,6 +55,7 @@ public:
protected:
private:
nsCOMPtr<nsIObserverService> mObserverService;
};
#endif

View File

@@ -49,16 +49,13 @@
NS_IMPL_ISUPPORTS1(nsOmniWebProfileMigrator, nsIBrowserProfileMigrator)
static nsIObserverService* sObserverService = nsnull;
nsOmniWebProfileMigrator::nsOmniWebProfileMigrator()
{
CallGetService("@mozilla.org/observer-service;1", &sObserverService);
mObserverService = do_GetService("@mozilla.org/observer-service;1");
}
nsOmniWebProfileMigrator::~nsOmniWebProfileMigrator()
{
NS_IF_RELEASE(sObserverService);
}
///////////////////////////////////////////////////////////////////////////////

View File

@@ -39,6 +39,7 @@
#define omniwebprofilemigrator___h___
#include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsString.h"
@@ -54,6 +55,7 @@ public:
protected:
private:
nsCOMPtr<nsIObserverService> mObserverService;
};
#endif

View File

@@ -94,16 +94,13 @@ static NS_DEFINE_CID(kGlobalHistoryCID, NS_GLOBALHISTORY_CID);
NS_IMPL_ISUPPORTS1(nsOperaProfileMigrator, nsIBrowserProfileMigrator)
static nsIObserverService* sObserverService = nsnull;
nsOperaProfileMigrator::nsOperaProfileMigrator()
{
CallGetService("@mozilla.org/observer-service;1", &sObserverService);
mObserverService = do_GetService("@mozilla.org/observer-service;1");
}
nsOperaProfileMigrator::~nsOperaProfileMigrator()
{
NS_IF_RELEASE(sObserverService);
}
NS_IMETHODIMP
@@ -960,7 +957,8 @@ nsOperaProfileMigrator::CopyBookmarks(PRBool aReplace)
else
parentFolder = root;
#ifdef XP_WIN
#if defined(XP_WIN) || (defined(XP_UNIX) && !defined(XP_MACOSX))
printf("*** before CopySmartKeywords\n");
CopySmartKeywords(bms, bundle, parentFolder);
#endif
@@ -973,7 +971,7 @@ nsOperaProfileMigrator::CopyBookmarks(PRBool aReplace)
return ParseBookmarksFolder(lineInputStream, parentFolder, toolbar, bms);
}
#ifdef XP_WIN
#if defined(XP_WIN) || (defined(XP_UNIX) && !defined(XP_MACOSX))
nsresult
nsOperaProfileMigrator::CopySmartKeywords(nsIBookmarksService* aBMS,
nsIStringBundle* aBundle,
@@ -1166,6 +1164,9 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
nsIRDFResource* aToolbar,
nsIBookmarksService* aBMS)
{
static PRInt32 callCount = 0;
printf("*** Entering ParseBookmarksFolder %d\n", ++callCount);
nsresult rv;
PRBool moreData = PR_FALSE;
nsAutoString buffer;
EntryType entryType = EntryType_BOOKMARK;
@@ -1173,7 +1174,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
nsCAutoString url;
PRBool onToolbar = PR_FALSE;
do {
nsresult rv = aStream->ReadLine(buffer, &moreData);
rv = aStream->ReadLine(buffer, &moreData);
if (NS_FAILED(rv)) return rv;
if (!moreData) break;
@@ -1226,7 +1227,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
url.AssignWithConversion(empty);
keyword = empty;
description = empty;
if (NS_FAILED(rv))
if (NS_FAILED(rv))
continue;
}
}
@@ -1239,7 +1240,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
name = empty;
if (NS_FAILED(rv))
continue;
ParseBookmarksFolder(aStream, itemRes, aToolbar, aBMS);
rv = ParseBookmarksFolder(aStream, itemRes, aToolbar, aBMS);
}
}
break;
@@ -1251,7 +1252,7 @@ nsOperaProfileMigrator::ParseBookmarksFolder(nsILineInputStream* aStream,
while (1);
done:
return NS_OK;
return rv;
}
void

View File

@@ -41,6 +41,7 @@
#include "nsCOMPtr.h"
#include "nsIBinaryInputStream.h"
#include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsString.h"
#include "nsVoidArray.h"
@@ -106,7 +107,7 @@ protected:
nsIRDFResource* aFolder,
nsIRDFResource* aToolbar,
nsIBookmarksService* aBMS);
#ifdef XP_WIN
#if defined(XP_WIN) || (defined(XP_UNIX) && !defined(XP_MACOSX))
nsresult CopySmartKeywords(nsIBookmarksService* aBMS,
nsIStringBundle* aBundle,
nsIRDFResource* aParentFolder);
@@ -117,6 +118,7 @@ protected:
private:
nsCOMPtr<nsILocalFile> mOperaProfile;
nsCOMPtr<nsISupportsArray> mProfiles;
nsCOMPtr<nsIObserverService> mObserverService;
};
class nsOperaCookieMigrator

View File

@@ -68,16 +68,13 @@
NS_IMPL_ISUPPORTS1(nsPhoenixProfileMigrator, nsIBrowserProfileMigrator)
static nsIObserverService* sObserverService = nsnull;
nsPhoenixProfileMigrator::nsPhoenixProfileMigrator()
{
CallGetService("@mozilla.org/observer-service;1", &sObserverService);
mObserverService = do_GetService("@mozilla.org/observer-service;1");
}
nsPhoenixProfileMigrator::~nsPhoenixProfileMigrator()
{
NS_IF_RELEASE(sObserverService);
}
///////////////////////////////////////////////////////////////////////////////

View File

@@ -40,6 +40,7 @@
#include "nsIBrowserProfileMigrator.h"
#include "nsILocalFile.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsNetscapeProfileMigratorBase.h"
#include "nsString.h"
@@ -80,6 +81,7 @@ protected:
private:
nsCOMPtr<nsISupportsArray> mProfileNames;
nsCOMPtr<nsISupportsArray> mProfileLocations;
nsCOMPtr<nsIObserverService> mObserverService;
};
#endif

View File

@@ -68,16 +68,13 @@
NS_IMPL_ISUPPORTS1(nsSafariProfileMigrator, nsIBrowserProfileMigrator)
static nsIObserverService* sObserverService = nsnull;
nsSafariProfileMigrator::nsSafariProfileMigrator()
{
CallGetService("@mozilla.org/observer-service;1", &sObserverService);
mObserverService = do_GetService("@mozilla.org/observer-service;1");
}
nsSafariProfileMigrator::~nsSafariProfileMigrator()
{
NS_IF_RELEASE(sObserverService);
}
///////////////////////////////////////////////////////////////////////////////

View File

@@ -39,6 +39,7 @@
#define safariprofilemigrator___h___
#include "nsIBrowserProfileMigrator.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsString.h"
@@ -85,6 +86,7 @@ protected:
nsresult CopyBookmarks(PRBool aReplace);
private:
nsCOMPtr<nsIObserverService> mObserverService;
};
#endif

View File

@@ -69,16 +69,13 @@
NS_IMPL_ISUPPORTS1(nsSeamonkeyProfileMigrator, nsIBrowserProfileMigrator)
static nsIObserverService* sObserverService = nsnull;
nsSeamonkeyProfileMigrator::nsSeamonkeyProfileMigrator()
{
CallGetService("@mozilla.org/observer-service;1", &sObserverService);
mObserverService = do_GetService("@mozilla.org/observer-service;1");
}
nsSeamonkeyProfileMigrator::~nsSeamonkeyProfileMigrator()
{
NS_IF_RELEASE(sObserverService);
}
///////////////////////////////////////////////////////////////////////////////

View File

@@ -40,6 +40,7 @@
#include "nsIBrowserProfileMigrator.h"
#include "nsILocalFile.h"
#include "nsIObserverService.h"
#include "nsISupportsArray.h"
#include "nsNetscapeProfileMigratorBase.h"
#include "nsString.h"
@@ -86,6 +87,7 @@ protected:
private:
nsCOMPtr<nsISupportsArray> mProfileNames;
nsCOMPtr<nsISupportsArray> mProfileLocations;
nsCOMPtr<nsIObserverService> mObserverService;
};
#endif