Bug 489702 - Update mozStorageStatement.* to follow style guidelines
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Fri, 08 May 2009 20:29:56 -0400
changeset 28144 16e1a256b772d0c618f5bbb641b79c1d7ffdc0a2
parent 28143 1d27d30234e251dd090ef5e523080929a174fd1b
child 28145 36e6791b31e8be6888aed2a5f02ddcffe53e861d
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs489702
milestone1.9.2a1pre
Bug 489702 - Update mozStorageStatement.* to follow style guidelines Consistent spacing, consistent naming, and namespaces - OH MY! r=asuth
storage/src/mozStorageArgValueArray.cpp
storage/src/mozStorageConnection.cpp
storage/src/mozStorageStatement.cpp
storage/src/mozStorageStatement.h
storage/src/mozStorageStatementJSHelper.cpp
storage/src/mozStorageStatementJSHelper.h
storage/src/mozStorageStatementParams.h
storage/src/mozStorageStatementRow.cpp
storage/src/mozStorageStatementRow.h
storage/src/mozStorageStatementWrapper.cpp
storage/src/mozStorageStatementWrapper.h
--- a/storage/src/mozStorageArgValueArray.cpp
+++ b/storage/src/mozStorageArgValueArray.cpp
@@ -166,17 +166,18 @@ ArgValueArray::GetString(PRUint32 aIndex
     _value.Assign(static_cast<const PRUnichar *>(::sqlite3_value_text16(mArgv[aIndex])),
                   ::sqlite3_value_bytes16(mArgv[aIndex]) / 2);
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 ArgValueArray::GetBlob(PRUint32 aIndex,
-                       PRUint32 *_size, PRUint8 **_blob)
+                       PRUint32 *_size,
+                       PRUint8 **_blob)
 {
   ENSURE_INDEX_VALUE(aIndex, mArgc);
 
   int size = ::sqlite3_value_bytes(mArgv[aIndex]);
   void *blob = nsMemory::Clone(::sqlite3_value_blob(mArgv[aIndex]), size);
   NS_ENSURE_TRUE(blob, NS_ERROR_OUT_OF_MEMORY);
 
   *_blob = static_cast<PRUint8 *>(blob);
--- a/storage/src/mozStorageConnection.cpp
+++ b/storage/src/mozStorageConnection.cpp
@@ -624,23 +624,23 @@ Connection::SetSchemaVersion(PRInt32 aVe
 
 NS_IMETHODIMP
 Connection::CreateStatement(const nsACString &aSQLStatement,
                             mozIStorageStatement **_stmt)
 {
   NS_ENSURE_ARG_POINTER(_stmt);
   if (!mDBConn) return NS_ERROR_NOT_INITIALIZED;
 
-  nsRefPtr<mozStorageStatement> statement(new mozStorageStatement());
+  nsRefPtr<Statement> statement(new Statement());
   NS_ENSURE_TRUE(statement, NS_ERROR_OUT_OF_MEMORY);
 
-  nsresult rv = statement->Initialize(this, aSQLStatement);
+  nsresult rv = statement->initialize(this, aSQLStatement);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  mozStorageStatement *rawPtr;
+  Statement *rawPtr;
   statement.forget(&rawPtr);
   *_stmt = rawPtr;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 Connection::ExecuteSimpleSQL(const nsACString &aSQLStatement)
 {
@@ -656,27 +656,27 @@ Connection::ExecuteAsync(mozIStorageStat
                          PRUint32 aNumStatements,
                          mozIStorageStatementCallback *aCallback,
                          mozIStoragePendingStatement **_handle)
 {
   int rc = SQLITE_OK;
   nsTArray<sqlite3_stmt *> stmts(aNumStatements);
   for (PRUint32 i = 0; i < aNumStatements && rc == SQLITE_OK; i++) {
     sqlite3_stmt *old_stmt =
-        static_cast<mozStorageStatement *>(aStatements[i])->nativeStatement();
+        static_cast<Statement *>(aStatements[i])->nativeStatement();
     if (!old_stmt) {
       rc = SQLITE_MISUSE;
       break;
     }
     NS_ASSERTION(::sqlite3_db_handle(old_stmt) == mDBConn,
                  "Statement must be from this database connection!");
 
     // Clone this statement.  We only need a sqlite3_stmt object, so we can
-    // avoid all the extra work that making a new mozStorageStatement would
-    // normally involve and use the SQLite API.
+    // avoid all the extra work that making a new Statement would normally
+    // involve and use the SQLite API.
     sqlite3_stmt *new_stmt;
     rc = ::sqlite3_prepare_v2(mDBConn, ::sqlite3_sql(old_stmt), -1, &new_stmt,
                               NULL);
     if (rc != SQLITE_OK)
       break;
 
 #ifdef PR_LOGGING
     PR_LOG(gStorageLog, PR_LOG_NOTICE,
--- a/storage/src/mozStorageStatement.cpp
+++ b/storage/src/mozStorageStatement.cpp
@@ -1,10 +1,10 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * vim: sw=4 ts=4 sts=4 expandtab
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
  * ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
@@ -36,19 +36,17 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include <stdio.h>
 
-#include "nsAutoLock.h"
 #include "nsError.h"
-#include "nsISimpleEnumerator.h"
 #include "nsMemory.h"
 #include "nsIClassInfoImpl.h"
 #include "nsIProgrammingLanguage.h"
 
 #include "mozStorageConnection.h"
 #include "mozStorageStatementJSHelper.h"
 #include "mozStoragePrivateHelpers.h"
 #include "mozStorageStatementParams.h"
@@ -56,845 +54,777 @@
 #include "mozStorageStatement.h"
 
 #include "prlog.h"
 
 #ifdef PR_LOGGING
 extern PRLogModuleInfo* gStorageLog;
 #endif
 
-using namespace mozilla::storage;
+namespace mozilla {
+namespace storage {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// nsIClassInfo
 
 NS_IMPL_CI_INTERFACE_GETTER2(
-    mozStorageStatement
-,   mozIStorageStatement
-,   mozIStorageValueArray
+  Statement,
+  mozIStorageStatement,
+  mozIStorageValueArray
 )
 
-class mozStorageStatementClassInfo : public nsIClassInfo
+class StatementClassInfo : public nsIClassInfo
 {
 public:
-    NS_DECL_ISUPPORTS
-
-    NS_IMETHODIMP
-    GetInterfaces(PRUint32 *_count, nsIID ***_array)
-    {
-        return NS_CI_INTERFACE_GETTER_NAME(mozStorageStatement)(_count, _array);
-    }
+  NS_DECL_ISUPPORTS
 
-    NS_IMETHODIMP
-    GetHelperForLanguage(PRUint32 aLanguage, nsISupports **_helper)
-    {
-        if (aLanguage == nsIProgrammingLanguage::JAVASCRIPT) {
-            static StatementJSHelper sJSHelper;
-            *_helper = &sJSHelper;
-            return NS_OK;
-        }
-
-        *_helper = nsnull;
-        return NS_OK;
-    }
+  NS_IMETHODIMP
+  GetInterfaces(PRUint32 *_count, nsIID ***_array)
+  {
+    return NS_CI_INTERFACE_GETTER_NAME(Statement)(_count, _array);
+  }
 
-    NS_IMETHODIMP
-    GetContractID(char **_contractID)
-    {
-        *_contractID = nsnull;
-        return NS_OK;
-    }
-
-    NS_IMETHODIMP
-    GetClassDescription(char **_desc)
-    {
-        *_desc = nsnull;
-        return NS_OK;
-    }
-
-    NS_IMETHODIMP
-    GetClassID(nsCID **_id)
-    {
-        *_id = nsnull;
-        return NS_OK;
-    }
-
-    NS_IMETHODIMP
-    GetImplementationLanguage(PRUint32 *_language)
-    {
-        *_language = nsIProgrammingLanguage::CPLUSPLUS;
-        return NS_OK;
+  NS_IMETHODIMP
+  GetHelperForLanguage(PRUint32 aLanguage, nsISupports **_helper)
+  {
+    if (aLanguage == nsIProgrammingLanguage::JAVASCRIPT) {
+      static StatementJSHelper sJSHelper;
+      *_helper = &sJSHelper;
+      return NS_OK;
     }
 
-    NS_IMETHODIMP
-    GetFlags(PRUint32 *_flags)
-    {
-        *_flags = nsnull;
-        return NS_OK;
-    }
+    *_helper = nsnull;
+    return NS_OK;
+  }
+
+  NS_IMETHODIMP
+  GetContractID(char **_contractID)
+  {
+    *_contractID = nsnull;
+    return NS_OK;
+  }
+
+  NS_IMETHODIMP
+  GetClassDescription(char **_desc)
+  {
+    *_desc = nsnull;
+    return NS_OK;
+  }
 
-    NS_IMETHODIMP
-    GetClassIDNoAlloc(nsCID *_cid)
-    {
-        return NS_ERROR_NOT_AVAILABLE;
-    }
+  NS_IMETHODIMP
+  GetClassID(nsCID **_id)
+  {
+    *_id = nsnull;
+    return NS_OK;
+  }
+
+  NS_IMETHODIMP
+  GetImplementationLanguage(PRUint32 *_language)
+  {
+    *_language = nsIProgrammingLanguage::CPLUSPLUS;
+    return NS_OK;
+  }
+
+  NS_IMETHODIMP
+  GetFlags(PRUint32 *_flags)
+  {
+    *_flags = nsnull;
+    return NS_OK;
+  }
+
+  NS_IMETHODIMP
+  GetClassIDNoAlloc(nsCID *_cid)
+  {
+    return NS_ERROR_NOT_AVAILABLE;
+  }
 };
 
-NS_IMETHODIMP_(nsrefcnt) mozStorageStatementClassInfo::AddRef() { return 2; }
-NS_IMETHODIMP_(nsrefcnt) mozStorageStatementClassInfo::Release() { return 1; }
-NS_IMPL_QUERY_INTERFACE1(mozStorageStatementClassInfo, nsIClassInfo)
-
-static mozStorageStatementClassInfo sStatementClassInfo;
+NS_IMETHODIMP_(nsrefcnt) StatementClassInfo::AddRef() { return 2; }
+NS_IMETHODIMP_(nsrefcnt) StatementClassInfo::Release() { return 1; }
+NS_IMPL_QUERY_INTERFACE1(StatementClassInfo, nsIClassInfo)
 
-/**
- ** mozStorageStatementRowEnumerator
- **/
-class mozStorageStatementRowEnumerator : public nsISimpleEnumerator {
-public:
-    // this expects a statement that has NOT had step called on it yet
-    mozStorageStatementRowEnumerator (sqlite3_stmt *aDBStatement);
-
-    // nsISupports interface
-    NS_DECL_ISUPPORTS
-
-    // nsISimpleEnumerator interface
-    NS_DECL_NSISIMPLEENUMERATOR
+static StatementClassInfo sStatementClassInfo;
 
-private:
-    ~mozStorageStatementRowEnumerator ();
-protected:
-    sqlite3_stmt *mDBStatement;
-    PRBool mHasMore;
-    PRBool mDidStep;
-
-    void DoRealStep();
-};
-
-
-/**
- ** mozStorageStatement
- **/
+////////////////////////////////////////////////////////////////////////////////
+//// Statement
 
-NS_IMPL_THREADSAFE_ADDREF(mozStorageStatement)
-NS_IMPL_THREADSAFE_RELEASE(mozStorageStatement)
-
-NS_INTERFACE_MAP_BEGIN(mozStorageStatement)
-    NS_INTERFACE_MAP_ENTRY(mozIStorageStatement)
-    NS_INTERFACE_MAP_ENTRY(mozIStorageValueArray)
-    if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
-        foundInterface = static_cast<nsIClassInfo *>(&sStatementClassInfo);
-    } else
-    NS_INTERFACE_MAP_ENTRY(nsISupports)
-NS_INTERFACE_MAP_END
-
-mozStorageStatement::mozStorageStatement()
-    : mDBConnection (nsnull), mDBStatement(nsnull), mColumnNames(nsnull), mExecuting(PR_FALSE)
+Statement::Statement()
+: mDBConnection(nsnull)
+, mDBStatement(NULL)
+, mColumnNames()
+, mExecuting(false)
 {
 }
 
 nsresult
-mozStorageStatement::Initialize(Connection *aDBConnection,
-                                const nsACString & aSQLStatement)
+Statement::initialize(Connection *aDBConnection,
+                      const nsACString &aSQLStatement)
 {
-    NS_ASSERTION(aDBConnection, "No database connection given!");
-    NS_ASSERTION(!mDBStatement, "Calling Initialize on an already initialized statement!");
+  NS_ASSERTION(aDBConnection, "No database connection given!");
+  NS_ASSERTION(!mDBStatement, "Statement already initialized!");
 
-    sqlite3 *db = aDBConnection->GetNativeConnection();
-    NS_ENSURE_TRUE(db != nsnull, NS_ERROR_NULL_POINTER);
+  sqlite3 *db = aDBConnection->GetNativeConnection();
+  NS_ASSERTION(db, "We should never be called with a null sqlite3 database!");
 
-    int srv = sqlite3_prepare_v2(db, PromiseFlatCString(aSQLStatement).get(),
+  int srv = ::sqlite3_prepare_v2(db, PromiseFlatCString(aSQLStatement).get(),
                                  -1, &mDBStatement, NULL);
-    if (srv != SQLITE_OK) {
+  if (srv != SQLITE_OK) {
 #ifdef PR_LOGGING
-        PR_LOG(gStorageLog, PR_LOG_ERROR, ("Sqlite statement prepare error: %d '%s'", srv, sqlite3_errmsg(db)));
-        PR_LOG(gStorageLog, PR_LOG_ERROR, ("Statement was: '%s'", nsPromiseFlatCString(aSQLStatement).get()));
+      PR_LOG(gStorageLog, PR_LOG_ERROR,
+             ("Sqlite statement prepare error: %d '%s'", srv,
+              ::sqlite3_errmsg(db)));
+      PR_LOG(gStorageLog, PR_LOG_ERROR,
+             ("Statement was: '%s'", PromiseFlatCString(aSQLStatement).get()));
 #endif
-        return NS_ERROR_FAILURE;
+      return NS_ERROR_FAILURE;
     }
 
 #ifdef PR_LOGGING
-    PR_LOG(gStorageLog, PR_LOG_NOTICE, ("Initialized statement '%s' (0x%p)",
-                                        nsPromiseFlatCString(aSQLStatement).get(),
-                                        mDBStatement));
+  PR_LOG(gStorageLog, PR_LOG_NOTICE, ("Initialized statement '%s' (0x%p)",
+                                      PromiseFlatCString(aSQLStatement).get(),
+                                      mDBStatement));
 #endif
 
-    mDBConnection = aDBConnection;
-    mParamCount = sqlite3_bind_parameter_count (mDBStatement);
-    mResultColumnCount = sqlite3_column_count (mDBStatement);
-    mColumnNames.Clear();
+  mDBConnection = aDBConnection;
+  mParamCount = ::sqlite3_bind_parameter_count(mDBStatement);
+  mResultColumnCount = ::sqlite3_column_count(mDBStatement);
+  mColumnNames.Clear();
 
-    for (PRUint32 i = 0; i < mResultColumnCount; i++) {
-        const char *name = sqlite3_column_name(mDBStatement, i);
-        mColumnNames.AppendElement(nsDependentCString(name));
-    }
+  for (PRUint32 i = 0; i < mResultColumnCount; i++) {
+      const char *name = ::sqlite3_column_name(mDBStatement, i);
+      (void)mColumnNames.AppendElement(nsDependentCString(name));
+  }
 
 #ifdef DEBUG
-    // We want to try and test for LIKE and that consumers are using
-    // escapeStringForLIKE instead of just trusting user input.  The idea to
-    // check to see if they are binding a parameter after like instead of just
-    // using a string.  We only do this in debug builds because it's expensive!
-    const nsCaseInsensitiveCStringComparator c;
-    nsACString::const_iterator start, end, e;
-    aSQLStatement.BeginReading(start);
-    aSQLStatement.EndReading(end);
-    e = end;
-    while (FindInReadable(NS_LITERAL_CSTRING(" LIKE"), start, e, c)) {
-        // We have a LIKE in here, so we perform our tests
-        // FindInReadable moves the iterator, so we have to get a new one for
-        // each test we perform.
-        nsACString::const_iterator s1, s2, s3;
-        s1 = s2 = s3 = start;
+  // We want to try and test for LIKE and that consumers are using
+  // escapeStringForLIKE instead of just trusting user input.  The idea to
+  // check to see if they are binding a parameter after like instead of just
+  // using a string.  We only do this in debug builds because it's expensive!
+  const nsCaseInsensitiveCStringComparator c;
+  nsACString::const_iterator start, end, e;
+  aSQLStatement.BeginReading(start);
+  aSQLStatement.EndReading(end);
+  e = end;
+  while (::FindInReadable(NS_LITERAL_CSTRING(" LIKE"), start, e, c)) {
+    // We have a LIKE in here, so we perform our tests
+    // FindInReadable moves the iterator, so we have to get a new one for
+    // each test we perform.
+    nsACString::const_iterator s1, s2, s3;
+    s1 = s2 = s3 = start;
 
-        if (!(FindInReadable(NS_LITERAL_CSTRING(" LIKE ?"), s1, end, c) ||
-              FindInReadable(NS_LITERAL_CSTRING(" LIKE :"), s2, end, c) ||
-              FindInReadable(NS_LITERAL_CSTRING(" LIKE @"), s3, end, c))) {
-            // At this point, we didn't find a LIKE statement followed by ?, :,
-            // or @, all of which are valid characters for binding a parameter.
-            // We will warn the consumer that they may not be safely using LIKE.
-            NS_WARNING("Unsafe use of LIKE detected!  Please ensure that you "
-                       "are using mozIStorageConnection::escapeStringForLIKE "
-                       "and that you are binding that result to the statement "
-                       "to prevent SQL injection attacks.");
-        }
+    if (!(::FindInReadable(NS_LITERAL_CSTRING(" LIKE ?"), s1, end, c) ||
+          ::FindInReadable(NS_LITERAL_CSTRING(" LIKE :"), s2, end, c) ||
+          ::FindInReadable(NS_LITERAL_CSTRING(" LIKE @"), s3, end, c))) {
+      // At this point, we didn't find a LIKE statement followed by ?, :,
+      // or @, all of which are valid characters for binding a parameter.
+      // We will warn the consumer that they may not be safely using LIKE.
+      NS_WARNING("Unsafe use of LIKE detected!  Please ensure that you "
+                 "are using mozIStorageConnection::escapeStringForLIKE "
+                 "and that you are binding that result to the statement "
+                 "to prevent SQL injection attacks.");
+    }
 
-        // resetting start and e
-        start = e;
-        e = end;
-    }
+    // resetting start and e
+    start = e;
+    e = end;
+  }
 #endif
 
-    return NS_OK;
+  return NS_OK;
+}
+
+Statement::~Statement()
+{
+  (void)Finalize();
 }
 
-mozStorageStatement::~mozStorageStatement()
-{
-    (void)Finalize();
-}
+NS_IMPL_THREADSAFE_ADDREF(Statement)
+NS_IMPL_THREADSAFE_RELEASE(Statement)
+
+NS_INTERFACE_MAP_BEGIN(Statement)
+  NS_INTERFACE_MAP_ENTRY(mozIStorageStatement)
+  NS_INTERFACE_MAP_ENTRY(mozIStorageValueArray)
+  if (aIID.Equals(NS_GET_IID(nsIClassInfo))) {
+    foundInterface = static_cast<nsIClassInfo *>(&sStatementClassInfo);
+  }
+  else
+  NS_INTERFACE_MAP_ENTRY(nsISupports)
+NS_INTERFACE_MAP_END
 
 ////////////////////////////////////////////////////////////////////////////////
 //// mozIStorageStatement
 
-/* mozIStorageStatement clone (); */
 NS_IMETHODIMP
-mozStorageStatement::Clone(mozIStorageStatement **_retval)
+Statement::Clone(mozIStorageStatement **_statement)
 {
-    mozStorageStatement *mss = new mozStorageStatement();
-    if (!mss)
-      return NS_ERROR_OUT_OF_MEMORY;
+  nsRefPtr<Statement> statement(new Statement());
+  NS_ENSURE_TRUE(statement, NS_ERROR_OUT_OF_MEMORY);
 
-    nsCAutoString sql(sqlite3_sql(mDBStatement));
-    nsresult rv = mss->Initialize (mDBConnection, sql);
-    NS_ENSURE_SUCCESS(rv, rv);
+  nsCAutoString sql(::sqlite3_sql(mDBStatement));
+  nsresult rv = statement->initialize(mDBConnection, sql);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    NS_ADDREF(*_retval = mss);
-    return NS_OK;
+  statement.forget(_statement);
+  return NS_OK;
 }
 
-/* void finalize(); */
 NS_IMETHODIMP
-mozStorageStatement::Finalize()
+Statement::Finalize()
 {
-    if (!mDBStatement)
-        return NS_OK;
+  if (!mDBStatement)
+    return NS_OK;
 
 #ifdef PR_LOGGING
-    PR_LOG(gStorageLog, PR_LOG_NOTICE, ("Finalizing statement '%s'",
-                                        sqlite3_sql(mDBStatement)));
+  PR_LOG(gStorageLog, PR_LOG_NOTICE, ("Finalizing statement '%s'",
+                                      ::sqlite3_sql(mDBStatement)));
 #endif
 
-    int srv = sqlite3_finalize(mDBStatement);
-    mDBStatement = NULL;
+  int srv = ::sqlite3_finalize(mDBStatement);
+  mDBStatement = NULL;
 
-    // We are considered dead at this point, so any wrappers for row or params
-    // need to lose their reference to us.
-    if (mStatementParamsHolder) {
-        nsCOMPtr<nsIXPConnectWrappedNative> wrapper =
-            do_QueryInterface(mStatementParamsHolder);
-        nsCOMPtr<mozIStorageStatementParams> iParams =
-            do_QueryWrappedNative(wrapper);
-        StatementParams *params = static_cast<StatementParams *>(iParams.get());
-        params->mStatement = nsnull;
-        mStatementParamsHolder = nsnull;
-    }
+  // We are considered dead at this point, so any wrappers for row or params
+  // need to lose their reference to us.
+  if (mStatementParamsHolder) {
+    nsCOMPtr<nsIXPConnectWrappedNative> wrapper =
+        do_QueryInterface(mStatementParamsHolder);
+    nsCOMPtr<mozIStorageStatementParams> iParams =
+        do_QueryWrappedNative(wrapper);
+    StatementParams *params = static_cast<StatementParams *>(iParams.get());
+    params->mStatement = nsnull;
+    mStatementParamsHolder = nsnull;
+  }
 
-    if (mStatementRowHolder) {
-        nsCOMPtr<nsIXPConnectWrappedNative> wrapper =
-            do_QueryInterface(mStatementRowHolder);
-        nsCOMPtr<mozIStorageStatementRow> iRow =
-            do_QueryWrappedNative(wrapper);
-        StatementRow *row = static_cast<StatementRow *>(iRow.get());
-        row->mStatement = nsnull;
-        mStatementRowHolder = nsnull;
-    }
+  if (mStatementRowHolder) {
+    nsCOMPtr<nsIXPConnectWrappedNative> wrapper =
+        do_QueryInterface(mStatementRowHolder);
+    nsCOMPtr<mozIStorageStatementRow> iRow =
+        do_QueryWrappedNative(wrapper);
+    StatementRow *row = static_cast<StatementRow *>(iRow.get());
+    row->mStatement = nsnull;
+    mStatementRowHolder = nsnull;
+  }
 
-    return convertResultCode(srv);
+  return convertResultCode(srv);
 }
 
-/* readonly attribute unsigned long parameterCount; */
 NS_IMETHODIMP
-mozStorageStatement::GetParameterCount(PRUint32 *aParameterCount)
+Statement::GetParameterCount(PRUint32 *_parameterCount)
 {
-    NS_ENSURE_ARG_POINTER(aParameterCount);
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
-
-    *aParameterCount = mParamCount;
-    return NS_OK;
+  *_parameterCount = mParamCount;
+  return NS_OK;
 }
 
-/* AUTF8String getParameterName(in unsigned long aParamIndex); */
 NS_IMETHODIMP
-mozStorageStatement::GetParameterName(PRUint32 aParamIndex, nsACString & _retval)
+Statement::GetParameterName(PRUint32 aParamIndex,
+                            nsACString &_name)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
+  ENSURE_INDEX_VALUE(aParamIndex, mParamCount);
 
-    // We have to check this index because sqlite3_bind_parameter_name returns
-    // NULL if an error occurs, or if a column is unnamed.  Since we handle
-    // unnamed columns, we won't be able to tell if it is an error not without
-    // checking ourselves.
-    if (aParamIndex < 0 || aParamIndex >= mParamCount)
-        return NS_ERROR_ILLEGAL_VALUE;
+  const char *name = ::sqlite3_bind_parameter_name(mDBStatement,
+                                                   aParamIndex + 1);
+  if (name == NULL) {
+    // this thing had no name, so fake one
+    nsCAutoString name(":");
+    name.AppendInt(aParamIndex);
+    _name.Assign(name);
+  }
+  else {
+    _name.Assign(nsDependentCString(name));
+  }
 
-    const char *pname = sqlite3_bind_parameter_name(mDBStatement, aParamIndex + 1);
-    if (pname == NULL) {
-        // this thing had no name, so fake one
-        nsCAutoString pname(":");
-        pname.AppendInt(aParamIndex);
-        _retval.Assign(pname);
-    } else {
-        _retval.Assign(nsDependentCString(pname));
-    }
-
-    return NS_OK;
+  return NS_OK;
 }
 
-/* unsigned long getParameterIndex(in AUTF8String aParameterName); */
 NS_IMETHODIMP
-mozStorageStatement::GetParameterIndex(const nsACString &aName,
-                                       PRUint32 *_retval)
+Statement::GetParameterIndex(const nsACString &aName,
+                             PRUint32 *_index)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    int ind = sqlite3_bind_parameter_index(mDBStatement,
-                                           nsPromiseFlatCString(aName).get());
-    if (ind  == 0) // Named parameter not found
-        return NS_ERROR_INVALID_ARG;
-    
-    *_retval = ind - 1; // SQLite indexes are 1-based, we are 0-based
+  int ind = ::sqlite3_bind_parameter_index(mDBStatement,
+                                           PromiseFlatCString(aName).get());
+  if (ind  == 0) // Named parameter not found.
+    return NS_ERROR_INVALID_ARG;
 
-    return NS_OK;
+  *_index = ind - 1; // SQLite indexes are 1-based, we are 0-based.
+
+  return NS_OK;
 }
 
-/* readonly attribute unsigned long columnCount; */
 NS_IMETHODIMP
-mozStorageStatement::GetColumnCount(PRUint32 *aColumnCount)
+Statement::GetColumnCount(PRUint32 *_columnCount)
 {
-    NS_ENSURE_ARG_POINTER(aColumnCount);
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
-
-    *aColumnCount = mResultColumnCount;
-    return NS_OK;
+  *_columnCount = mResultColumnCount;
+  return NS_OK;
 }
 
-/* AUTF8String getColumnName(in unsigned long aColumnIndex); */
 NS_IMETHODIMP
-mozStorageStatement::GetColumnName(PRUint32 aColumnIndex, nsACString & _retval)
+Statement::GetColumnName(PRUint32 aColumnIndex,
+                         nsACString &_name)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
+  ENSURE_INDEX_VALUE(aColumnIndex, mResultColumnCount);
 
-    // We have to check this index because sqlite3_column_name returns
-    // NULL if an error occurs, or if a column is unnamed.
-    if (aColumnIndex < 0 || aColumnIndex >= mResultColumnCount)
-        return NS_ERROR_ILLEGAL_VALUE;
+  const char *cname = ::sqlite3_column_name(mDBStatement, aColumnIndex);
+  _name.Assign(nsDependentCString(cname));
 
-    const char *cname = sqlite3_column_name(mDBStatement, aColumnIndex);
-    _retval.Assign(nsDependentCString(cname));
-
-    return NS_OK;
+  return NS_OK;
 }
 
-/* unsigned long getColumnIndex(in AUTF8String aName); */
 NS_IMETHODIMP
-mozStorageStatement::GetColumnIndex(const nsACString &aName, PRUint32 *_retval)
+Statement::GetColumnIndex(const nsACString &aName,
+                          PRUint32 *_index)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+      return NS_ERROR_NOT_INITIALIZED;
 
-    // Surprisingly enough, SQLite doesn't provide an API for this.  We have to
-    // determine it ourselves sadly.
-    for (PRUint32 i = 0; i < mResultColumnCount; i++) {
-        if (mColumnNames[i].Equals(aName)) {
-            *_retval = i;
-            return NS_OK;
-        }
+  // Surprisingly enough, SQLite doesn't provide an API for this.  We have to
+  // determine it ourselves sadly.
+  for (PRUint32 i = 0; i < mResultColumnCount; i++) {
+    if (mColumnNames[i].Equals(aName)) {
+      *_index = i;
+      return NS_OK;
     }
+  }
 
-    return NS_ERROR_INVALID_ARG;
+  return NS_ERROR_INVALID_ARG;
 }
 
-/* void reset (); */
 NS_IMETHODIMP
-mozStorageStatement::Reset()
+Statement::Reset()
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
 #ifdef DEBUG
-    PR_LOG(gStorageLog, PR_LOG_DEBUG, ("Resetting statement: '%s'",
-                                       sqlite3_sql(mDBStatement)));
+  PR_LOG(gStorageLog, PR_LOG_DEBUG, ("Resetting statement: '%s'",
+                                     ::sqlite3_sql(mDBStatement)));
 
-    checkAndLogStatementPerformance(mDBStatement);
+  checkAndLogStatementPerformance(mDBStatement);
 #endif
 
-    sqlite3_reset(mDBStatement);
-    sqlite3_clear_bindings(mDBStatement);
+  (void)sqlite3_reset(mDBStatement);
+  (void)sqlite3_clear_bindings(mDBStatement);
 
-    mExecuting = PR_FALSE;
+  mExecuting = false;
 
-    return NS_OK;
+  return NS_OK;
 }
 
-/* void bindUTF8StringParameter (in unsigned long aParamIndex, in AUTF8String aValue); */
 NS_IMETHODIMP
-mozStorageStatement::BindUTF8StringParameter(PRUint32 aParamIndex, const nsACString & aValue)
+Statement::BindUTF8StringParameter(PRUint32 aParamIndex,
+                                   const nsACString &aValue)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    int srv = sqlite3_bind_text (mDBStatement, aParamIndex + 1,
-                                 nsPromiseFlatCString(aValue).get(),
-                                 aValue.Length(), SQLITE_TRANSIENT);
-
-    return convertResultCode(srv);
+  int srv = ::sqlite3_bind_text(mDBStatement, aParamIndex + 1,
+                                PromiseFlatCString(aValue).get(),
+                                aValue.Length(), SQLITE_TRANSIENT);
+  return convertResultCode(srv);
 }
 
-/* void bindStringParameter (in unsigned long aParamIndex, in AString aValue); */
 NS_IMETHODIMP
-mozStorageStatement::BindStringParameter(PRUint32 aParamIndex, const nsAString & aValue)
+Statement::BindStringParameter(PRUint32 aParamIndex,
+                               const nsAString &aValue)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    int srv = sqlite3_bind_text16 (mDBStatement, aParamIndex + 1,
-                                   nsPromiseFlatString(aValue).get(),
-                                   aValue.Length() * 2, SQLITE_TRANSIENT);
-
-    return convertResultCode(srv);
+  int srv = ::sqlite3_bind_text16(mDBStatement, aParamIndex + 1,
+                                  PromiseFlatString(aValue).get(),
+                                  aValue.Length() * 2, SQLITE_TRANSIENT);
+  return convertResultCode(srv);
 }
 
-/* void bindDoubleParameter (in unsigned long aParamIndex, in double aValue); */
 NS_IMETHODIMP
-mozStorageStatement::BindDoubleParameter(PRUint32 aParamIndex, double aValue)
+Statement::BindDoubleParameter(PRUint32 aParamIndex,
+                               double aValue)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    int srv = sqlite3_bind_double (mDBStatement, aParamIndex + 1, aValue);
-
-    return convertResultCode(srv);
+  int srv = ::sqlite3_bind_double(mDBStatement, aParamIndex + 1, aValue);
+  return convertResultCode(srv);
 }
 
-/* void bindInt32Parameter (in unsigned long aParamIndex, in long aValue); */
 NS_IMETHODIMP
-mozStorageStatement::BindInt32Parameter(PRUint32 aParamIndex, PRInt32 aValue)
+Statement::BindInt32Parameter(PRUint32 aParamIndex,
+                              PRInt32 aValue)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    int srv = sqlite3_bind_int (mDBStatement, aParamIndex + 1, aValue);
-
-    return convertResultCode(srv);
+  int srv = ::sqlite3_bind_int(mDBStatement, aParamIndex + 1, aValue);
+  return convertResultCode(srv);
 }
 
-/* void bindInt64Parameter (in unsigned long aParamIndex, in long long aValue); */
 NS_IMETHODIMP
-mozStorageStatement::BindInt64Parameter(PRUint32 aParamIndex, PRInt64 aValue)
+Statement::BindInt64Parameter(PRUint32 aParamIndex,
+                              PRInt64 aValue)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    int srv = sqlite3_bind_int64 (mDBStatement, aParamIndex + 1, aValue);
-
-    return convertResultCode(srv);
+  int srv = ::sqlite3_bind_int64(mDBStatement, aParamIndex + 1, aValue);
+  return convertResultCode(srv);
 }
 
-/* void bindNullParameter (in unsigned long aParamIndex); */
 NS_IMETHODIMP
-mozStorageStatement::BindNullParameter(PRUint32 aParamIndex)
+Statement::BindNullParameter(PRUint32 aParamIndex)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    int srv = sqlite3_bind_null (mDBStatement, aParamIndex + 1);
-
-    return convertResultCode(srv);
+  int srv = ::sqlite3_bind_null(mDBStatement, aParamIndex + 1);
+  return convertResultCode(srv);
 }
 
-/* void bindBlobParameter (in unsigned long aParamIndex, [array, const, size_is (aValueSize)] in octet aValue, in unsigned long aValueSize); */
 NS_IMETHODIMP
-mozStorageStatement::BindBlobParameter(PRUint32 aParamIndex, const PRUint8 *aValue, PRUint32 aValueSize)
+Statement::BindBlobParameter(PRUint32 aParamIndex,
+                             const PRUint8 *aValue,
+                             PRUint32 aValueSize)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    int srv = sqlite3_bind_blob (mDBStatement, aParamIndex + 1, aValue,
-                                 aValueSize, SQLITE_TRANSIENT);
-
-    return convertResultCode(srv);
+  int srv = ::sqlite3_bind_blob(mDBStatement, aParamIndex + 1, aValue,
+                                aValueSize, SQLITE_TRANSIENT);
+  return convertResultCode(srv);
 }
 
