| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" | 5 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 | 31 |
| 32 leveldb::Status LevelDBIteratorImpl::CheckStatus() { | 32 leveldb::Status LevelDBIteratorImpl::CheckStatus() { |
| 33 DCHECK(!IsDetached()); | 33 DCHECK(!IsDetached()); |
| 34 const leveldb::Status& s = iterator_->status(); | 34 const leveldb::Status& s = iterator_->status(); |
| 35 if (!s.ok()) | 35 if (!s.ok()) |
| 36 LOG(ERROR) << "LevelDB iterator error: " << s.ToString(); | 36 LOG(ERROR) << "LevelDB iterator error: " << s.ToString(); |
| 37 return s; | 37 return s; |
| 38 } | 38 } |
| 39 | 39 |
| 40 bool LevelDBIteratorImpl::IsValid() const { | 40 bool LevelDBIteratorImpl::IsValid() const { |
| 41 return iterator_state_ == IteratorState::EVICTED_AND_VALID || | 41 switch (iterator_state_) { |
| 42 iterator_->Valid(); | 42 case IteratorState::EVICTED_AND_VALID: |
| 43 return true; |
| 44 case IteratorState::EVICTED_AND_INVALID: |
| 45 return false; |
| 46 case IteratorState::ACTIVE: |
| 47 return iterator_->Valid(); |
| 48 } |
| 49 NOTREACHED(); |
| 50 return false; |
| 43 } | 51 } |
| 44 | 52 |
| 45 leveldb::Status LevelDBIteratorImpl::SeekToLast() { | 53 leveldb::Status LevelDBIteratorImpl::SeekToLast() { |
| 46 WillUseDBIterator(); | 54 WillUseDBIterator(); |
| 47 DCHECK(iterator_); | 55 DCHECK(iterator_); |
| 48 iterator_->SeekToLast(); | 56 iterator_->SeekToLast(); |
| 49 return CheckStatus(); | 57 return CheckStatus(); |
| 50 } | 58 } |
| 51 | 59 |
| 52 leveldb::Status LevelDBIteratorImpl::Seek(const base::StringPiece& target) { | 60 leveldb::Status LevelDBIteratorImpl::Seek(const base::StringPiece& target) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 iterator_->Seek(key_before_eviction_); | 121 iterator_->Seek(key_before_eviction_); |
| 114 key_before_eviction_.clear(); | 122 key_before_eviction_.clear(); |
| 115 DCHECK(IsValid()); | 123 DCHECK(IsValid()); |
| 116 } else { | 124 } else { |
| 117 DCHECK(!iterator_->Valid()); | 125 DCHECK(!iterator_->Valid()); |
| 118 } | 126 } |
| 119 iterator_state_ = IteratorState::ACTIVE; | 127 iterator_state_ = IteratorState::ACTIVE; |
| 120 } | 128 } |
| 121 | 129 |
| 122 } // namespace content | 130 } // namespace content |
| OLD | NEW |