Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ : |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_storage_mozStorageAsyncStatement_h_ |
michael@0 | 8 | #define mozilla_storage_mozStorageAsyncStatement_h_ |
michael@0 | 9 | |
michael@0 | 10 | #include "nsAutoPtr.h" |
michael@0 | 11 | #include "nsString.h" |
michael@0 | 12 | |
michael@0 | 13 | #include "nsTArray.h" |
michael@0 | 14 | |
michael@0 | 15 | #include "mozStorageBindingParamsArray.h" |
michael@0 | 16 | #include "mozStorageStatementData.h" |
michael@0 | 17 | #include "mozIStorageAsyncStatement.h" |
michael@0 | 18 | #include "StorageBaseStatementInternal.h" |
michael@0 | 19 | #include "mozilla/Attributes.h" |
michael@0 | 20 | |
michael@0 | 21 | class nsIXPConnectJSObjectHolder; |
michael@0 | 22 | struct sqlite3_stmt; |
michael@0 | 23 | |
michael@0 | 24 | namespace mozilla { |
michael@0 | 25 | namespace storage { |
michael@0 | 26 | |
michael@0 | 27 | class AsyncStatementJSHelper; |
michael@0 | 28 | class Connection; |
michael@0 | 29 | |
michael@0 | 30 | class AsyncStatement MOZ_FINAL : public mozIStorageAsyncStatement |
michael@0 | 31 | , public StorageBaseStatementInternal |
michael@0 | 32 | { |
michael@0 | 33 | public: |
michael@0 | 34 | NS_DECL_THREADSAFE_ISUPPORTS |
michael@0 | 35 | NS_DECL_MOZISTORAGEASYNCSTATEMENT |
michael@0 | 36 | NS_DECL_MOZISTORAGEBASESTATEMENT |
michael@0 | 37 | NS_DECL_MOZISTORAGEBINDINGPARAMS |
michael@0 | 38 | NS_DECL_STORAGEBASESTATEMENTINTERNAL |
michael@0 | 39 | |
michael@0 | 40 | AsyncStatement(); |
michael@0 | 41 | |
michael@0 | 42 | /** |
michael@0 | 43 | * Initializes the object on aDBConnection by preparing the SQL statement |
michael@0 | 44 | * given by aSQLStatement. |
michael@0 | 45 | * |
michael@0 | 46 | * @param aDBConnection |
michael@0 | 47 | * The Connection object this statement is associated with. |
michael@0 | 48 | * @param aNativeConnection |
michael@0 | 49 | * The native Sqlite connection this statement is associated with. |
michael@0 | 50 | * @param aSQLStatement |
michael@0 | 51 | * The SQL statement to prepare that this object will represent. |
michael@0 | 52 | */ |
michael@0 | 53 | nsresult initialize(Connection *aDBConnection, |
michael@0 | 54 | sqlite3 *aNativeConnection, |
michael@0 | 55 | const nsACString &aSQLStatement); |
michael@0 | 56 | |
michael@0 | 57 | /** |
michael@0 | 58 | * Obtains and transfers ownership of the array of parameters that are bound |
michael@0 | 59 | * to this statment. This can be null. |
michael@0 | 60 | */ |
michael@0 | 61 | inline already_AddRefed<BindingParamsArray> bindingParamsArray() |
michael@0 | 62 | { |
michael@0 | 63 | return mParamsArray.forget(); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | |
michael@0 | 67 | private: |
michael@0 | 68 | ~AsyncStatement(); |
michael@0 | 69 | |
michael@0 | 70 | /** |
michael@0 | 71 | * Clean up the references JS helpers hold to us. For cycle-avoidance reasons |
michael@0 | 72 | * they do not hold reference-counted references to us, so it is important |
michael@0 | 73 | * we do this. |
michael@0 | 74 | */ |
michael@0 | 75 | void cleanupJSHelpers(); |
michael@0 | 76 | |
michael@0 | 77 | /** |
michael@0 | 78 | * @return a pointer to the BindingParams object to use with our Bind* |
michael@0 | 79 | * method. |
michael@0 | 80 | */ |
michael@0 | 81 | mozIStorageBindingParams *getParams(); |
michael@0 | 82 | |
michael@0 | 83 | /** |
michael@0 | 84 | * The SQL string as passed by the user. We store it because we create the |
michael@0 | 85 | * async statement on-demand on the async thread. |
michael@0 | 86 | */ |
michael@0 | 87 | nsCString mSQLString; |
michael@0 | 88 | |
michael@0 | 89 | /** |
michael@0 | 90 | * Holds the array of parameters to bind to this statement when we execute |
michael@0 | 91 | * it asynchronously. |
michael@0 | 92 | */ |
michael@0 | 93 | nsRefPtr<BindingParamsArray> mParamsArray; |
michael@0 | 94 | |
michael@0 | 95 | /** |
michael@0 | 96 | * Caches the JS 'params' helper for this statement. |
michael@0 | 97 | */ |
michael@0 | 98 | nsCOMPtr<nsIXPConnectJSObjectHolder> mStatementParamsHolder; |
michael@0 | 99 | |
michael@0 | 100 | /** |
michael@0 | 101 | * Have we been explicitly finalized by the user? |
michael@0 | 102 | */ |
michael@0 | 103 | bool mFinalized; |
michael@0 | 104 | |
michael@0 | 105 | /** |
michael@0 | 106 | * Required for access to private mStatementParamsHolder field by |
michael@0 | 107 | * AsyncStatementJSHelper::getParams. |
michael@0 | 108 | */ |
michael@0 | 109 | friend class AsyncStatementJSHelper; |
michael@0 | 110 | }; |
michael@0 | 111 | |
michael@0 | 112 | } // storage |
michael@0 | 113 | } // mozilla |
michael@0 | 114 | |
michael@0 | 115 | #endif // mozilla_storage_mozStorageAsyncStatement_h_ |