-/* void execute (); */
 NS_IMETHODIMP
-mozStorageStatement::Execute()
+Statement::Execute()
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    PRBool ret;
-    nsresult rv = ExecuteStep(&ret);
-    NS_ENSURE_SUCCESS(rv, rv);
+  PRBool ret;
+  nsresult rv = ExecuteStep(&ret);
+  NS_ENSURE_SUCCESS(rv, rv);
 
-    return Reset();
+  return Reset();
 }
 
-/* boolean executeStep (); */
 NS_IMETHODIMP
-mozStorageStatement::ExecuteStep(PRBool *_retval)
+Statement::ExecuteStep(PRBool *_moreResults)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    int srv = sqlite3_step (mDBStatement);
+  int srv = ::sqlite3_step(mDBStatement);
 
 #ifdef PR_LOGGING
-    if (srv != SQLITE_ROW && srv != SQLITE_DONE)
-    {
-        nsCAutoString errStr;
-        mDBConnection->GetLastErrorString(errStr);
-        PR_LOG(gStorageLog, PR_LOG_DEBUG, ("mozStorageStatement::ExecuteStep error: %s", errStr.get()));
-    }
+  if (srv != SQLITE_ROW && srv != SQLITE_DONE) {
+      nsCAutoString errStr;
+      (void)mDBConnection->GetLastErrorString(errStr);
+      PR_LOG(gStorageLog, PR_LOG_DEBUG,
+             ("Statement::ExecuteStep error: %s", errStr.get()));
+  }
 #endif
 
