1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_storage_mozStorageAsyncStatement_h_
8 #define mozilla_storage_mozStorageAsyncStatement_h_
14 #include "mozStorageBindingParamsArray.h"
15 #include "mozStorageStatementData.h"
16 #include "mozIStorageAsyncStatement.h"
17 #include "StorageBaseStatementInternal.h"
18 #include "mozilla/Attributes.h"
23 class AsyncStatementJSHelper
;
24 class AsyncStatementParamsHolder
;
27 class AsyncStatement final
: public mozIStorageAsyncStatement
,
28 public StorageBaseStatementInternal
{
30 NS_DECL_THREADSAFE_ISUPPORTS
31 NS_DECL_MOZISTORAGEASYNCSTATEMENT
32 NS_DECL_MOZISTORAGEBASESTATEMENT
33 NS_DECL_MOZISTORAGEBINDINGPARAMS
34 NS_DECL_STORAGEBASESTATEMENTINTERNAL
39 * Initializes the object on aDBConnection by preparing the SQL statement
40 * given by aSQLStatement.
42 * @param aDBConnection
43 * The Connection object this statement is associated with.
44 * @param aNativeConnection
45 * The native Sqlite connection this statement is associated with.
46 * @param aSQLStatement
47 * The SQL statement to prepare that this object will represent.
49 nsresult
initialize(Connection
* aDBConnection
, sqlite3
* aNativeConnection
,
50 const nsACString
& aSQLStatement
);
53 * Obtains and transfers ownership of the array of parameters that are bound
54 * to this statment. This can be null.
56 inline already_AddRefed
<BindingParamsArray
> bindingParamsArray() {
57 return mParamsArray
.forget();
64 * @return a pointer to the BindingParams object to use with our Bind*
67 mozIStorageBindingParams
* getParams();
70 * The SQL string as passed by the user. We store it because we create the
71 * async statement on-demand on the async thread.
76 * Holds the array of parameters to bind to this statement when we execute
79 RefPtr
<BindingParamsArray
> mParamsArray
;
82 * Caches the JS 'params' helper for this statement.
84 nsMainThreadPtrHandle
<AsyncStatementParamsHolder
> mStatementParamsHolder
;
87 * Have we been explicitly finalized by the user?
92 * Required for access to private mStatementParamsHolder field by
93 * AsyncStatementJSHelper::getParams.
95 friend class AsyncStatementJSHelper
;
98 } // namespace storage
99 } // namespace mozilla
101 #endif // mozilla_storage_mozStorageAsyncStatement_h_