Remove indexes from IDBDatabaseRequest
authorBen Turner <bent.mozilla@gmail.com>
Tue, 18 May 2010 10:12:54 -0700
changeset 44005 4b45d103318ebc2f97bea888e4e179f6e80bf332
parent 44004 bd2f53ccc182df441fabae6523ff6fac8dcf4a94
child 44006 59a9e1a65400c72127b38e3adc5c18538297121f
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)
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
Remove indexes from IDBDatabaseRequest
dom/indexedDB/IDBDatabaseRequest.cpp
dom/indexedDB/IDBDatabaseRequest.h
dom/indexedDB/IndexedDatabaseRequest.cpp
dom/indexedDB/nsIIDBDatabase.idl
dom/indexedDB/nsIIDBDatabaseRequest.idl
--- a/dom/indexedDB/IDBDatabaseRequest.cpp
+++ b/dom/indexedDB/IDBDatabaseRequest.cpp
@@ -178,30 +178,28 @@ private:
 
 } // anonymous namespace
 
 // static
 already_AddRefed<IDBDatabaseRequest>
 IDBDatabaseRequest::Create(const nsAString& aName,
                            const nsAString& aDescription,
                            nsTArray<nsString>& aObjectStoreNames,
-                           nsTArray<nsString>& aIndexNames,
                            const nsAString& aVersion,
                            LazyIdleThread* aThread,
                            const nsAString& aDatabaseFilePath,
                            nsCOMPtr<mozIStorageConnection>& aConnection)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   nsRefPtr<IDBDatabaseRequest> db(new IDBDatabaseRequest());
 
   db->mName.Assign(aName);
   db->mDescription.Assign(aDescription);
   db->mObjectStoreNames.SwapElements(aObjectStoreNames);
-  db->mIndexNames.SwapElements(aIndexNames);
   db->mVersion.Assign(aVersion);
   db->mDatabaseFilePath.Assign(aDatabaseFilePath);
 
   aThread->SetWeakIdleObserver(db);
   db->mConnectionThread = aThread;
 
   db->mConnection.swap(aConnection);
 
@@ -403,26 +401,16 @@ IDBDatabaseRequest::OnObjectStoreCreated
   NS_ASSERTION(!mObjectStoreNames.Contains(aName),
                "Already got this object store in the list!");
   if (!mObjectStoreNames.AppendElement(aName)) {
     NS_ERROR("Failed to add object store name! OOM?");
   }
 }
 
 void