-    // SQLITE_ROW and SQLITE_DONE are non-errors
-    if (srv == SQLITE_ROW) {
-        // we got a row back
-        mExecuting = PR_TRUE;
-        *_retval = PR_TRUE;
-        return NS_OK;
-    } else if (srv == SQLITE_DONE) {
-        // statement is done (no row returned)
-        mExecuting = PR_FALSE;
-        *_retval = PR_FALSE;
-        return NS_OK;
-    } else if (srv == SQLITE_BUSY || srv == SQLITE_MISUSE) {
-        mExecuting = PR_FALSE;
-    } else if (mExecuting == PR_TRUE) {
+  // SQLITE_ROW and SQLITE_DONE are non-errors
+  if (srv == SQLITE_ROW) {
+    // we got a row back
+    mExecuting = true;
+    *_moreResults = PR_TRUE;
+    return NS_OK;
+  }
+  else if (srv == SQLITE_DONE) {
+    // statement is done (no row returned)
+    mExecuting = false;
+    *_moreResults = PR_FALSE;
+    return NS_OK;
+  }
+  else if (srv == SQLITE_BUSY || srv == SQLITE_MISUSE) {
+    mExecuting = PR_FALSE;
+  }
+  else if (mExecuting) {
 #ifdef PR_LOGGING
-        PR_LOG(gStorageLog, PR_LOG_ERROR, ("SQLite error after mExecuting was true!"));
+    PR_LOG(gStorageLog, PR_LOG_ERROR,
+           ("SQLite error after mExecuting was true!"));
 #endif
-        mExecuting = PR_FALSE;
-    }
+    mExecuting = PR_FALSE;
+  }
 
