diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-08 00:10:51 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-08 00:10:51 +0000 |
commit | 45d2a8a014f1a36c710ced424fcf83c2900827d8 (patch) | |
tree | ca60e2227c68a1c662dfe218629c1638b61dde6a /chrome/browser/autofill/autofill_scanner.cc | |
parent | e9832c0aa2567a84f5a49d120b7ed9acff39ed47 (diff) | |
download | chromium_src-45d2a8a014f1a36c710ced424fcf83c2900827d8.zip chromium_src-45d2a8a014f1a36c710ced424fcf83c2900827d8.tar.gz chromium_src-45d2a8a014f1a36c710ced424fcf83c2900827d8.tar.bz2 |
Simplify Autofill Scanner semantics
SaveCursor() no longer provides stack semantics. Instead, it only saves the most recent cursor position.
Clients who want to save multiple cursors can now capture the result of SaveCursor() and later explicitly RewindTo() saved positions.
BUG=85142
TEST=unit_tests --gtest_filter=Autofill*:CreditCard*:FormField*
Review URL: http://codereview.chromium.org/7120005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@88243 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill/autofill_scanner.cc')
-rw-r--r-- | chrome/browser/autofill/autofill_scanner.cc | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/chrome/browser/autofill/autofill_scanner.cc b/chrome/browser/autofill/autofill_scanner.cc index 1fd8a7e..41aadc8 100644 --- a/chrome/browser/autofill/autofill_scanner.cc +++ b/chrome/browser/autofill/autofill_scanner.cc @@ -10,6 +10,8 @@ AutofillScanner::AutofillScanner( const std::vector<const AutofillField*>& fields) : cursor_(fields.begin()), + saved_cursor_(fields.begin()), + begin_(fields.begin()), end_(fields.end()) { } @@ -35,11 +37,18 @@ bool AutofillScanner::IsEnd() const { } void AutofillScanner::Rewind() { - DCHECK(!saved_cursors_.empty()); - cursor_ = saved_cursors_.back(); - saved_cursors_.pop_back(); + DCHECK(saved_cursor_ != end_); + cursor_ = saved_cursor_; + saved_cursor_ = end_; } -void AutofillScanner::SaveCursor() { - saved_cursors_.push_back(cursor_); +void AutofillScanner::RewindTo(size_t index) { + DCHECK(index < static_cast<size_t>(end_ - begin_)); + cursor_ = begin_ + index; + saved_cursor_ = end_; +} + +size_t AutofillScanner::SaveCursor() { + saved_cursor_ = cursor_; + return static_cast<size_t>(cursor_ - begin_); } |