-IDBDatabaseRequest::OnIndexCreated(const nsAString& aName)
-{
-  NS_ASSERTION(!mIndexNames.Contains(aName),
-               "Already got this index in the list!");
-  if (!mIndexNames.AppendElement(aName)) {
-    NS_ERROR("Failed to add index name! OOM?");
-  }
-}
-
-void
 IDBDatabaseRequest::OnObjectStoreRemoved(const nsAString& aName)
 {
   NS_ASSERTION(mObjectStoreNames.Contains(aName),
                "Didn't know about this object store before!");
   PRUint32 count = mObjectStoreNames.Length();
   for (PRUint32 index = 0; index < count; index++) {
     if (mObjectStoreNames[index].Equals(aName)) {
       mObjectStoreNames.RemoveElementAt(index);
@@ -483,42 +471,16 @@ IDBDatabaseRequest::GetObjectStores(nsID
     NS_ENSURE_TRUE(list->Add(mObjectStoreNames[index]), NS_ERROR_OUT_OF_MEMORY);
   }
 
   list.forget(aObjectStores);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-IDBDatabaseRequest::GetIndexes(nsIDOMDOMStringList** aIndexes)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
-  nsRefPtr<nsDOMStringList> list(new nsDOMStringList());
-  PRUint32 count = mIndexNames.Length();
-  for (PRUint32 index = 0; index < count; index++) {
-    NS_ENSURE_TRUE(list->Add(mIndexNames[index]), NS_ERROR_OUT_OF_MEMORY);
-  }
-
-
-  list.forget(aIndexes);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-IDBDatabaseRequest::GetCurrentTransaction(nsIIDBTransaction** aTransaction)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-
-  nsCOMPtr<nsIIDBTransaction> transaction(mCurrentTransaction);
-  transaction.forget(aTransaction);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 IDBDatabaseRequest::CreateObjectStore(const nsAString& aName,
                                       const nsAString& aKeyPath,
                                       PRBool aAutoIncrement,
                                       nsIIDBRequest** _retval)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   if (aName.IsEmpty()) {
@@ -627,29 +589,16 @@ IDBDatabaseRequest::CreateIndex(const ns
 
   nsCOMPtr<nsIIDBRequest> request(GenerateRequest());
   request.forget(_retval);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
-IDBDatabaseRequest::OpenIndex(const nsAString& aName,
-                              nsIIDBRequest** _retval)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-  NS_NOTYETIMPLEMENTED("Implement me!");
-
-  nsCOMPtr<nsIIDBRequest> request(GenerateRequest());
-  request.forget(_retval);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 IDBDatabaseRequest::RemoveObjectStore(const nsAString& aName,
                                       nsIIDBRequest** _retval)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   if (aName.IsEmpty()) {
     return NS_ERROR_INVALID_ARG;
   }
@@ -680,29 +629,16 @@ IDBDatabaseRequest::RemoveObjectStore(co
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   request.forget(_retval);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-IDBDatabaseRequest::RemoveIndex(const nsAString& aIndexName,
-                                nsIIDBRequest** _retval)
-{
-  NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
-  NS_NOTYETIMPLEMENTED("Implement me!");
-
-  nsCOMPtr<nsIIDBRequest> request(GenerateRequest());
-  request.forget(_retval);
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 IDBDatabaseRequest::SetVersion(const nsAString& aVersion,
                                nsIIDBRequest** _retval)
 {
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   nsRefPtr<IDBRequest> request = GenerateRequest();
 
   nsRefPtr<SetVersionHelper> helper =
--- a/dom/indexedDB/IDBDatabaseRequest.h
+++ b/dom/indexedDB/IDBDatabaseRequest.h
@@ -40,17 +40,16 @@
 #ifndef mozilla_dom_indexeddb_idbdatabaserequest_h__
 #define mozilla_dom_indexeddb_idbdatabaserequest_h__
 
 #include "mozilla/dom/indexedDB/IDBRequest.h"
 #include "mozilla/dom/indexedDB/LazyIdleThread.h"
 
 #include "mozIStorageConnection.h"
 #include "nsIIDBDatabaseRequest.h"
-#include "nsIIDBTransaction.h"
 #include "nsIObserver.h"
 
 #include "nsDOMLists.h"
 
 BEGIN_INDEXEDDB_NAMESPACE
 
 class AsyncConnectionHelper;
 class IDBObjectStoreRequest;
@@ -67,17 +66,16 @@ public:
   NS_DECL_NSIIDBDATABASE
   NS_DECL_NSIIDBDATABASEREQUEST
   NS_DECL_NSIOBSERVER
 
   static already_AddRefed<IDBDatabaseRequest>
   Create(const nsAString& aName,
          const nsAString& aDescription,
          nsTArray<nsString>& aObjectStoreNames,
-         nsTArray<nsString>& aIndexNames,
          const nsAString& aVersion,
          LazyIdleThread* aThread,
          const nsAString& aDatabaseFilePath,
          nsCOMPtr<mozIStorageConnection>& aConnection);
 
   /**
    * Obtains a cached statement for the put operation on object stores.
    *
@@ -140,19 +138,16 @@ protected:
 
 private:
   nsString mName;
   nsString mDescription;
   nsString mVersion;
   nsString mDatabaseFilePath;
 
   nsTArray<nsString> mObjectStoreNames;
-  nsTArray<nsString> mIndexNames;
-
-  nsCOMPtr<nsIIDBTransaction> mCurrentTransaction;
 
   nsRefPtr<LazyIdleThread> mConnectionThread;
 
   // Only touched on mStorageThread! These must be destroyed in the
   // FireCloseConnectionRunnable method.
   nsCOMPtr<mozIStorageConnection> mConnection;
   nsCOMPtr<mozIStorageStatement> mPutStmt;
   nsCOMPtr<mozIStorageStatement> mPutAutoIncrementStmt;
--- a/dom/indexedDB/IndexedDatabaseRequest.cpp
+++ b/dom/indexedDB/IndexedDatabaseRequest.cpp
@@ -84,17 +84,16 @@ private:
   // In-params.
   nsString mName;
   nsString mDescription;
   nsCString mASCIIOrigin;
   nsRefPtr<LazyIdleThread> mThread;
 
   // Out-params.
   nsTArray<nsString> mObjectStoreNames;
-  nsTArray<nsString> mIndexNames;
   nsString mVersion;
 
   nsCOMPtr<mozIStorageConnection> mConnection;
   nsString mDatabaseFilePath;
 };
 
 nsresult
 CreateTables(mozIStorageConnection* aDBConn)
@@ -546,20 +545,16 @@ OpenDatabaseHelper::DoDatabaseWork(mozIS
       nsString* name = mObjectStoreNames.AppendElement();
       NS_ENSURE_TRUE(name, nsIIDBDatabaseException::UNKNOWN_ERR);
 
       rv = stmt->GetString(0, *name);
       NS_ENSURE_SUCCESS(rv, nsIIDBDatabaseException::UNKNOWN_ERR);
     }
   }
 
-  { // Load index names.
-    NS_WARNING("Need to load index names here!");
-  }
-
   { // Load version information.
     nsCOMPtr<mozIStorageStatement> stmt;
     rv = mConnection->CreateStatement(NS_LITERAL_CSTRING(
       "SELECT version "
       "FROM database"
     ), getter_AddRefs(stmt));
     NS_ENSURE_SUCCESS(rv, nsIIDBDatabaseException::UNKNOWN_ERR);
 
@@ -580,17 +575,17 @@ OpenDatabaseHelper::DoDatabaseWork(mozIS
 
 PRUint16
 OpenDatabaseHelper::GetSuccessResult(nsIWritableVariant* aResult)
 {
   NS_ASSERTION(mConnection, "Should have a connection!");
 
   nsRefPtr<IDBDatabaseRequest> db =
     IDBDatabaseRequest::Create(mName, mDescription, mObjectStoreNames,
-                               mIndexNames, mVersion, mThread,
-                               mDatabaseFilePath, mConnection);
+                               mVersion, mThread, mDatabaseFilePath,
+                               mConnection);
   NS_ASSERTION(db, "This can't fail!");
 
   NS_ASSERTION(!mConnection, "Should have swapped out!");
 
   aResult->SetAsISupports(static_cast<IDBRequest::Generator*>(db));
   return OK;
 }
--- a/dom/indexedDB/nsIIDBDatabase.idl
+++ b/dom/indexedDB/nsIIDBDatabase.idl
@@ -52,13 +52,9 @@ interface nsIIDBDatabase : nsISupports
 {
   readonly attribute DOMString name;
 
   readonly attribute DOMString description;
 
   readonly attribute DOMString version;
 
   readonly attribute nsIDOMDOMStringList objectStores;
-
-  readonly attribute nsIDOMDOMStringList indexes;
-
-  readonly attribute nsIIDBTransaction currentTransaction;
 };
--- a/dom/indexedDB/nsIIDBDatabaseRequest.idl
+++ b/dom/indexedDB/nsIIDBDatabaseRequest.idl
@@ -64,24 +64,18 @@ interface nsIIDBDatabaseRequest : nsIIDB
 
   nsIIDBRequest
   createIndex(in AString name,
               in AString storeName,
               in AString keyPath,
               [optional /* false */] in boolean unique);
 
   nsIIDBRequest
-  openIndex(in AString name);
-
-  nsIIDBRequest
   removeObjectStore(in AString name);
 
   nsIIDBRequest
-  removeIndex(in AString indexName);
-
-  nsIIDBRequest
   setVersion(in AString version);
 
   [optional_argc]
   nsIIDBRequest
   openTransaction([optional /* null */]in nsIDOMDOMStringList storeNames,
                   [optional /* 5000ms */] in unsigned long timeout);
 };