-    return convertResultCode(srv);
+  return convertResultCode(srv);
 }
 
-/* nsICancelable executeAsync([optional] in storageIStatementCallback aCallback); */
 nsresult
-mozStorageStatement::ExecuteAsync(mozIStorageStatementCallback *aCallback,
-                                  mozIStoragePendingStatement **_stmt)
+Statement::ExecuteAsync(mozIStorageStatementCallback *aCallback,
+                        mozIStoragePendingStatement **_stmt)
 {
-    mozIStorageStatement * stmts[1] = {this};
-    return mDBConnection->ExecuteAsync(stmts, 1, aCallback, _stmt);
+  mozIStorageStatement *stmts[1] = {this};
+  return mDBConnection->ExecuteAsync(stmts, 1, aCallback, _stmt);
 }
 
-/* readonly attribute long state; */
 NS_IMETHODIMP
-mozStorageStatement::GetState(PRInt32 *_retval)
+Statement::GetState(PRInt32 *_state)
 {
-    if (!mDBStatement) {
-        *_retval = MOZ_STORAGE_STATEMENT_INVALID;
-    } else if (mExecuting) {
-        *_retval = MOZ_STORAGE_STATEMENT_EXECUTING;
-    } else {
-        *_retval = MOZ_STORAGE_STATEMENT_READY;
-    }
+  if (!mDBStatement)
+    *_state = MOZ_STORAGE_STATEMENT_INVALID;
+  else if (mExecuting)
+    *_state = MOZ_STORAGE_STATEMENT_EXECUTING;
+  else
+    *_state = MOZ_STORAGE_STATEMENT_READY;
 
-    return NS_OK;
+  return NS_OK;
 }
 
