Indexed DB: Simplify cursor iteration logic
commit1f54336fed5113fc440658d2a8465ae7a4d9a02c
authorjsbell <jsbell@chromium.org>
Wed, 10 Jun 2015 20:09:07 +0000 (10 13:09 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 10 Jun 2015 20:09:40 +0000 (10 20:09 +0000)
treee94bc4a1eab30b2e3003c4e18668cb19259ba8c6
parentf84c62613ac15c2d1672c8298691c448005d35a0
Indexed DB: Simplify cursor iteration logic

The internal logic for cursor iteration in Continue()
needs to handle four cases: "next", "nextunique", "prev",
"prevunique". This was handled in a single function with a
single loop and hairy `if (forwards) {} else {}` and `if
(unique) {}` clauses, which made understanding and
extending it difficult.

This CL splits the function into two cases: ContinueNext()
for "next"/"nextunique" cursors and ContinuePrevious() for
"prev"/"prevunique" cursors, which greatly simplifies the
logic for each.

The "prevunique" case is particularly complex, since the
spec requires that the first duplicate (in index order) is
returned rather than the last (the one encountered first
when iterating backwards). This was previously done by
iterating further then reversing, all within the same
loop. Now, this case is handled by a subsequent loop.

BUG=497454
R=cmumford@chromium.org

Review URL: https://codereview.chromium.org/1170833004

Cr-Commit-Position: refs/heads/master@{#333780}
content/browser/indexed_db/indexed_db_backing_store.cc
content/browser/indexed_db/indexed_db_backing_store.h