Bug 692671: IndexedDB: remove timeout in database operations. r=sicking.

This commit is contained in:
Ben Turner 2011-11-08 09:43:00 -08:00
Родитель a8a5ed6540
Коммит 89b3794ebe
9 изменённых файлов: 9 добавлений и 76 удалений

Просмотреть файл

@ -50,9 +50,6 @@
#include "IndexedDatabaseManager.h"
#include "TransactionThreadPool.h"
using mozilla::TimeStamp;
using mozilla::TimeDuration;
USING_INDEXEDDB_NAMESPACE
namespace {
@ -60,7 +57,6 @@ namespace {
IDBTransaction* gCurrentTransaction = nsnull;
const PRUint32 kProgressHandlerGranularity = 1000;
const PRUint32 kDefaultTimeoutMS = 30000;
NS_STACK_CLASS
class TransactionPoolEventTarget : public nsIEventTarget
@ -170,7 +166,6 @@ AsyncConnectionHelper::AsyncConnectionHelper(IDBDatabase* aDatabase,
IDBRequest* aRequest)
: HelperBase(aRequest),
mDatabase(aDatabase),
mTimeoutDuration(TimeDuration::FromMilliseconds(kDefaultTimeoutMS)),
mResultCode(NS_OK),
mDispatched(false)
{
@ -182,7 +177,6 @@ AsyncConnectionHelper::AsyncConnectionHelper(IDBTransaction* aTransaction,
: HelperBase(aRequest),
mDatabase(aTransaction->mDatabase),
mTransaction(aTransaction),
mTimeoutDuration(TimeDuration::FromMilliseconds(kDefaultTimeoutMS)),
mResultCode(NS_OK),
mDispatched(false)
{
@ -272,12 +266,13 @@ AsyncConnectionHelper::Run()
}
}
bool setProgressHandler = false;
if (connection) {
rv = connection->SetProgressHandler(kProgressHandlerGranularity, this,
getter_AddRefs(mOldProgressHandler));
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "SetProgressHandler failed!");
if (NS_SUCCEEDED(rv)) {
mStartTime = TimeStamp::Now();
setProgressHandler = true;
}
}
@ -322,18 +317,16 @@ AsyncConnectionHelper::Run()
}
}
if (!mStartTime.IsNull()) {
if (setProgressHandler) {
nsCOMPtr<mozIStorageProgressHandler> handler;
rv = connection->RemoveProgressHandler(getter_AddRefs(handler));
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "RemoveProgressHandler failed!");
#ifdef DEBUG
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsISupports> handlerSupports(do_QueryInterface(handler));
nsCOMPtr<nsISupports> thisSupports = do_QueryObject(this);
NS_ASSERTION(thisSupports == handlerSupports, "Mismatch!");
NS_ASSERTION(SameCOMIdentity(handler, static_cast<nsIRunnable*>(this)),
"Mismatch!");
}
#endif
mStartTime = TimeStamp();
}
return NS_DispatchToMainThread(this, NS_DISPATCH_NORMAL);
@ -349,12 +342,6 @@ AsyncConnectionHelper::OnProgress(mozIStorageConnection* aConnection,
return NS_OK;
}
TimeDuration elapsed = TimeStamp::Now() - mStartTime;
if (elapsed >= mTimeoutDuration) {
*_retval = true;
return NS_OK;
}
if (mOldProgressHandler) {
return mOldProgressHandler->OnProgress(aConnection, _retval);
}

Просмотреть файл