-/***
- *** mozIStorageValueArray
- ***/
+NS_IMETHODIMP
+Statement::EscapeStringForLIKE(const nsAString &aValue,
+                               const PRUnichar aEscapeChar,
+                               nsAString &_escapedString)
+{
+  const PRUnichar MATCH_ALL('%');
+  const PRUnichar MATCH_ONE('_');
 
-/* readonly attribute unsigned long numEntries; */
-NS_IMETHODIMP
-mozStorageStatement::GetNumEntries(PRUint32 *aLength)
-{
-    *aLength = mResultColumnCount;
-    return NS_OK;
+  _escapedString.Truncate(0);
+
+  for (PRInt32 i = 0; i < aValue.Length(); i++) {
+    if (aValue[i] == aEscapeChar || aValue[i] == MATCH_ALL ||
+        aValue[i] == MATCH_ONE)
+      _escapedString += aEscapeChar;
+    _escapedString += aValue[i];
+  }
+  return NS_OK;
 }
 
-/* long getTypeOfIndex (in unsigned long aIndex); */
 NS_IMETHODIMP
-mozStorageStatement::GetTypeOfIndex(PRUint32 aIndex, PRInt32 *_retval)
+Statement::GetColumnDecltype(PRUint32 aParamIndex,
+                             nsACString &_declType)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    if (aIndex < 0 || aIndex >= mResultColumnCount)
-        return NS_ERROR_ILLEGAL_VALUE;
-
-    if (!mExecuting)
-        return NS_ERROR_UNEXPECTED;
+  ENSURE_INDEX_VALUE(aParamIndex, mResultColumnCount);
 
-    int t = sqlite3_column_type (mDBStatement, aIndex);
-    switch (t) {
-        case SQLITE_INTEGER:
-            *_retval = VALUE_TYPE_INTEGER;
-            break;
-        case SQLITE_FLOAT:
-            *_retval = VALUE_TYPE_FLOAT;
-            break;
-        case SQLITE_TEXT:
-            *_retval = VALUE_TYPE_TEXT;
-            break;
-        case SQLITE_BLOB:
-            *_retval = VALUE_TYPE_BLOB;
-            break;
-        case SQLITE_NULL:
-            *_retval = VALUE_TYPE_NULL;
-            break;
-        default:
-            // ???
-            return NS_ERROR_FAILURE;
-    }
+  _declType.Assign(::sqlite3_column_decltype(mDBStatement, aParamIndex));
+  return NS_OK;
+}
 
-    return NS_OK;
+////////////////////////////////////////////////////////////////////////////////
+//// mozIStorageValueArray
+
+NS_IMETHODIMP
+Statement::GetNumEntries(PRUint32 *_length)
+{
+  *_length = mResultColumnCount;
+  return NS_OK;
 }
 
-/* long getInt32 (in unsigned long aIndex); */
 NS_IMETHODIMP
-mozStorageStatement::GetInt32(PRUint32 aIndex, PRInt32 *_retval)
+Statement::GetTypeOfIndex(PRUint32 aIndex,
+                          PRInt32 *_type)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
+
+  ENSURE_INDEX_VALUE(aIndex, mResultColumnCount);
+
+  if (!mExecuting)
+    return NS_ERROR_UNEXPECTED;
 
