Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(372)

Unified Diff: third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp

Issue 2349413002: Minor IndexedDB refactorings. (Closed)
Patch Set: Rebased Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp
index 4a5d672b23d772a072cff20f414c017eabe56394..c5e2aaad76bed544144475b772879f56b7edfb2a 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBRequest.cpp
@@ -71,7 +71,7 @@ IDBRequest::IDBRequest(ScriptState* scriptState, IDBAny* source, IDBTransaction*
IDBRequest::~IDBRequest()
{
- ASSERT(m_readyState == DONE || m_readyState == EarlyDeath || !getExecutionContext());
+ DCHECK(m_readyState == DONE || m_readyState == EarlyDeath || !getExecutionContext());
}
DEFINE_TRACE(IDBRequest)
@@ -123,7 +123,7 @@ ScriptValue IDBRequest::source() const
const String& IDBRequest::readyState() const
{
- ASSERT(m_readyState == PENDING || m_readyState == DONE);
+ DCHECK(m_readyState == PENDING || m_readyState == DONE);
if (m_readyState == PENDING)
return IndexedDBNames::pending;
@@ -133,10 +133,10 @@ const String& IDBRequest::readyState() const
void IDBRequest::abort()
{
- ASSERT(!m_requestAborted);
+ DCHECK(!m_requestAborted);
if (m_contextStopped || !getExecutionContext())
return;
- ASSERT(m_readyState == PENDING || m_readyState == DONE);
+ DCHECK(m_readyState == PENDING || m_readyState == DONE);
if (m_readyState == DONE)
return;
@@ -155,19 +155,19 @@ void IDBRequest::abort()
void IDBRequest::setCursorDetails(IndexedDB::CursorType cursorType, WebIDBCursorDirection direction)
{
- ASSERT(m_readyState == PENDING);
- ASSERT(!m_pendingCursor);
+ DCHECK_EQ(m_readyState, PENDING);
+ DCHECK(!m_pendingCursor);
m_cursorType = cursorType;
m_cursorDirection = direction;
}
void IDBRequest::setPendingCursor(IDBCursor* cursor)
{
- ASSERT(m_readyState == DONE);
- ASSERT(getExecutionContext());
- ASSERT(m_transaction);
- ASSERT(!m_pendingCursor);
- ASSERT(cursor == getResultCursor());
+ DCHECK_EQ(m_readyState, DONE);
+ DCHECK(getExecutionContext());
+ DCHECK(m_transaction);
+ DCHECK(!m_pendingCursor);
+ DCHECK_EQ(cursor, getResultCursor());
m_hasPendingActivity = true;
m_pendingCursor = cursor;
@@ -190,7 +190,7 @@ IDBCursor* IDBRequest::getResultCursor() const
void IDBRequest::setResultCursor(IDBCursor* cursor, IDBKey* key, IDBKey* primaryKey, PassRefPtr<IDBValue> value)
{
- ASSERT(m_readyState == PENDING);
+ DCHECK_EQ(m_readyState, PENDING);
m_cursorKey = key;
m_cursorPrimaryKey = primaryKey;
m_cursorValue = value;
@@ -218,11 +218,11 @@ bool IDBRequest::shouldEnqueueEvent() const
{
if (m_contextStopped || !getExecutionContext())
return false;
- ASSERT(m_readyState == PENDING || m_readyState == DONE);
+ DCHECK(m_readyState == PENDING || m_readyState == DONE);
if (m_requestAborted)
return false;
- ASSERT(m_readyState == PENDING);
- ASSERT(!m_error && !m_result);
+ DCHECK_EQ(m_readyState, PENDING);
+ DCHECK(!m_error && !m_result);
return true;
}
@@ -256,7 +256,7 @@ void IDBRequest::onSuccess(std::unique_ptr<WebIDBCursor> backend, IDBKey* key, I
if (!shouldEnqueueEvent())
return;
- ASSERT(!m_pendingCursor);
+ DCHECK(!m_pendingCursor);
IDBCursor* cursor = nullptr;
switch (m_cursorType) {
case IndexedDB::CursorKeyOnly:
@@ -266,7 +266,7 @@ void IDBRequest::onSuccess(std::unique_ptr<WebIDBCursor> backend, IDBKey* key, I
cursor = IDBCursorWithValue::create(std::move(backend), m_cursorDirection, this, m_source.get(), m_transaction.get());
break;
default:
- ASSERT_NOT_REACHED();
+ NOTREACHED();
}
setResultCursor(cursor, key, primaryKey, std::move(value));
}
@@ -293,7 +293,7 @@ void IDBRequest::onSuccess(const Vector<RefPtr<IDBValue>>& values)
onSuccessInternal(IDBAny::create(values));
}
-#if ENABLE(ASSERT)
+#if DCHECK_IS_ON()
static IDBObjectStore* effectiveObjectStore(IDBAny* source)
{
if (source->getType() == IDBAny::IDBObjectStoreType)
@@ -301,10 +301,10 @@ static IDBObjectStore* effectiveObjectStore(IDBAny* source)
if (source->getType() == IDBAny::IDBIndexType)
return source->idbIndex()->objectStore();
- ASSERT_NOT_REACHED();
+ NOTREACHED();
return nullptr;
}
-#endif
+#endif // DCHECK_IS_ON()
void IDBRequest::onSuccess(PassRefPtr<IDBValue> prpValue)
{
@@ -317,18 +317,18 @@ void IDBRequest::onSuccess(PassRefPtr<IDBValue> prpValue)
if (m_pendingCursor) {
// Value should be null, signifying the end of the cursor's range.
- ASSERT(value->isNull());
- ASSERT(!value->blobInfo()->size());
+ DCHECK(value->isNull());
+ DCHECK(!value->blobInfo()->size());
m_pendingCursor->close();
m_pendingCursor.clear();
}
-#if ENABLE(ASSERT)
+#if DCHECK_IS_ON()
if (value->primaryKey()) {
- ASSERT(value->keyPath() == effectiveObjectStore(m_source)->metadata().keyPath);
+ DCHECK(value->keyPath() == effectiveObjectStore(m_source)->idbKeyPath());
assertPrimaryKeyValidOrInjectable(m_scriptState.get(), value.get());
}
-#endif
+#endif // DCHECK_IS_ON()
onSuccessInternal(IDBAny::create(value.release()));
}
@@ -351,8 +351,8 @@ void IDBRequest::onSuccess()
void IDBRequest::onSuccessInternal(IDBAny* result)
{
- ASSERT(!m_contextStopped);
- ASSERT(!m_pendingCursor);
+ DCHECK(!m_contextStopped);
+ DCHECK(!m_pendingCursor);
setResult(result);
enqueueEvent(Event::create(EventTypeNames::success));
}
@@ -369,7 +369,7 @@ void IDBRequest::onSuccess(IDBKey* key, IDBKey* primaryKey, PassRefPtr<IDBValue>
if (!shouldEnqueueEvent())
return;
- ASSERT(m_pendingCursor);
+ DCHECK(m_pendingCursor);
setResultCursor(m_pendingCursor.release(), key, primaryKey, std::move(value));
}
@@ -420,10 +420,10 @@ DispatchEventResult IDBRequest::dispatchEventInternal(Event* event)
IDB_TRACE("IDBRequest::dispatchEvent");
if (m_contextStopped || !getExecutionContext())
return DispatchEventResult::CanceledBeforeDispatch;
- ASSERT(m_readyState == PENDING);
- ASSERT(m_hasPendingActivity);
- ASSERT(m_enqueuedEvents.size());
- ASSERT(event->target() == this);
+ DCHECK_EQ(m_readyState, PENDING);
+ DCHECK(m_hasPendingActivity);
+ DCHECK(m_enqueuedEvents.size());
+ DCHECK_EQ(event->target(), this);
ScriptState::Scope scope(m_scriptState.get());
@@ -451,7 +451,7 @@ DispatchEventResult IDBRequest::dispatchEventInternal(Event* event)
}
if (event->type() == EventTypeNames::upgradeneeded) {
- ASSERT(!m_didFireUpgradeNeededEvent);
+ DCHECK(!m_didFireUpgradeNeededEvent);
m_didFireUpgradeNeededEvent = true;
}
@@ -501,11 +501,11 @@ void IDBRequest::uncaughtExceptionInEventHandler()
void IDBRequest::transactionDidFinishAndDispatch()
{
- ASSERT(m_transaction);
- ASSERT(m_transaction->isVersionChange());
- ASSERT(m_didFireUpgradeNeededEvent);
- ASSERT(m_readyState == DONE);
- ASSERT(getExecutionContext());
+ DCHECK(m_transaction);
+ DCHECK(m_transaction->isVersionChange());
+ DCHECK(m_didFireUpgradeNeededEvent);
+ DCHECK_EQ(m_readyState, DONE);
+ DCHECK(getExecutionContext());
m_transaction.clear();
if (m_contextStopped)
@@ -516,7 +516,7 @@ void IDBRequest::transactionDidFinishAndDispatch()
void IDBRequest::enqueueEvent(Event* event)
{
- ASSERT(m_readyState == PENDING || m_readyState == DONE);
+ DCHECK(m_readyState == PENDING || m_readyState == DONE);
if (m_contextStopped || !getExecutionContext())
return;

Powered by Google App Engine
This is Rietveld 408576698