зеркало из https://github.com/mozilla/pjs.git
Bug 363024 - Calling createInstance() on mozIStorageService crashes. r=sspitzer
This commit is contained in:
Родитель
58f854275c
Коммит
ed928796c5
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче