storage/src/mozStorageStatement.h

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 mozStorageStatement_h
     8 #define mozStorageStatement_h
    10 #include "nsAutoPtr.h"
    11 #include "nsString.h"
    13 #include "nsTArray.h"
    15 #include "mozStorageBindingParamsArray.h"
    16 #include "mozStorageStatementData.h"
    17 #include "mozIStorageStatement.h"
    18 #include "mozIStorageValueArray.h"
    19 #include "StorageBaseStatementInternal.h"
    20 #include "mozilla/Attributes.h"
    22 class nsIXPConnectJSObjectHolder;
    23 struct sqlite3_stmt;
    25 namespace mozilla {
    26 namespace storage {
    27 class StatementJSHelper;
    28 class Connection;
    30 class Statement MOZ_FINAL : public mozIStorageStatement
    31                           , public mozIStorageValueArray
    32                           , public StorageBaseStatementInternal
    33 {
    34 public:
    35   NS_DECL_THREADSAFE_ISUPPORTS
    36   NS_DECL_MOZISTORAGESTATEMENT
    37   NS_DECL_MOZISTORAGEBASESTATEMENT
    38   NS_DECL_MOZISTORAGEBINDINGPARAMS
    39   // NS_DECL_MOZISTORAGEVALUEARRAY (methods in mozIStorageStatement)
    40   NS_DECL_STORAGEBASESTATEMENTINTERNAL
    42   Statement();
    44   /**
    45    * Initializes the object on aDBConnection by preparing the SQL statement
    46    * given by aSQLStatement.
    47    *
    48    * @param aDBConnection
    49    *        The Connection object this statement is associated with.
    50    * @param aNativeConnection
    51    *        The native Sqlite connection this statement is associated with.
    52    * @param aSQLStatement
    53    *        The SQL statement to prepare that this object will represent.
    54    */
    55   nsresult initialize(Connection *aDBConnection,
    56                       sqlite3* aNativeConnection,
    57                       const nsACString &aSQLStatement);
    60   /**
    61    * Obtains the native statement pointer.
    62    */
    63   inline sqlite3_stmt *nativeStatement() { return mDBStatement; }
    65   /**
    66    * Obtains and transfers ownership of the array of parameters that are bound
    67    * to this statment.  This can be null.
    68    */
    69   inline already_AddRefed<BindingParamsArray> bindingParamsArray()
    70   {
    71     return mParamsArray.forget();
    72   }
    74 private:
    75     ~Statement();
    77     sqlite3_stmt *mDBStatement;
    78     uint32_t mParamCount;
    79     uint32_t mResultColumnCount;
    80     nsTArray<nsCString> mColumnNames;
    81     bool mExecuting;
    83     /**
    84      * @return a pointer to the BindingParams object to use with our Bind*
    85      *         method.
    86      */
    87     mozIStorageBindingParams *getParams();
    89     /**
    90      * Holds the array of parameters to bind to this statement when we execute
    91      * it asynchronously.
    92      */
    93     nsRefPtr<BindingParamsArray> mParamsArray;
    95     /**
    96      * The following two members are only used with the JS helper.  They cache
    97      * the row and params objects.
    98      */
    99     nsCOMPtr<nsIXPConnectJSObjectHolder> mStatementParamsHolder;
   100     nsCOMPtr<nsIXPConnectJSObjectHolder> mStatementRowHolder;
   102   /**
   103    * Internal version of finalize that allows us to tell it if it is being
   104    * called from the destructor so it can know not to dispatch events that
   105    * require a reference to us.
   106    *
   107    * @param aDestructing
   108    *        Is the destructor calling?
   109    */
   110   nsresult internalFinalize(bool aDestructing);
   112     friend class StatementJSHelper;
   113 };
   115 } // storage
   116 } // mozilla
   118 #endif // mozStorageStatement_h

mercurial