Bug 69131 - Return null for the value of IDB key cursors
Summary: Return null for the value of IDB key cursors
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Grogan
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-29 23:58 PDT by David Grogan
Modified: 2011-10-06 16:57 PDT (History)
4 users (show)

See Also:


Attachments
Patch (1.49 KB, patch)
2011-09-30 00:00 PDT, David Grogan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Grogan 2011-09-29 23:58:24 PDT
Return null for the value of IDB key cursors
Comment 1 David Grogan 2011-09-30 00:00:54 PDT
Created attachment 109259 [details]
Patch
Comment 2 David Grogan 2011-09-30 00:04:51 PDT
This is the webkit patch in support of http://codereview.chromium.org/7834006

Michael and/or Hans, could you take a look?
Comment 3 Hans Wennborg 2011-10-03 04:00:35 PDT
Comment on attachment 109259 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=109259&action=review

> Source/WebCore/storage/IDBCursorBackendImpl.cpp:-76
> -    ASSERT(m_cursorType != IndexKeyCursor);

i'm not sure I'm following... if the cursor is an IndexKeyCursor, this shouldn't be called, because such cursors don't have a value
Comment 4 Michael Nordman 2011-10-03 09:40:11 PDT
lgtm (fwiw)

You have to look at the chrome CL to fully understand this webkit patch. When a cursor is created or stepped, the value is retrieved and sent to the renderer w/o regard for the cursorType. The branch to return null for IndexKeyCursor type has to be somewhere. IDBCursorBackendImpl.cpp is a fine place for that branch.

http://codereview.chromium.org/7834006/diff/13001/content/browser/in_process_webkit/indexed_db_callbacks.cc

+  dispatcher_host()->Send(new IndexedDBMsg_CallbacksSuccessIDBCursor(
+      response_id(), object_id, IndexedDBKey(idb_object->key()),
+      IndexedDBKey(idb_object->primaryKey()),
+      SerializedScriptValue(idb_object->value())));


Notice there is no 'type' getter on WebIDBCursor. In the current design (where chrome doesn't have much insight into these datatypes) there doesn't need to be.

class WebIDBCursor {
public:
    virtual ~WebIDBCursor() { }

    virtual unsigned short direction() const
    {
        WEBKIT_ASSERT_NOT_REACHED();
        return 0;
    }
    virtual WebIDBKey key() const
    {
        WEBKIT_ASSERT_NOT_REACHED();
        return WebIDBKey::createInvalid();
    }
    virtual WebIDBKey primaryKey() const
    {
        WEBKIT_ASSERT_NOT_REACHED();
        return WebIDBKey::createInvalid();
    }
    virtual WebSerializedScriptValue value() const
    {
        WEBKIT_ASSERT_NOT_REACHED();
        return WebSerializedScriptValue();
    }

    virtual void update(const WebSerializedScriptValue&, WebIDBCallbacks*, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); }
    virtual void continueFunction(const WebIDBKey&, WebIDBCallbacks*, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); }
    virtual void deleteFunction(WebIDBCallbacks* callbacks, WebExceptionCode& ec) { WEBKIT_ASSERT_NOT_REACHED(); }

protected:
    WebIDBCursor() { }
};
Comment 5 David Grogan 2011-10-03 13:55:39 PDT
Tony, could you review this two-line patch?
Comment 6 David Grogan 2011-10-05 14:09:26 PDT
ping tc

Sorry for the flood of IDB patches lately.  Let me/us know if you need a break from them.
Comment 7 Tony Chang 2011-10-05 14:12:38 PDT
Comment on attachment 109259 [details]
Patch

Can we add a layout test for this?
Comment 8 David Grogan 2011-10-06 14:58:53 PDT
(In reply to comment #7)
> (From update of attachment 109259 [details])
> Can we add a layout test for this?

I don't think so.  DRT won't be able to exercise this code path - there's no javascript API to get the value of a key cursor.  It's only called by WebIDBCursorImpl (which is called by IndexedDBCallbacks in content/browser/in_process_webkit/indexed_db_callbacks.cc)
Comment 9 WebKit Review Bot 2011-10-06 16:57:18 PDT
Comment on attachment 109259 [details]
Patch

Clearing flags on attachment: 109259

Committed r96877: <http://trac.webkit.org/changeset/96877>
Comment 10 WebKit Review Bot 2011-10-06 16:57:22 PDT
All reviewed patches have been landed.  Closing bug.