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

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

Issue 2349413002: Minor IndexedDB refactorings. (Closed)
Patch Set: 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/IDBIndex.cpp
diff --git a/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp b/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp
index 1599c7f233ae0a68d8ac6491df5dfad7fab1cb39..5f832bb21848aa57e7a3f3cce9af41e3f13e2a99 100644
--- a/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp
+++ b/third_party/WebKit/Source/modules/indexeddb/IDBIndex.cpp
@@ -50,9 +50,9 @@ IDBIndex::IDBIndex(const IDBIndexMetadata& metadata, IDBObjectStore* objectStore
, m_objectStore(objectStore)
, m_transaction(transaction)
{
- ASSERT(m_objectStore);
- ASSERT(m_transaction);
- ASSERT(m_metadata.id != IDBIndexMetadata::InvalidId);
+ DCHECK(m_objectStore);
+ DCHECK(m_transaction);
+ DCHECK(id() != IDBIndexMetadata::InvalidId);
cmumford 2016/09/19 23:26:48 DCHECK_NE
pwnall 2016/09/20 09:11:14 Done. TBH, I was trying to be smart and thinking
}
IDBIndex::~IDBIndex()
@@ -65,7 +65,7 @@ DEFINE_TRACE(IDBIndex)
visitor->trace(m_transaction);
}
-void IDBIndex::setName(const String& name, ExceptionState& exceptionState)
+void IDBIndex::setName(const String& newName, ExceptionState& exceptionState)
cmumford 2016/09/19 23:26:48 Nit: Several other Blink "setName" methods use "na
pwnall 2016/09/20 09:11:14 Done. I was mostly trying to avoid if (this->name
{
if (!RuntimeEnabledFeatures::indexedDBExperimentalEnabled())
return;
@@ -88,9 +88,9 @@ void IDBIndex::setName(const String& name, ExceptionState& exceptionState)
return;
}
- if (m_metadata.name == name)
+ if (name() == newName)
return;
- if (m_objectStore->containsIndex(name)) {
+ if (m_objectStore->containsIndex(newName)) {
exceptionState.throwDOMException(ConstraintError, IDBDatabase::indexNameTakenErrorMessage);
return;
}
@@ -99,15 +99,15 @@ void IDBIndex::setName(const String& name, ExceptionState& exceptionState)
return;
}
- backendDB()->renameIndex(m_transaction->id(), m_objectStore->id(), id(), name);
- m_metadata.name = name;
- m_objectStore->indexRenamed(m_metadata.id, name);
- m_transaction->db()->indexRenamed(m_objectStore->id(), id(), name);
+ backendDB()->renameIndex(m_transaction->id(), m_objectStore->id(), id(), newName);
+ m_metadata.name = newName;
+ m_objectStore->indexRenamed(m_metadata.id, newName);
+ m_transaction->db()->indexRenamed(m_objectStore->id(), id(), newName);
}
ScriptValue IDBIndex::keyPath(ScriptState* scriptState) const
{
- return ScriptValue::from(scriptState, m_metadata.keyPath);
+ return ScriptValue::from(scriptState, metadata().keyPath);
}
IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, const ScriptValue& range, const String& directionString, ExceptionState& exceptionState)
@@ -142,7 +142,7 @@ IDBRequest* IDBIndex::openCursor(ScriptState* scriptState, IDBKeyRange* keyRange
{
IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
request->setCursorDetails(IndexedDB::CursorKeyAndValue, direction);
- backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, direction, false, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create(request).release());
+ backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), keyRange, direction, false, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create(request).release());
return request;
}
@@ -172,7 +172,7 @@ IDBRequest* IDBIndex::count(ScriptState* scriptState, const ScriptValue& range,
}
IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
- backendDB()->count(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, WebIDBCallbacksImpl::create(request).release());
+ backendDB()->count(m_transaction->id(), m_objectStore->id(), id(), keyRange, WebIDBCallbacksImpl::create(request).release());
return request;
}
@@ -202,7 +202,7 @@ IDBRequest* IDBIndex::openKeyCursor(ScriptState* scriptState, const ScriptValue&
IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
request->setCursorDetails(IndexedDB::CursorKeyOnly, direction);
- backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, direction, true, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create(request).release());
+ backendDB()->openCursor(m_transaction->id(), m_objectStore->id(), id(), keyRange, direction, true, WebIDBTaskTypeNormal, WebIDBCallbacksImpl::create(request).release());
return request;
}
@@ -268,7 +268,7 @@ IDBRequest* IDBIndex::getInternal(ScriptState* scriptState, const ScriptValue& k
}
IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
- backendDB()->get(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, keyOnly, WebIDBCallbacksImpl::create(request).release());
+ backendDB()->get(m_transaction->id(), m_objectStore->id(), id(), keyRange, keyOnly, WebIDBCallbacksImpl::create(request).release());
return request;
}
@@ -299,7 +299,7 @@ IDBRequest* IDBIndex::getAllInternal(ScriptState* scriptState, const ScriptValue
}
IDBRequest* request = IDBRequest::create(scriptState, IDBAny::create(this), m_transaction.get());
- backendDB()->getAll(m_transaction->id(), m_objectStore->id(), m_metadata.id, keyRange, maxCount, keyOnly, WebIDBCallbacksImpl::create(request).release());
+ backendDB()->getAll(m_transaction->id(), m_objectStore->id(), id(), keyRange, maxCount, keyOnly, WebIDBCallbacksImpl::create(request).release());
return request;
}

Powered by Google App Engine
This is Rietveld 408576698