From bfa65f5d5f4fc1a1330acc91945d0587ddf65104 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 8 Feb 2018 11:43:07 +0100 Subject: Cleanup async mozStorage callback management. Also avoid raw pointers in mozStorageAsyncStatementExecution.cpp. --- storage/mozStorageAsyncStatementExecution.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'storage/mozStorageAsyncStatementExecution.h') diff --git a/storage/mozStorageAsyncStatementExecution.h b/storage/mozStorageAsyncStatementExecution.h index c8493fd77..14ea49c2d 100644 --- a/storage/mozStorageAsyncStatementExecution.h +++ b/storage/mozStorageAsyncStatementExecution.h @@ -82,6 +82,14 @@ public: */ bool shouldNotify(); + /** + * Used by notifyComplete(), notifyError() and notifyResults() to notify on + * the calling thread. + */ + nsresult notifyCompleteOnCallingThread(); + nsresult notifyErrorOnCallingThread(mozIStorageError *aError); + nsresult notifyResultsOnCallingThread(ResultSet *aResultSet); + private: AsyncExecuteStatements(StatementDataArray &aStatements, Connection *aConnection, @@ -186,7 +194,10 @@ private: RefPtr mConnection; sqlite3 *mNativeConnection; bool mHasTransaction; - mozIStorageStatementCallback *mCallback; + // Note, this may not be a threadsafe object - never addref/release off + // the calling thread. We take a reference when this is created, and + // release it in the CompletionNotifier::Run() call back to this thread. + nsCOMPtr mCallback; nsCOMPtr mCallingThread; RefPtr mResultSet; -- cgit v1.2.3