-    if (aIndex < 0 || aIndex >= mResultColumnCount)
-        return NS_ERROR_ILLEGAL_VALUE;
-    
-    if (!mExecuting)
-        return NS_ERROR_UNEXPECTED;
+  int t = ::sqlite3_column_type(mDBStatement, aIndex);
+  switch (t) {
+    case SQLITE_INTEGER:
+      *_type = VALUE_TYPE_INTEGER;
+      break;
+    case SQLITE_FLOAT:
+      *_type = VALUE_TYPE_FLOAT;
+      break;
+    case SQLITE_TEXT:
+      *_type = VALUE_TYPE_TEXT;
+      break;
+    case SQLITE_BLOB:
+      *_type = VALUE_TYPE_BLOB;
+      break;
+    case SQLITE_NULL:
+      *_type = VALUE_TYPE_NULL;
+      break;
+    default:
+      return NS_ERROR_FAILURE;
+  }
 
-    *_retval = sqlite3_column_int (mDBStatement, aIndex);
-
-    return NS_OK;
+  return NS_OK;
 }
 
-/* long long getInt64 (in unsigned long aIndex); */
 NS_IMETHODIMP
-mozStorageStatement::GetInt64(PRUint32 aIndex, PRInt64 *_retval)
+Statement::GetInt32(PRUint32 aIndex,
+                    PRInt32 *_value)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
-
-    if (aIndex < 0 || aIndex >= mResultColumnCount)
-        return NS_ERROR_ILLEGAL_VALUE;
-    
-    if (!mExecuting)
-        return NS_ERROR_UNEXPECTED;
-
-    *_retval = sqlite3_column_int64 (mDBStatement, aIndex);
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    return NS_OK;
-}
-
-/* double getDouble (in unsigned long aIndex); */
-NS_IMETHODIMP
-mozStorageStatement::GetDouble(PRUint32 aIndex, double *_retval)
-{
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  ENSURE_INDEX_VALUE(aIndex, mResultColumnCount);
 
-    if (aIndex < 0 || aIndex >= mResultColumnCount)
-        return NS_ERROR_ILLEGAL_VALUE;
-    
-    if (!mExecuting)
-        return NS_ERROR_UNEXPECTED;
+  if (!mExecuting)
+    return NS_ERROR_UNEXPECTED;
 
-    *_retval = sqlite3_column_double (mDBStatement, aIndex);
-
-    return NS_OK;
+  *_value = ::sqlite3_column_int(mDBStatement, aIndex);
+  return NS_OK;
 }
 
-/* AUTF8String getUTF8String (in unsigned long aIndex); */
 NS_IMETHODIMP
-mozStorageStatement::GetUTF8String(PRUint32 aIndex, nsACString & _retval)
+Statement::GetInt64(PRUint32 aIndex,
+                    PRInt64 *_value)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    // Get type of Index will check aIndex for us, so we don't have to.
-    PRInt32 t;
-    nsresult rv = GetTypeOfIndex (aIndex, &t);
-    NS_ENSURE_SUCCESS(rv, rv);
-    if (t == VALUE_TYPE_NULL) {
-        // null columns get IsVoid set to distinguish them from empty strings
-        _retval.Truncate(0);
-        _retval.SetIsVoid(PR_TRUE);
-    } else {
-        int slen = sqlite3_column_bytes (mDBStatement, aIndex);
-        const unsigned char *cstr = sqlite3_column_text (mDBStatement, aIndex);
-        _retval.Assign ((char *) cstr, slen);
-    }
-    return NS_OK;
+  ENSURE_INDEX_VALUE(aIndex, mResultColumnCount);
+
+  if (!mExecuting)
+    return NS_ERROR_UNEXPECTED;
+
+  *_value = ::sqlite3_column_int64(mDBStatement, aIndex);
+
+  return NS_OK;
 }
 
-/* AString getString (in unsigned long aIndex); */
 NS_IMETHODIMP
-mozStorageStatement::GetString(PRUint32 aIndex, nsAString & _retval)
+Statement::GetDouble(PRUint32 aIndex,
+                     double *_value)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
 
-    // Get type of Index will check aIndex for us, so we don't have to.
-    PRInt32 t;
-    nsresult rv = GetTypeOfIndex (aIndex, &t);
-    NS_ENSURE_SUCCESS(rv, rv);
-    if (t == VALUE_TYPE_NULL) {
-        // null columns get IsVoid set to distinguish them from empty strings
-        _retval.Truncate(0);
-        _retval.SetIsVoid(PR_TRUE);
-    } else {
-        int slen = sqlite3_column_bytes16 (mDBStatement, aIndex);
-        const void *text = sqlite3_column_text16 (mDBStatement, aIndex);
-        const PRUnichar *wstr = static_cast<const PRUnichar *>(text);
-        _retval.Assign (wstr, slen/2);
-    }
-    return NS_OK;
+  ENSURE_INDEX_VALUE(aIndex, mResultColumnCount);
+
+  if (!mExecuting)
+    return NS_ERROR_UNEXPECTED;
+
+  *_value = ::sqlite3_column_double(mDBStatement, aIndex);
+
+  return NS_OK;
 }
 
-/* void getBlob (in unsigned long aIndex, out unsigned long aDataSize, [array, size_is (aDataSize)] out octet aData); */
 NS_IMETHODIMP
-mozStorageStatement::GetBlob(PRUint32 aIndex, PRUint32 *aDataSize, PRUint8 **aData)
+Statement::GetUTF8String(PRUint32 aIndex,
+                         nsACString &_value)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
-
-    if (aIndex < 0 || aIndex >= mResultColumnCount)
-        return NS_ERROR_ILLEGAL_VALUE;
-    
-    if (!mExecuting)
-        return NS_ERROR_UNEXPECTED;
-
-    int blobsize = sqlite3_column_bytes (mDBStatement, aIndex);
-    if (blobsize == 0) {
-      // empty column
-      *aData = nsnull;
-      *aDataSize = 0;
-      return NS_OK;
-    }
-    const void *blob = sqlite3_column_blob (mDBStatement, aIndex);
-
-    void *blobcopy = nsMemory::Clone(blob, blobsize);
-    if (blobcopy == NULL)
-        return NS_ERROR_OUT_OF_MEMORY;
-
-    *aData = (PRUint8*) blobcopy;
-    *aDataSize = blobsize;
-
-    return NS_OK;
+  // Get type of Index will check aIndex for us, so we don't have to.
+  PRInt32 type;
+  nsresult rv = GetTypeOfIndex(aIndex, &type);
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (type == VALUE_TYPE_NULL) {
+    // NULL columns should have IsVod set to distinguis them from an empty
+    // string.
+    _value.Truncate(0);
+    _value.SetIsVoid(PR_TRUE);
+  }
+  else {
+    const char *value =
+      reinterpret_cast<const char *>(::sqlite3_column_text(mDBStatement,
+                                                           aIndex));
+    _value.Assign(value, ::sqlite3_column_bytes(mDBStatement, aIndex));
+  }
+  return NS_OK;
 }
 
-/* [noscript] void getSharedUTF8String(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out string aResult); */
 NS_IMETHODIMP
-mozStorageStatement::GetSharedUTF8String(PRUint32 aIndex, PRUint32 *aLength, const char **_retval)
+Statement::GetString(PRUint32 aIndex,
+                     nsAString &_value)
 {
-    if (aLength) {
-        int slen = sqlite3_column_bytes (mDBStatement, aIndex);
-        *aLength = slen;
-    }
-
-    *_retval = (const char *) sqlite3_column_text (mDBStatement, aIndex);
-    return NS_OK;
+  // Get type of Index will check aIndex for us, so we don't have to.
+  PRInt32 type;
+  nsresult rv = GetTypeOfIndex(aIndex, &type);
+  NS_ENSURE_SUCCESS(rv, rv);
+  if (type == VALUE_TYPE_NULL) {
+    // NULL columns should have IsVod set to distinguis them from an empty
+    // string.
+    _value.Truncate(0);
+    _value.SetIsVoid(PR_TRUE);
+  } else {
+    const PRUnichar *value =
+      static_cast<const PRUnichar *>(::sqlite3_column_text16(mDBStatement,
+                                                             aIndex));
+    _value.Assign(value, ::sqlite3_column_bytes16(mDBStatement, aIndex) / 2);
+  }
+  return NS_OK;
 }
 
-/* [noscript] void getSharedString(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out wstring aResult); */
 NS_IMETHODIMP
-mozStorageStatement::GetSharedString(PRUint32 aIndex, PRUint32 *aLength, const PRUnichar **_retval)
+Statement::GetBlob(PRUint32 aIndex,
+                   PRUint32 *_size,
+                   PRUint8 **_blob)
 {
-    if (aLength) {
-        int slen = sqlite3_column_bytes16 (mDBStatement, aIndex);
-        *aLength = slen;
-    }
+  if (!mDBStatement)
+    return NS_ERROR_NOT_INITIALIZED;
+
+  ENSURE_INDEX_VALUE(aIndex, mResultColumnCount);
 
-    *_retval = (const PRUnichar *) sqlite3_column_text16 (mDBStatement, aIndex);
-    return NS_OK;
-}
+  if (!mExecuting)
+     return NS_ERROR_UNEXPECTED;
 
