michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_storage_mozStorageAsyncStatement_h_ michael@0: #define mozilla_storage_mozStorageAsyncStatement_h_ michael@0: michael@0: #include "nsAutoPtr.h" michael@0: #include "nsString.h" michael@0: michael@0: #include "nsTArray.h" michael@0: michael@0: #include "mozStorageBindingParamsArray.h" michael@0: #include "mozStorageStatementData.h" michael@0: #include "mozIStorageAsyncStatement.h" michael@0: #include "StorageBaseStatementInternal.h" michael@0: #include "mozilla/Attributes.h" michael@0: michael@0: class nsIXPConnectJSObjectHolder; michael@0: struct sqlite3_stmt; michael@0: michael@0: namespace mozilla { michael@0: namespace storage { michael@0: michael@0: class AsyncStatementJSHelper; michael@0: class Connection; michael@0: michael@0: class AsyncStatement MOZ_FINAL : public mozIStorageAsyncStatement michael@0: , public StorageBaseStatementInternal michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_MOZISTORAGEASYNCSTATEMENT michael@0: NS_DECL_MOZISTORAGEBASESTATEMENT michael@0: NS_DECL_MOZISTORAGEBINDINGPARAMS michael@0: NS_DECL_STORAGEBASESTATEMENTINTERNAL michael@0: michael@0: AsyncStatement(); michael@0: michael@0: /** michael@0: * Initializes the object on aDBConnection by preparing the SQL statement michael@0: * given by aSQLStatement. michael@0: * michael@0: * @param aDBConnection michael@0: * The Connection object this statement is associated with. michael@0: * @param aNativeConnection michael@0: * The native Sqlite connection this statement is associated with. michael@0: * @param aSQLStatement michael@0: * The SQL statement to prepare that this object will represent. michael@0: */ michael@0: nsresult initialize(Connection *aDBConnection, michael@0: sqlite3 *aNativeConnection, michael@0: const nsACString &aSQLStatement); michael@0: michael@0: /** michael@0: * Obtains and transfers ownership of the array of parameters that are bound michael@0: * to this statment. This can be null. michael@0: */ michael@0: inline already_AddRefed bindingParamsArray() michael@0: { michael@0: return mParamsArray.forget(); michael@0: } michael@0: michael@0: michael@0: private: michael@0: ~AsyncStatement(); michael@0: michael@0: /** michael@0: * Clean up the references JS helpers hold to us. For cycle-avoidance reasons michael@0: * they do not hold reference-counted references to us, so it is important michael@0: * we do this. michael@0: */ michael@0: void cleanupJSHelpers(); michael@0: michael@0: /** michael@0: * @return a pointer to the BindingParams object to use with our Bind* michael@0: * method. michael@0: */ michael@0: mozIStorageBindingParams *getParams(); michael@0: michael@0: /** michael@0: * The SQL string as passed by the user. We store it because we create the michael@0: * async statement on-demand on the async thread. michael@0: */ michael@0: nsCString mSQLString; michael@0: michael@0: /** michael@0: * Holds the array of parameters to bind to this statement when we execute michael@0: * it asynchronously. michael@0: */ michael@0: nsRefPtr mParamsArray; michael@0: michael@0: /** michael@0: * Caches the JS 'params' helper for this statement. michael@0: */ michael@0: nsCOMPtr mStatementParamsHolder; michael@0: michael@0: /** michael@0: * Have we been explicitly finalized by the user? michael@0: */ michael@0: bool mFinalized; michael@0: michael@0: /** michael@0: * Required for access to private mStatementParamsHolder field by michael@0: * AsyncStatementJSHelper::getParams. michael@0: */ michael@0: friend class AsyncStatementJSHelper; michael@0: }; michael@0: michael@0: } // storage michael@0: } // mozilla michael@0: michael@0: #endif // mozilla_storage_mozStorageAsyncStatement_h_