Chromium Code Reviews| 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 DCHECK(iterator_); | |
|
cmumford
2017/03/29 17:00:20
nit: Suggest removing the DCHECK because the progr
dmurph
2017/03/29 18:07:17
Done.
| |
| 48 return iterator_->Valid(); | |
| 49 default: | |
| 50 NOTREACHED(); | |
|
cmumford
2017/03/29 17:00:20
Remove the default because the compile will fail i
dmurph
2017/03/29 18:07:17
Done.
| |
| 51 return false; | |
| 52 } | |
| 43 } | 53 } |
| 44 | 54 |
| 45 leveldb::Status LevelDBIteratorImpl::SeekToLast() { | 55 leveldb::Status LevelDBIteratorImpl::SeekToLast() { |
| 46 WillUseDBIterator(); | 56 WillUseDBIterator(); |
| 47 DCHECK(iterator_); | 57 DCHECK(iterator_); |
| 48 iterator_->SeekToLast(); | 58 iterator_->SeekToLast(); |
| 49 return CheckStatus(); | 59 return CheckStatus(); |
| 50 } | 60 } |
| 51 | 61 |
| 52 leveldb::Status LevelDBIteratorImpl::Seek(const base::StringPiece& target) { | 62 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_); | 123 iterator_->Seek(key_before_eviction_); |
| 114 key_before_eviction_.clear(); | 124 key_before_eviction_.clear(); |
| 115 DCHECK(IsValid()); | 125 DCHECK(IsValid()); |
| 116 } else { | 126 } else { |
| 117 DCHECK(!iterator_->Valid()); | 127 DCHECK(!iterator_->Valid()); |
| 118 } | 128 } |
| 119 iterator_state_ = IteratorState::ACTIVE; | 129 iterator_state_ = IteratorState::ACTIVE; |
| 120 } | 130 } |
| 121 | 131 |
| 122 } // namespace content | 132 } // namespace content |
| OLD | NEW |