-/* [noscript] void getSharedBlob(in unsigned long aIndex, out unsigned long aLength, [shared,retval] out octetPtr aResult); */
-NS_IMETHODIMP
-mozStorageStatement::GetSharedBlob(PRUint32 aIndex, PRUint32 *aDataSize, const PRUint8 **aData)
-{
-    *aDataSize = sqlite3_column_bytes (mDBStatement, aIndex);
-    *aData = (const PRUint8*) sqlite3_column_blob (mDBStatement, aIndex);
+  int size = ::sqlite3_column_bytes(mDBStatement, aIndex);
+  void *blob = nsnull;
+  if (size) {
+    blob = nsMemory::Clone(::sqlite3_column_blob(mDBStatement, aIndex), size);
+    NS_ENSURE_TRUE(blob, NS_ERROR_OUT_OF_MEMORY);
+  }
 
-    return NS_OK;
+  *_blob = static_cast<PRUint8 *>(blob);
+  *_size = size;
+  return NS_OK;
 }
 
-/* boolean getIsNull (in unsigned long aIndex); */
 NS_IMETHODIMP
-mozStorageStatement::GetIsNull(PRUint32 aIndex, PRBool *_retval)
+Statement::GetSharedUTF8String(PRUint32 aIndex,
+                               PRUint32 *_length,
+                               const char **_value)
 {
-    // Get type of Index will check aIndex for us, so we don't have to.
-    PRInt32 t;
-    nsresult rv = GetTypeOfIndex (aIndex, &t);
-    NS_ENSURE_SUCCESS(rv, rv);
+  if (_length)
+    *_length = ::sqlite3_column_bytes(mDBStatement, aIndex);
+
+  *_value = reinterpret_cast<const char *>(::sqlite3_column_text(mDBStatement,
+                                                                 aIndex));
+  return NS_OK;
+}
 
-    if (t == VALUE_TYPE_NULL)
-        *_retval = PR_TRUE;
-    else
-        *_retval = PR_FALSE;
+NS_IMETHODIMP
+Statement::GetSharedString(PRUint32 aIndex,
+                           PRUint32 *_length,
+                           const PRUnichar **_value)
+{
+  if (_length)
+    *_length = ::sqlite3_column_bytes16(mDBStatement, aIndex);
 
-    return NS_OK;
+  *_value = static_cast<const PRUnichar *>(::sqlite3_column_text16(mDBStatement,
+                                                                   aIndex));
+  return NS_OK;
 }
 
-/* AString escapeStringForLIKE(in AString aValue, in char aEscapeChar); */
 NS_IMETHODIMP
-mozStorageStatement::EscapeStringForLIKE(const nsAString & aValue, 
-                                         const PRUnichar aEscapeChar, 
-                                         nsAString &aEscapedString)
+Statement::GetSharedBlob(PRUint32 aIndex,
+                         PRUint32 *_size,
+                         const PRUint8 **_blob)
 {
-    const PRUnichar MATCH_ALL('%');
-    const PRUnichar MATCH_ONE('_');
-
-    aEscapedString.Truncate(0);
-
-    for (PRInt32 i = 0; i < aValue.Length(); i++) {
-        if (aValue[i] == aEscapeChar || aValue[i] == MATCH_ALL || 
-            aValue[i] == MATCH_ONE)
-            aEscapedString += aEscapeChar;
-        aEscapedString += aValue[i];
-    }
-    return NS_OK;
+  *_size = ::sqlite3_column_bytes(mDBStatement, aIndex);
+  *_blob = static_cast<const PRUint8 *>(::sqlite3_column_blob(mDBStatement,
+                                                              aIndex));
+  return NS_OK;
 }
 
-/* AString getColumnDecltype(in unsigned long aParamIndex); */
 NS_IMETHODIMP
-mozStorageStatement::GetColumnDecltype(PRUint32 aParamIndex,
-                                       nsACString& aDeclType)
+Statement::GetIsNull(PRUint32 aIndex,
+                     PRBool *_isNull)
 {
-    if (!mDBStatement)
-        return NS_ERROR_NOT_INITIALIZED;
-    
-    if (aParamIndex < 0 || aParamIndex >= mResultColumnCount)
-        return NS_ERROR_ILLEGAL_VALUE;
+  // Get type of Index will check aIndex for us, so we don't have to.
+  PRInt32 type;
+  nsresult rv = GetTypeOfIndex(aIndex, &type);
+  NS_ENSURE_SUCCESS(rv, rv);
+  *_isNull = (type == VALUE_TYPE_NULL);
+  return NS_OK;
+}
 
-    const char *declType = sqlite3_column_decltype(mDBStatement, aParamIndex);
-    aDeclType.Assign(declType);
-    
-    return NS_OK;
-}
+} // namespace storage
+} // namespace mozilla
--- a/storage/src/mozStorageStatement.h
+++ b/storage/src/mozStorageStatement.h
@@ -1,10 +1,11 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=2 et lcs=trail\:.,tab\:>~ :
+ * ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
  * Software distributed under the License is distributed on an "AS IS" basis,
@@ -31,79 +32,77 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#ifndef _MOZSTORAGESTATEMENT_H_
-#define _MOZSTORAGESTATEMENT_H_
+#ifndef _mozStorageStatement_h_
+#define _mozStorageStatement_h_
 
 #include "nsAutoPtr.h"
 #include "nsString.h"
 
 #include "nsTArray.h"
 
 #include "mozIStorageStatement.h"
 
-#include <sqlite3.h>
-
 class nsIXPConnectJSObjectHolder;
+struct sqlite3_stmt;
 
 namespace mozilla {
 namespace storage {
 class StatementJSHelper;
 class Connection;
-} // storage
-} // mozilla
 
-class mozStorageStatement : public mozIStorageStatement
+class Statement : public mozIStorageStatement
 {
 public:
-    mozStorageStatement();
+  NS_DECL_ISUPPORTS
+  NS_DECL_MOZISTORAGESTATEMENT
+  NS_DECL_MOZISTORAGEVALUEARRAY
 
-    // interfaces
-    NS_DECL_ISUPPORTS
-    NS_DECL_MOZISTORAGESTATEMENT
-    NS_DECL_MOZISTORAGEVALUEARRAY
+  Statement();
 
-    /**
-     * Initializes the object on aDBConnection by preparing the SQL statement
-     * given by aSQLStatement.
-     *
-     * @param aDBConnection
-     *        The mozStorageConnection object this statement is associated with.
-     * @param aSQLStatement
-     *        The SQL statement to prepare that this object will represent.
-     */
-    nsresult Initialize(mozilla::storage::Connection *aDBConnection,
-                        const nsACString &aSQLStatement);
+  /**
+   * Initializes the object on aDBConnection by preparing the SQL statement
+   * given by aSQLStatement.
+   *
+   * @param aDBConnection
+   *        The Connection object this statement is associated with.
+   * @param aSQLStatement
+   *        The SQL statement to prepare that this object will represent.
+   */
+  nsresult initialize(Connection *aDBConnection,
+                      const nsACString &aSQLStatement);
 
 
-    /**
-     * Obtains the native statement pointer.
-     */
-    inline sqlite3_stmt *nativeStatement() { return mDBStatement; }
+  /**
+   * Obtains the native statement pointer.
+   */
+  inline sqlite3_stmt *nativeStatement() { return mDBStatement; }
 
 private:
-    ~mozStorageStatement();
+    ~Statement();
 
-protected:
-    nsRefPtr<mozilla::storage::Connection> mDBConnection;
+    nsRefPtr<Connection> mDBConnection;
     sqlite3_stmt *mDBStatement;
     PRUint32 mParamCount;
     PRUint32 mResultColumnCount;
     nsTArray<nsCString> mColumnNames;
-    PRBool mExecuting;
+    bool mExecuting;
 
     /**
      * The following two members are only used with the JS helper.  They cache
      * the row and params objects.
      */
     nsCOMPtr<nsIXPConnectJSObjectHolder> mStatementParamsHolder;
     nsCOMPtr<nsIXPConnectJSObjectHolder> mStatementRowHolder;
 
-    friend class mozilla::storage::StatementJSHelper;
+    friend class StatementJSHelper;
 };
 
