本文整理汇总了C++中IDBTransaction类的典型用法代码示例。如果您正苦于以下问题:C++ IDBTransaction类的具体用法?C++ IDBTransaction怎么用?C++ IDBTransaction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IDBTransaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: didAbortTransaction
void IDBDatabase::didAbortTransaction(IDBTransaction& transaction)
{
LOG(IndexedDB, "IDBDatabase::didAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
ASSERT(currentThread() == originThreadID());
if (transaction.isVersionChange()) {
ASSERT(transaction.originalDatabaseInfo());
ASSERT(m_info.version() == transaction.originalDatabaseInfo()->version());
m_closePending = true;
maybeCloseInServer();
}
didCommitOrAbortTransaction(transaction);
}
示例2: NS_ASSERTION
void
TransactionThreadPool::AbortTransactionsForDatabase(IDBDatabase* aDatabase)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ASSERTION(aDatabase, "Null pointer!");
// Get list of transactions for this database id
DatabaseTransactionInfo* dbTransactionInfo;
if (!mTransactionsInProgress.Get(aDatabase->Id(), &dbTransactionInfo)) {
// If there are no running transactions, there can't be any pending ones
return;
}
nsAutoTArray<nsRefPtr<IDBTransaction>, 50> transactions;
// Collect any running transactions
nsTArray<TransactionInfo>& transactionsInProgress =
dbTransactionInfo->transactions;
PRUint32 transactionCount = transactionsInProgress.Length();
NS_ASSERTION(transactionCount, "Should never be 0!");
for (PRUint32 index = 0; index < transactionCount; index++) {
// See if any transaction belongs to this IDBDatabase instance
IDBTransaction* transaction = transactionsInProgress[index].transaction;
if (transaction->Database() == aDatabase) {
transactions.AppendElement(transaction);
}
}
// Collect any pending transactions.
for (PRUint32 index = 0; index < mDelayedDispatchQueue.Length(); index++) {
// See if any transaction belongs to this IDBDatabase instance
IDBTransaction* transaction = mDelayedDispatchQueue[index].transaction;
if (transaction->Database() == aDatabase) {
transactions.AppendElement(transaction);
}
}
// Abort transactions. Do this after collecting the transactions in case
// calling Abort() modifies the data structures we're iterating above.
for (PRUint32 index = 0; index < transactions.Length(); index++) {
// This can fail, for example if the transaction is in the process of
// being comitted. That is expected and fine, so we ignore any returned
// errors.
transactions[index]->Abort();
}
}
示例3: hasRecordOfTransaction
bool IDBConnectionProxy::hasRecordOfTransaction(const IDBTransaction& transaction) const
{
ASSERT(m_transactionMapLock.isLocked());
auto identifier = transaction.info().identifier();
return m_pendingTransactions.contains(identifier) || m_committingTransactions.contains(identifier) || m_abortingTransactions.contains(identifier);
}
示例4: IDBActiveDOMObject
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
: IDBActiveDOMObject(&context)
, m_transaction(&transaction)
, m_resourceIdentifier(transaction.connectionProxy())
, m_pendingCursor(&cursor)
, m_connectionProxy(transaction.database().connectionProxy())
{
suspendIfNeeded();
WTF::switchOn(cursor.source(),
[this] (const auto& value) { this->m_source = IDBRequest::Source { value }; }
);
m_result = NullResultType::Empty;
cursor.setRequest(*this);
}
示例5: didStartTransaction
void IDBDatabase::didStartTransaction(IDBTransaction& transaction)
{
LOG(IndexedDB, "IDBDatabase::didStartTransaction");
ASSERT(!m_versionChangeTransaction);
m_activeTransactions.set(transaction.info().identifier(), &transaction);
}
示例6: IDBOpenDBRequest
IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBCursor& cursor, IDBTransaction& transaction)
: IDBOpenDBRequest(&context)
, m_transaction(&transaction)
, m_connection(transaction.serverConnection())
, m_resourceIdentifier(transaction.serverConnection())
, m_pendingCursor(&cursor)
{
suspendIfNeeded();
cursor.setRequest(*this);
auto* cursorSource = cursor.source();
ASSERT(cursorSource);
ASSERT(cursorSource->type() == IDBAny::Type::IDBObjectStore || cursorSource->type() == IDBAny::Type::IDBIndex);
m_source = cursorSource;
}
示例7: dispatchEventCallback
static v8::Handle<v8::Value> dispatchEventCallback(const v8::Arguments& args)
{
INC_STATS("DOM.IDBTransaction.dispatchEvent");
IDBTransaction* imp = V8IDBTransaction::toNative(args.Holder());
ExceptionCode ec = 0;
{
EXCEPTION_BLOCK(Event*, evt, V8Event::HasInstance(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined)) ? V8Event::toNative(v8::Handle<v8::Object>::Cast(MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined))) : 0);
bool result = imp->dispatchEvent(evt, ec);
if (UNLIKELY(ec))
goto fail;
return v8Boolean(result);
}
fail:
V8Proxy::setDOMException(ec);
return v8::Handle<v8::Value>();
}
示例8: objectStoreCallback
static v8::Handle<v8::Value> objectStoreCallback(const v8::Arguments& args)
{
INC_STATS("DOM.IDBTransaction.objectStore");
IDBTransaction* imp = V8IDBTransaction::toNative(args.Holder());
ExceptionCode ec = 0;
{
STRING_TO_V8PARAMETER_EXCEPTION_BLOCK(V8Parameter<>, name, MAYBE_MISSING_PARAMETER(args, 0, MissingIsUndefined));
RefPtr<IDBObjectStore> result = imp->objectStore(name, ec);
if (UNLIKELY(ec))
goto fail;
return toV8(result.release());
}
fail:
V8Proxy::setDOMException(ec);
return v8::Handle<v8::Value>();
}
示例9: NS_ASSERTION
NS_IMETHODIMP
IDBIndex::OpenKeyCursor(const jsval& aKey,
PRUint16 aDirection,
JSContext* aCx,
PRUint8 aOptionalArgCount,
nsIIDBRequest** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
nsresult rv;
nsRefPtr<IDBKeyRange> keyRange;
if (aOptionalArgCount) {
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
NS_ENSURE_SUCCESS(rv, rv);
if (aOptionalArgCount >= 2) {
if (aDirection != nsIIDBCursor::NEXT &&
aDirection != nsIIDBCursor::NEXT_NO_DUPLICATE &&
aDirection != nsIIDBCursor::PREV &&
aDirection != nsIIDBCursor::PREV_NO_DUPLICATE) {
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
}
}
else {
aDirection = nsIIDBCursor::NEXT;
}
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsRefPtr<OpenKeyCursorHelper> helper =
new OpenKeyCursorHelper(transaction, request, this, keyRange, aDirection);
rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
request.forget(_retval);
return NS_OK;
}
示例10: didCommitOrAbortTransaction
void IDBDatabase::didCommitOrAbortTransaction(IDBTransaction& transaction)
{
LOG(IndexedDB, "IDBDatabase::didCommitOrAbortTransaction %s", transaction.info().identifier().loggingString().utf8().data());
if (m_versionChangeTransaction == &transaction)
m_versionChangeTransaction = nullptr;
#ifndef NDBEBUG
unsigned count = 0;
if (m_activeTransactions.contains(transaction.info().identifier()))
++count;
if (m_committingTransactions.contains(transaction.info().identifier()))
++count;
if (m_abortingTransactions.contains(transaction.info().identifier()))
++count;
ASSERT(count == 1);
#endif
m_activeTransactions.remove(transaction.info().identifier());
m_committingTransactions.remove(transaction.info().identifier());
m_abortingTransactions.remove(transaction.info().identifier());
if (m_closePending)
maybeCloseInServer();
}
示例11: didCommitTransaction
void IDBDatabase::didCommitTransaction(IDBTransaction& transaction)
{
LOG(IndexedDB, "IDBDatabase::didCommitTransaction");
if (m_versionChangeTransaction == &transaction)
m_info.setVersion(transaction.info().newVersion());
didCommitOrAbortTransaction(transaction);
}
示例12: LOG
void IDBDatabase::stop()
{
LOG(IndexedDB, "IDBDatabase::stop - %" PRIu64, m_databaseConnectionIdentifier);
Vector<IDBResourceIdentifier> transactionIdentifiers;
transactionIdentifiers.reserveInitialCapacity(m_activeTransactions.size());
for (auto& id : m_activeTransactions.keys())
transactionIdentifiers.uncheckedAppend(id);
for (auto& id : transactionIdentifiers) {
IDBTransaction* transaction = m_activeTransactions.get(id);
if (transaction)
transaction->stop();
}
close();
}
示例13: NS_ASSERTION
NS_IMETHODIMP
IDBIndex::GetAllKeys(nsIVariant* aKey,
PRUint32 aLimit,
PRUint8 aOptionalArgCount,
nsIIDBRequest** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
IDBTransaction* transaction = mObjectStore->Transaction();
if (!transaction->IsOpen()) {
return NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR;
}
nsresult rv;
Key key;
if (aOptionalArgCount &&
NS_FAILED(IDBObjectStore::GetKeyFromVariant(aKey, key))) {
PRUint16 type;
rv = aKey->GetDataType(&type);
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (type != nsIDataType::VTYPE_EMPTY) {
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
}
}
if (aOptionalArgCount < 2) {
aLimit = PR_UINT32_MAX;
}
nsRefPtr<IDBRequest> request = GenerateRequest(this);
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
nsRefPtr<GetAllKeysHelper> helper =
new GetAllKeysHelper(transaction, request, this, key, aLimit);
rv = helper->DispatchToTransactionPool();
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
request.forget(_retval);
return NS_OK;
}
示例14: AssertIsOnOwningThread
void
IDBIndex::SetName(const nsAString& aName, ErrorResult& aRv)
{
AssertIsOnOwningThread();
IDBTransaction* transaction = mObjectStore->Transaction();
if (transaction->GetMode() != IDBTransaction::VERSION_CHANGE ||
mDeletedMetadata) {
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
if (!transaction->IsOpen()) {
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_TRANSACTION_INACTIVE_ERR);
return;
}
if (aName == mMetadata->name()) {
return;
}
// Cache logging string of this index before renaming.
const LoggingString loggingOldIndex(this);
const int64_t indexId = Id();
nsresult rv =
transaction->Database()->RenameIndex(mObjectStore->Id(),
indexId,
aName);
if (NS_FAILED(rv)) {
aRv.Throw(rv);
return;
}
// Don't do this in the macro because we always need to increment the serial
// number to keep in sync with the parent.
const uint64_t requestSerialNumber = IDBRequest::NextSerialNumber();
IDB_LOG_MARK("IndexedDB %s: Child Transaction[%lld] Request[%llu]: "
"database(%s).transaction(%s).objectStore(%s).index(%s)."
"rename(%s)",
"IndexedDB %s: C T[%lld] R[%llu]: IDBIndex.rename()",
IDB_LOG_ID_STRING(),
transaction->LoggingSerialNumber(),
requestSerialNumber,
IDB_LOG_STRINGIFY(transaction->Database()),
IDB_LOG_STRINGIFY(transaction),
IDB_LOG_STRINGIFY(mObjectStore),
loggingOldIndex.get(),
IDB_LOG_STRINGIFY(this));
transaction->RenameIndex(mObjectStore, indexId, aName);
}
示例15: LOG
void IDBDatabase::stop()
{
LOG(IndexedDB, "IDBDatabase::stop - %" PRIu64, m_databaseConnectionIdentifier);
ASSERT(&originThread() == &Thread::current());
removeAllEventListeners();
Vector<IDBResourceIdentifier> transactionIdentifiers;
transactionIdentifiers.reserveInitialCapacity(m_activeTransactions.size());
for (auto& id : m_activeTransactions.keys())
transactionIdentifiers.uncheckedAppend(id);
for (auto& id : transactionIdentifiers) {
IDBTransaction* transaction = m_activeTransactions.get(id);
if (transaction)
transaction->stop();
}
close();
}