Commit 06404f4b authored by Abhijeet Kandalkar's avatar Abhijeet Kandalkar Committed by Commit Bot

Use new downcast helper for blink::IDBCursorWithValue

This CL has two goals,
  1. Use To<IDBCursorWithValue> and DynamicTo<IDBCursorWithValue> as new
   downcast helper
  2. Use IsA<IDBCursorWithValue>(element) in place of
   IsIDBCursorWithValue(element)

Bug: 891908
Change-Id: I495cfb89dabb4242f86fcbe62cf295afcf1eda10
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2019646Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Abhijeet Kandalkar <abhijeet@igalia.com>
Cr-Commit-Position: refs/heads/master@{#744589}
parent 13a53ffb
......@@ -59,8 +59,8 @@ IDBCursor* IDBAny::IdbCursor() const {
IDBCursorWithValue* IDBAny::IdbCursorWithValue() const {
DCHECK_EQ(type_, kIDBCursorWithValueType);
SECURITY_DCHECK(idb_cursor_->IsCursorWithValue());
return ToIDBCursorWithValue(idb_cursor_.Get());
SECURITY_DCHECK(IsA<IDBCursorWithValue>(idb_cursor_.Get()));
return To<IDBCursorWithValue>(idb_cursor_.Get());
}
IDBDatabase* IDBAny::IdbDatabase() const {
......@@ -93,8 +93,8 @@ IDBAny::IDBAny(DOMStringList* value)
: type_(kDOMStringListType), dom_string_list_(value) {}
IDBAny::IDBAny(IDBCursor* value)
: type_(value->IsCursorWithValue() ? kIDBCursorWithValueType
: kIDBCursorType),
: type_(IsA<IDBCursorWithValue>(value) ? kIDBCursorWithValueType
: kIDBCursorType),
idb_cursor_(value) {}
IDBAny::IDBAny(IDBDatabase* value)
......
......@@ -32,6 +32,7 @@
#include "third_party/blink/renderer/bindings/modules/v8/v8_idb_request.h"
#include "third_party/blink/renderer/modules/indexed_db_names.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_any.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_cursor_with_value.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_database.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_object_store.h"
#include "third_party/blink/renderer/modules/indexeddb/idb_tracing.h"
......@@ -41,6 +42,7 @@
#include "third_party/blink/renderer/platform/bindings/script_state.h"
#include "third_party/blink/renderer/platform/bindings/v8_private_property.h"
#include "third_party/blink/renderer/platform/heap/heap.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -392,7 +394,7 @@ ScriptValue IDBCursor::primaryKey(ScriptState* script_state) {
}
ScriptValue IDBCursor::value(ScriptState* script_state) {
DCHECK(IsCursorWithValue());
DCHECK(IsA<IDBCursorWithValue>(this));
IDBAny* value;
if (value_) {
......@@ -430,7 +432,7 @@ void IDBCursor::SetValueReady(std::unique_ptr<IDBKey> key,
got_value_ = true;
if (!IsCursorWithValue())
if (!IsA<IDBCursorWithValue>(this))
return;
value_dirty_ = true;
......
......@@ -31,6 +31,7 @@
#include "third_party/blink/renderer/modules/indexeddb/idb_cursor.h"
#include "third_party/blink/renderer/modules/indexeddb/indexed_db.h"
#include "third_party/blink/renderer/modules/indexeddb/web_idb_cursor.h"
#include "third_party/blink/renderer/platform/wtf/casting.h"
namespace blink {
......@@ -56,11 +57,12 @@ class IDBCursorWithValue final : public IDBCursor {
bool IsCursorWithValue() const override { return true; }
};
DEFINE_TYPE_CASTS(IDBCursorWithValue,
IDBCursor,
cursor,
cursor->IsCursorWithValue(),
cursor.IsCursorWithValue());
template <>
struct DowncastTraits<IDBCursorWithValue> {
static bool AllowFrom(const IDBCursor& cursor) {
return cursor.IsCursorWithValue();
}
};
} // namespace blink
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment