Bumping gaia.json for 2 gaia revision(s) a=gaia-bump
[gecko.git] / storage / src / mozStorageAsyncStatement.h
blobd0688639325eb84c30f8030326f7afe4a533b3a6
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"
11 #include "nsString.h"
13 #include "nsTArray.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;
22 struct sqlite3_stmt;
24 namespace mozilla {
25 namespace storage {
27 class AsyncStatementJSHelper;
28 class Connection;
30 class AsyncStatement MOZ_FINAL : public mozIStorageAsyncStatement
31 , public StorageBaseStatementInternal
33 public:
34 NS_DECL_THREADSAFE_ISUPPORTS
35 NS_DECL_MOZISTORAGEASYNCSTATEMENT
36 NS_DECL_MOZISTORAGEBASESTATEMENT
37 NS_DECL_MOZISTORAGEBINDINGPARAMS
38 NS_DECL_STORAGEBASESTATEMENTINTERNAL
40 AsyncStatement();
42 /**
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);
57 /**
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();
67 private:
68 ~AsyncStatement();
70 /**
71 * @return a pointer to the BindingParams object to use with our Bind*
72 * method.
74 mozIStorageBindingParams *getParams();
76 /**
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.
80 nsCString mSQLString;
82 /**
83 * Holds the array of parameters to bind to this statement when we execute
84 * it asynchronously.
86 nsRefPtr<BindingParamsArray> mParamsArray;
88 /**
89 * Caches the JS 'params' helper for this statement.
91 nsMainThreadPtrHandle<nsIXPConnectJSObjectHolder> mStatementParamsHolder;
93 /**
94 * Have we been explicitly finalized by the user?
96 bool mFinalized;
98 /**
99 * Required for access to private mStatementParamsHolder field by
100 * AsyncStatementJSHelper::getParams.
102 friend class AsyncStatementJSHelper;
105 } // storage
106 } // mozilla
108 #endif // mozilla_storage_mozStorageAsyncStatement_h_