Bug 363024 - Calling createInstance() on mozIStorageService crashes. r=sspitzer

This commit is contained in:
sdwilsh@shawnwilsher.com 2007-06-18 19:22:01 -07:00
Родитель 58f854275c
Коммит ed928796c5
3 изменённых файлов: 26 добавлений и 5 удалений

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

@ -21,6 +21,7 @@
*
* Contributor(s):
* Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
* Shawn Wilsher <me@shawnwilsher.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -46,7 +47,8 @@
#include "mozStorageCID.h"
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozStorageService, Init)
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(mozStorageService,
mozStorageService::GetSingleton)
NS_GENERIC_FACTORY_CONSTRUCTOR(mozStorageStatementWrapper)
static const nsModuleComponentInfo components[] =

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

@ -52,14 +52,30 @@ NS_IMPL_THREADSAFE_ISUPPORTS2(mozStorageService, mozIStorageService, nsIObserver
static const char kShutdownMessage[] = "xpcom-shutdown-threads";
mozStorageService::mozStorageService()
mozStorageService *mozStorageService::gStorageService = nsnull;
mozStorageService *
mozStorageService::GetSingleton()
{
if (gStorageService) {
NS_ADDREF(gStorageService);
return gStorageService;
}
gStorageService = new mozStorageService();
if (gStorageService) {
NS_ADDREF(gStorageService);
if (NS_FAILED(gStorageService->Init()))
NS_RELEASE(gStorageService);
}
return gStorageService;
}
mozStorageService::~mozStorageService()
{
FreeLocks();
gStorageService = nsnull;
}
nsresult

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

@ -23,6 +23,7 @@
* Contributor(s):
* Vladimir Vukicevic <vladimir.vukicevic@oracle.com>
* Brett Wilson <brettw@gmail.com>
* Shawn Wilsher <me@shawnwilsher.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -56,11 +57,11 @@ class mozStorageService : public mozIStorageService,
friend class mozStorageConnection;
public:
mozStorageService();
// two-phase init, must call before using service
nsresult Init();
static mozStorageService *GetSingleton();
// nsISupports
NS_DECL_ISUPPORTS
@ -70,10 +71,12 @@ public:
NS_DECL_NSIOBSERVER
private:
~mozStorageService();
virtual ~mozStorageService();
protected:
nsCOMPtr<nsIFile> mProfileStorageFile;
static mozStorageService *gStorageService;
nsresult InitStorageAsyncIO();
nsresult FlushAsyncIO();
nsresult FinishAsyncIO();