@ -47,13 +47,11 @@
#include "mozIStorageProgressHandler.h"
#include "nsIRunnable.h"
#include "nsIThread.h"
#include "nsDOMEvent.h"
#include "mozilla/TimeStamp.h"
class mozIStorageConnection;
class nsIEventTarget;
BEGIN_INDEXEDDB_NAMESPACE
@ -149,14 +147,6 @@ protected:
virtual ~AsyncConnectionHelper();
/**
* Set the timeout duration in milliseconds.
*/
void SetTimeoutMS(PRUint32 aTimeoutMS)
{
mTimeoutDuration = TimeDuration::FromMilliseconds(aTimeoutMS);
}
/**
* This is called on the main thread after Dispatch is called but before the
* runnable is actually dispatched to the database thread. Allows the subclass
@ -219,10 +209,6 @@ protected:
private:
nsCOMPtr<mozIStorageProgressHandler> mOldProgressHandler;
mozilla::TimeStamp mStartTime;
mozilla::TimeDuration mTimeoutDuration;
nsresult mResultCode;
bool mDispatched;
};

Просмотреть файл

@ -64,8 +64,6 @@ USING_INDEXEDDB_NAMESPACE
namespace {
const PRUint32 kDefaultDatabaseTimeoutSeconds = 30;
PRUint32 gDatabaseInstanceCount = 0;
mozilla::Mutex* gPromptHelpersMutex = nsnull;
@ -705,8 +703,7 @@ IDBDatabase::Transaction(const jsval& aStoreNames,
}
nsRefPtr<IDBTransaction> transaction =
IDBTransaction::Create(this, storesToOpen, aMode,
kDefaultDatabaseTimeoutSeconds);
IDBTransaction::Create(this, storesToOpen, aMode, false);
NS_ENSURE_TRUE(transaction, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
transaction.forget(_retval);

Просмотреть файл

@ -53,7 +53,6 @@
#define ERROR_EVT_STR "error"
#define COMPLETE_EVT_STR "complete"
#define ABORT_EVT_STR "abort"
#define TIMEOUT_EVT_STR "timeout"
#define VERSIONCHANGE_EVT_STR "versionchange"
#define BLOCKED_EVT_STR "blocked"
#define UPGRADENEEDED_EVT_STR "upgradeneeded"

Просмотреть файл

@ -80,7 +80,6 @@ already_AddRefed<IDBTransaction>
IDBTransaction::Create(IDBDatabase* aDatabase,
nsTArray<nsString>& aObjectStoreNames,
PRUint16 aMode,
PRUint32 aTimeout,
bool aDispatchDelayed)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -92,7 +91,6 @@ IDBTransaction::Create(IDBDatabase* aDatabase,
transaction->mDatabase = aDatabase;
transaction->mMode = aMode;
transaction->mTimeout = aTimeout;
if (!transaction->mObjectStoreNames.AppendElements(aObjectStoreNames)) {
NS_ERROR("Out of memory!");
@ -129,7 +127,6 @@ IDBTransaction::Create(IDBDatabase* aDatabase,
IDBTransaction::IDBTransaction()
: mReadyState(nsIIDBTransaction::INITIAL),
mMode(nsIIDBTransaction::READ_ONLY),
mTimeout(0),
mPendingRequests(0),
mCreatedRecursionDepth(0),
mSavepointCount(0),
@ -524,7 +521,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBTransaction,
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnErrorListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnCompleteListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnAbortListener)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnTimeoutListener)
for (PRUint32 i = 0; i < tmp->mCreatedObjectStores.Length(); i++) {
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mCreatedObjectStores[i]");
@ -540,7 +536,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBTransaction,
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnErrorListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnCompleteListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnAbortListener)
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnTimeoutListener)
tmp->mCreatedObjectStores.Clear();
@ -724,23 +719,6 @@ IDBTransaction::SetOnabort(nsIDOMEventListener* aOnabort)
mOnAbortListener, aOnabort);
}
NS_IMETHODIMP
IDBTransaction::GetOntimeout(nsIDOMEventListener** aOntimeout)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return GetInnerEventListener(mOnTimeoutListener, aOntimeout);
}
NS_IMETHODIMP
IDBTransaction::SetOntimeout(nsIDOMEventListener* aOntimeout)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return RemoveAddEventListener(NS_LITERAL_STRING(TIMEOUT_EVT_STR),
mOnTimeoutListener, aOntimeout);
}
nsresult
IDBTransaction::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
{

Просмотреть файл

@ -95,8 +95,7 @@ public:
Create(IDBDatabase* aDatabase,
nsTArray<nsString>& aObjectStoreNames,
PRUint16 aMode,
PRUint32 aTimeout,
bool aDispatchDelayed = false);
bool aDispatchDelayed);
// nsIDOMEventTarget
virtual nsresult PreHandleEvent(nsEventChainPreVisitor& aVisitor);
@ -173,7 +172,6 @@ private:
nsTArray<nsString> mObjectStoreNames;
PRUint16 mReadyState;
PRUint16 mMode;
PRUint32 mTimeout;
PRUint32 mPendingRequests;
PRUint32 mCreatedRecursionDepth;
@ -181,7 +179,6 @@ private:
nsRefPtr<nsDOMEventListenerWrapper> mOnErrorListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnCompleteListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnAbortListener;
nsRefPtr<nsDOMEventListenerWrapper> mOnTimeoutListener;
nsInterfaceHashtable<nsCStringHashKey, mozIStorageStatement>
mCachedStatements;

Просмотреть файл

@ -50,8 +50,6 @@
USING_INDEXEDDB_NAMESPACE
const extern PRUint32 kDefaultDatabaseTimeoutSeconds = 30;
namespace {
nsresult
@ -845,8 +843,7 @@ OpenDatabaseHelper::StartSetVersion()
nsTArray<nsString> storesToOpen;
nsRefPtr<IDBTransaction> transaction =
IDBTransaction::Create(mDatabase, storesToOpen,
IDBTransaction::VERSION_CHANGE,
kDefaultDatabaseTimeoutSeconds, true);
IDBTransaction::VERSION_CHANGE, true);
NS_ENSURE_TRUE(transaction, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsRefPtr<SetVersionHelper> helper =

Просмотреть файл

@ -83,10 +83,4 @@ interface nsIIDBTransaction : nsISupports
// Event listener that fires when the transaction is aborted.
// Receives an Event.
attribute nsIDOMEventListener onabort;
// Event listener that fires when the transaction times out while
// attempting to grab the relevant locks, as specified by the
// timeoutSeconds parameter
// Receives an Event.
attribute nsIDOMEventListener ontimeout;
};

Просмотреть файл

@ -50,7 +50,6 @@
is(transaction.objectStore("foo"), objectStore, "Can get stores");
is(transaction.oncomplete, null, "No complete listener");
is(transaction.onabort, null, "No abort listener");
is(transaction.ontimeout, null, "No timeout listener");
is(objectStore.name, "foo", "Correct name");
is(objectStore.keyPath, "", "Correct keyPath");
@ -69,7 +68,6 @@
is(transaction.objectStoreNames.length, 1, "Correct names length");
is(transaction.objectStoreNames.item(0), "foo", "Correct name");
is(transaction.onabort, null, "No abort listener");
is(transaction.ontimeout, null, "No timeout listener");
try {
is(transaction.objectStore("foo").name, "foo", "Can't get stores");