Fix more bugs
authorBen Turner <bent.mozilla@gmail.com>
Fri, 21 May 2010 16:08:58 -0700
changeset 44016 95fd72c43249554a4d1091a2c9e0c49679f1af2c
parent 44015 0ed9e1eade6f3dfe587349d2836a7963401195db
child 44017 9c5cc89881a73d87d13f1cd56abba1f3e0357a63
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
Fix more bugs
dom/indexedDB/IDBDatabaseRequest.cpp
dom/indexedDB/IDBDatabaseRequest.h
--- a/dom/indexedDB/IDBDatabaseRequest.cpp
+++ b/dom/indexedDB/IDBDatabaseRequest.cpp
@@ -642,31 +642,30 @@ IDBDatabaseRequest::RemoveObjectStore(co
   NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
 
   if (aName.IsEmpty()) {
     return NS_ERROR_INVALID_ARG;
   }
 
   nsRefPtr<IDBRequest> request = GenerateRequest();
 
-  PRInt64 id;
-  bool exists = IdForObjectStoreName(aName, &id);
+  ObjectStoreInfo* info;
+  bool exists = ObjectStoreInfoForName(aName, &info);
 
   nsresult rv;
   if (NS_UNLIKELY(!exists)) {
     nsCOMPtr<nsIRunnable> runnable =
       IDBErrorEvent::CreateRunnable(request,
                                     nsIIDBDatabaseException::NOT_FOUND_ERR);
     NS_ENSURE_TRUE(runnable, NS_ERROR_UNEXPECTED);
     rv = NS_DispatchToCurrentThread(runnable);
   }
   else {
-    ObjectStoreInfo info(aName, id);
     nsRefPtr<RemoveObjectStoreHelper> helper =
-      new RemoveObjectStoreHelper(this, request, info);
+      new RemoveObjectStoreHelper(this, request, *info);
     rv = helper->Dispatch(mConnectionThread);
   }
   NS_ENSURE_SUCCESS(rv, rv);
 
   request.forget(_retval);
   return NS_OK;
 }
 
@@ -850,24 +849,24 @@ IDBDatabaseRequest::ObjectStore(const ns
         aMode != nsIIDBTransaction::SNAPSHOT_READ) {
       return NS_ERROR_INVALID_ARG;
     }
   }
   else {
     aMode = nsIIDBTransaction::READ_ONLY;
   }
 
-  PRInt64 id;
-  if (!IdForObjectStoreName(aName, &id)) {
+  ObjectStoreInfo* info;
+  if (!ObjectStoreInfoForName(aName, &info)) {
     NS_NOTYETIMPLEMENTED("Need right return code");
     return NS_ERROR_INVALID_ARG;
   }
 
   nsTArray<ObjectStoreInfo> objectStores;
-  if (!objectStores.AppendElement(mObjectStores[id])) {
+  if (!objectStores.AppendElement(*info)) {
     NS_ERROR("Out of memory");
     return NS_ERROR_OUT_OF_MEMORY;
   }
 
   nsRefPtr<IDBTransactionRequest> transaction =
     IDBTransactionRequest::Create(this, objectStores, aMode,
                                   kDefaultDatabaseTimeoutSeconds);
   NS_ENSURE_TRUE(transaction, NS_ERROR_FAILURE);
--- a/dom/indexedDB/IDBDatabaseRequest.h
+++ b/dom/indexedDB/IDBDatabaseRequest.h
@@ -183,27 +183,32 @@ protected:
   // Only meant to be called on mStorageThread!
   nsCOMPtr<mozIStorageConnection>& Connection();
 
   // Only meant to be called on mStorageThread!
   nsresult EnsureConnection();
 
   nsresult QueueDatabaseWork(nsIRunnable* aRunnable);
 
-  bool IdForObjectStoreName(const nsAString& aName,
-                            PRInt64* aIndex) {
-    NS_ASSERTION(aIndex, "Null pointer!");
+  bool ObjectStoreInfoForName(const nsAString& aName,
+                              ObjectStoreInfo** aInfo) {
+    NS_ASSERTION(aInfo, "Null pointer!");
     PRUint32 count = mObjectStores.Length();
     for (PRUint32 index = 0; index < count; index++) {
       ObjectStoreInfo& store = mObjectStores[index];
       if (store.name == aName) {
-        *aIndex = PRInt64(index);
+        if (aInfo) {
+          *aInfo = &store;
+        }
         return true;
       }
     }
+    if (aInfo) {
+      *aInfo = nsnull;
+    }
     return false;
   }
 
 private:
   nsString mName;
   nsString mDescription;
   nsString mVersion;
   nsString mDatabaseFilePath;