-#endif /* _MOZSTORAGESTATEMENT_H_ */
+} // storage
+} // mozilla
+
+#endif // _mozStorageStatement_h_
--- a/storage/src/mozStorageStatementJSHelper.cpp
+++ b/storage/src/mozStorageStatementJSHelper.cpp
@@ -69,18 +69,17 @@ stepFunc(JSContext *aCtx,
   nsresult rv = xpc->GetWrappedNativeOfJSObject(
     aCtx, JS_THIS_OBJECT(aCtx, _vp), getter_AddRefs(wrapper)
   );
   if (NS_FAILED(rv)) {
     ::JS_ReportError(aCtx, "mozIStorageStatement::step() could not obtain native statement");
     return JS_FALSE;
   }
 
-  mozStorageStatement *stmt =
-    static_cast<mozStorageStatement *>(wrapper->Native());
+  Statement *stmt = static_cast<Statement *>(wrapper->Native());
 
 #ifdef DEBUG
   {
     nsCOMPtr<mozIStorageStatement> isStatement(do_QueryInterface(stmt));
     NS_ASSERTION(isStatement, "How is this not a statement?!");
   }
 #endif
 
@@ -100,17 +99,17 @@ stepFunc(JSContext *aCtx,
   *_vp = BOOLEAN_TO_JSVAL(hasMore);
   return JS_TRUE;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 //// StatementJSHelper
 
 nsresult
-StatementJSHelper::getRow(mozStorageStatement *aStatement,
+StatementJSHelper::getRow(Statement *aStatement,
                           JSContext *aCtx,
                           JSObject *aScopeObj,
                           jsval *_row)
 {
   nsresult rv;
 
   PRInt32 state;
   (void)aStatement->GetState(&state);
@@ -136,17 +135,17 @@ StatementJSHelper::getRow(mozStorageStat
   rv = aStatement->mStatementRowHolder->GetJSObject(&obj);
   NS_ENSURE_SUCCESS(rv, rv);
 
   *_row = OBJECT_TO_JSVAL(obj);
   return NS_OK;
 }
 
 nsresult
-StatementJSHelper::getParams(mozStorageStatement *aStatement,
+StatementJSHelper::getParams(Statement *aStatement,
                              JSContext *aCtx,
                              JSObject *aScopeObj,
                              jsval *_params)
 {
   nsresult rv;
 
   PRInt32 state;
   (void)aStatement->GetState(&state);
@@ -200,18 +199,17 @@ StatementJSHelper::GetProperty(nsIXPConn
                                JSObject *aScopeObj,
                                jsval aId,
                                jsval *_result,
                                PRBool *_retval)
 {
   if (!JSVAL_IS_STRING(aId))
     return NS_OK;
 
-  mozStorageStatement *stmt =
-    static_cast<mozStorageStatement *>(aWrapper->Native());
+  Statement *stmt = static_cast<Statement *>(aWrapper->Native());
 
 #ifdef DEBUG
   {
     nsCOMPtr<mozIStorageStatement> isStatement(do_QueryInterface(stmt));
     NS_ASSERTION(isStatement, "How is this not a statement?!");
   }
 #endif
 
--- a/storage/src/mozStorageStatementJSHelper.h
+++ b/storage/src/mozStorageStatementJSHelper.h
@@ -37,28 +37,28 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef __MOZSTORAGESTATEMENTJSHELPER_H__
 #define __MOZSTORAGESTATEMENTJSHELPER_H__
 
 #include "nsIXPCScriptable.h"
 
-class mozStorageStatement;
+class Statement;
 
 namespace mozilla {
 namespace storage {
 
 class StatementJSHelper : public nsIXPCScriptable
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIXPCSCRIPTABLE
 
 private:
-  nsresult getRow(mozStorageStatement *, JSContext *, JSObject *, jsval *);
-  nsresult getParams(mozStorageStatement *, JSContext *, JSObject *, jsval *);
+  nsresult getRow(Statement *, JSContext *, JSObject *, jsval *);
+  nsresult getParams(Statement *, JSContext *, JSObject *, jsval *);
 };
 
 } // namespace storage
 } // namespace mozilla
 
 #endif // __MOZSTORAGESTATEMENTJSHELPER_H__
--- a/storage/src/mozStorageStatementParams.h
+++ b/storage/src/mozStorageStatementParams.h
@@ -42,37 +42,38 @@
 
 #include "mozIStorageStatementWrapper.h"
 #include "nsIXPCScriptable.h"
 
 #include "jsapi.h"
 #include "jsdate.h"
 
 class mozIStorageStatement;
-class mozStorageStatement;
 
 namespace mozilla {
 namespace storage {
 
+class Statement;
+
 class StatementParams : public mozIStorageStatementParams
                       , public nsIXPCScriptable
 {
 public:
   StatementParams(mozIStorageStatement *aStatement);
 
   // interfaces
   NS_DECL_ISUPPORTS
   NS_DECL_MOZISTORAGESTATEMENTPARAMS
   NS_DECL_NSIXPCSCRIPTABLE
 
 protected:
   mozIStorageStatement *mStatement;
   PRUint32 mParamCount;
 
-  friend class ::mozStorageStatement;
+  friend class Statement;
 };
 
 static
 PRBool
 JSValStorageStatementBinder(JSContext *aCtx,
                             mozIStorageStatement *aStatement,
                             int aIdx,
                             jsval aValue)
--- a/storage/src/mozStorageStatementRow.cpp
+++ b/storage/src/mozStorageStatementRow.cpp
@@ -48,18 +48,18 @@
 #include "jsdate.h"
 
 namespace mozilla {
 namespace storage {
 
 ////////////////////////////////////////////////////////////////////////////////
 //// StatementRow
 
-StatementRow::StatementRow(mozStorageStatement *aStatement) :
-    mStatement(aStatement)
+StatementRow::StatementRow(Statement *aStatement)
+: mStatement(aStatement)
 {
 }
 
 NS_IMPL_ISUPPORTS2(
   StatementRow,
   mozIStorageStatementRow,
   nsIXPCScriptable
 )
--- a/storage/src/mozStorageStatementRow.h
+++ b/storage/src/mozStorageStatementRow.h
@@ -38,34 +38,33 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef _MOZSTORAGESTATEMENTROW_H_
 #define _MOZSTORAGESTATEMENTROW_H_
 
 #include "mozIStorageStatementWrapper.h"
 #include "nsIXPCScriptable.h"
 
-class mozStorageStatement;
-
-
 namespace mozilla {
 namespace storage {
 
+class Statement;
+
 class StatementRow : public mozIStorageStatementRow
                    , public nsIXPCScriptable
 {
 public:
   NS_DECL_ISUPPORTS
   NS_DECL_MOZISTORAGESTATEMENTROW
   NS_DECL_NSIXPCSCRIPTABLE
 
-  StatementRow(mozStorageStatement *aStatement);
+  StatementRow(Statement *aStatement);
 protected:
 
-  mozStorageStatement *mStatement;
+  Statement *mStatement;
 
-  friend class ::mozStorageStatement;
+  friend class Statement;
 };
 
 } // namespace storage
 } // namespace mozilla
 
 #endif /* _MOZSTORAGESTATEMENTROW_H_ */
--- a/storage/src/mozStorageStatementWrapper.cpp
+++ b/storage/src/mozStorageStatementWrapper.cpp
@@ -72,17 +72,17 @@ NS_IMPL_ISUPPORTS2(
 //// mozIStorageStatementWrapper
 
 NS_IMETHODIMP
 StatementWrapper::Initialize(mozIStorageStatement *aStatement)
 {
   NS_ASSERTION(mStatement == nsnull, "StatementWrapper is already initialized");
   NS_ENSURE_ARG_POINTER(aStatement);
 
-  mStatement = static_cast<mozStorageStatement *>(aStatement);
+  mStatement = static_cast<Statement *>(aStatement);
 
   // fetch various things we care about
   (void)mStatement->GetParameterCount(&mParamCount);
   (void)mStatement->GetColumnCount(&mResultColumnCount);
 
   for (unsigned int i = 0; i < mResultColumnCount; i++) {
     const void *name = ::sqlite3_column_name16(nativeStatement(), i);
     (void)mColumnNames.AppendElement(nsDependentString(static_cast<const PRUnichar*>(name)));
--- a/storage/src/mozStorageStatementWrapper.h
+++ b/storage/src/mozStorageStatementWrapper.h
@@ -62,17 +62,17 @@ public:
 
 private:
     ~StatementWrapper();
 
     sqlite3_stmt *nativeStatement() {
       return mStatement->nativeStatement();
     }
 
-    nsRefPtr<mozStorageStatement> mStatement;
+    nsRefPtr<Statement> mStatement;
     PRUint32 mParamCount;
     PRUint32 mResultColumnCount;
     nsTArray<nsString> mColumnNames;
 
     nsCOMPtr<mozIStorageStatementRow> mStatementRow;
     nsCOMPtr<mozIStorageStatementParams> mStatementParams;
 };