mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-31 11:01:40 +00:00
Bug 327567, r=darin. Storage connections should not outlive service (crasher).
This commit is contained in:
parent
0fc7a7c541
commit
d25d558be1
@ -47,7 +47,6 @@
|
||||
#include "mozStorageCID.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(mozStorageService, Init)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(mozStorageConnection)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(mozStorageStatementWrapper)
|
||||
|
||||
static const nsModuleComponentInfo components[] =
|
||||
@ -58,12 +57,6 @@ static const nsModuleComponentInfo components[] =
|
||||
mozStorageServiceConstructor
|
||||
},
|
||||
|
||||
{ "Unified Data Store Connection",
|
||||
MOZ_STORAGE_CONNECTION_CID,
|
||||
MOZ_STORAGE_CONNECTION_CONTRACTID,
|
||||
mozStorageConnectionConstructor
|
||||
},
|
||||
|
||||
{ "Unified Data Store Scriptable Statement Wrapper",
|
||||
MOZ_STORAGE_STATEMENT_WRAPPER_CID,
|
||||
MOZ_STORAGE_STATEMENT_WRAPPER_CONTRACTID,
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "mozIStorageFunction.h"
|
||||
|
||||
#include "mozStorageConnection.h"
|
||||
#include "mozStorageService.h"
|
||||
#include "mozStorageStatement.h"
|
||||
#include "mozStorageValueArray.h"
|
||||
|
||||
@ -57,8 +58,9 @@ PRLogModuleInfo* gStorageLog = nsnull;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(mozStorageConnection, mozIStorageConnection)
|
||||
|
||||
mozStorageConnection::mozStorageConnection()
|
||||
: mDBConn(nsnull), mTransactionInProgress(PR_FALSE)
|
||||
mozStorageConnection::mozStorageConnection(mozIStorageService* aService)
|
||||
: mDBConn(nsnull), mTransactionInProgress(PR_FALSE),
|
||||
mStorageService(aService)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -49,12 +49,13 @@
|
||||
#include <sqlite3.h>
|
||||
|
||||
class nsIFile;
|
||||
class mozIStorageService;
|
||||
|
||||
class mozStorageConnection : public mozIStorageConnection
|
||||
{
|
||||
public:
|
||||
|
||||
mozStorageConnection();
|
||||
mozStorageConnection(mozIStorageService* aService);
|
||||
|
||||
NS_IMETHOD Initialize(nsIFile *aDatabaseFile);
|
||||
|
||||
@ -76,6 +77,11 @@ protected:
|
||||
PRBool mTransactionInProgress;
|
||||
|
||||
nsCOMPtr<nsIMutableArray> mFunctions;
|
||||
|
||||
// This isn't accessed but is used to make sure that the connections do
|
||||
// not outlive the service. The service, for example, owns certain locks
|
||||
// in mozStorageAsyncIO file that the connections depend on.
|
||||
nsCOMPtr<mozIStorageService> mStorageService;
|
||||
};
|
||||
|
||||
#endif /* _MOZSTORAGECONNECTION_H_ */
|
||||
|
@ -112,8 +112,9 @@ mozStorageService::OpenSpecialDatabase(const char *aStorageKey, mozIStorageConne
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
mozStorageConnection *msc = new mozStorageConnection();
|
||||
// FIXME: check for out of memory
|
||||
mozStorageConnection *msc = new mozStorageConnection(this);
|
||||
if (! msc)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsCOMPtr<mozIStorageConnection> conn = msc;
|
||||
rv = msc->Initialize (storageFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -129,7 +130,9 @@ mozStorageService::OpenDatabase(nsIFile *aDatabaseFile, mozIStorageConnection **
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
mozStorageConnection *msc = new mozStorageConnection();
|
||||
mozStorageConnection *msc = new mozStorageConnection(this);
|
||||
if (! msc)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
nsCOMPtr<mozIStorageConnection> conn = msc;
|
||||
rv = msc->Initialize (aDatabaseFile);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
Loading…
x
Reference in New Issue
Block a user