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_
10 #include "nsAutoPtr.h"
15 #include "mozStorageBindingParamsArray.h"
16 #include "mozStorageStatementData.h"
17 #include "mozIStorageAsyncStatement.h"
18 #include "StorageBaseStatementInternal.h"
19 #include "mozilla/Attributes.h"
21 class nsIXPConnectJSObjectHolder
;
27 class AsyncStatementJSHelper
;
30 class AsyncStatement MOZ_FINAL
: public mozIStorageAsyncStatement
31 , public StorageBaseStatementInternal
34 NS_DECL_THREADSAFE_ISUPPORTS
35 NS_DECL_MOZISTORAGEASYNCSTATEMENT
36 NS_DECL_MOZISTORAGEBASESTATEMENT
37 NS_DECL_MOZISTORAGEBINDINGPARAMS
38 NS_DECL_STORAGEBASESTATEMENTINTERNAL
43 * Initializes the object on aDBConnection by preparing the SQL statement
44 * given by aSQLStatement.
46 * @param aDBConnection
47 * The Connection object this statement is associated with.
48 * @param aNativeConnection
49 * The native Sqlite connection this statement is associated with.
50 * @param aSQLStatement
51 * The SQL statement to prepare that this object will represent.
53 nsresult
initialize(Connection
*aDBConnection
,
54 sqlite3
*aNativeConnection
,
55 const nsACString
&aSQLStatement
);
58 * Obtains and transfers ownership of the array of parameters that are bound
59 * to this statment. This can be null.
61 inline already_AddRefed
<BindingParamsArray
> bindingParamsArray()
63 return mParamsArray
.forget();
71 * @return a pointer to the BindingParams object to use with our Bind*
74 mozIStorageBindingParams
*getParams();
77 * The SQL string as passed by the user. We store it because we create the
78 * async statement on-demand on the async thread.
83 * Holds the array of parameters to bind to this statement when we execute
86 nsRefPtr
<BindingParamsArray
> mParamsArray
;
89 * Caches the JS 'params' helper for this statement.
91 nsMainThreadPtrHandle
<nsIXPConnectJSObjectHolder
> mStatementParamsHolder
;
94 * Have we been explicitly finalized by the user?
99 * Required for access to private mStatementParamsHolder field by
100 * AsyncStatementJSHelper::getParams.
102 friend class AsyncStatementJSHelper
;
108 #endif // mozilla_storage_mozStorageAsyncStatement_h_