| 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" |
| 6 |
| 7 #include <utility> |
| 8 |
| 5 #include "base/logging.h" | 9 #include "base/logging.h" |
| 6 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 7 #include "content/browser/indexed_db/leveldb/leveldb_iterator_impl.h" | |
| 8 | 11 |
| 9 static leveldb::Slice MakeSlice(const base::StringPiece& s) { | 12 static leveldb::Slice MakeSlice(const base::StringPiece& s) { |
| 10 return leveldb::Slice(s.begin(), s.size()); | 13 return leveldb::Slice(s.begin(), s.size()); |
| 11 } | 14 } |
| 12 | 15 |
| 13 static base::StringPiece MakeStringPiece(const leveldb::Slice& s) { | 16 static base::StringPiece MakeStringPiece(const leveldb::Slice& s) { |
| 14 return base::StringPiece(s.data(), s.size()); | 17 return base::StringPiece(s.data(), s.size()); |
| 15 } | 18 } |
| 16 | 19 |
| 17 namespace content { | 20 namespace content { |
| 18 | 21 |
| 19 LevelDBIteratorImpl::~LevelDBIteratorImpl() { | 22 LevelDBIteratorImpl::~LevelDBIteratorImpl() { |
| 20 } | 23 } |
| 21 | 24 |
| 22 LevelDBIteratorImpl::LevelDBIteratorImpl(scoped_ptr<leveldb::Iterator> it) | 25 LevelDBIteratorImpl::LevelDBIteratorImpl(scoped_ptr<leveldb::Iterator> it) |
| 23 : iterator_(it.Pass()) { | 26 : iterator_(std::move(it)) {} |
| 24 } | |
| 25 | 27 |
| 26 void LevelDBIteratorImpl::CheckStatus() { | 28 void LevelDBIteratorImpl::CheckStatus() { |
| 27 const leveldb::Status& s = iterator_->status(); | 29 const leveldb::Status& s = iterator_->status(); |
| 28 if (!s.ok()) | 30 if (!s.ok()) |
| 29 LOG(ERROR) << "LevelDB iterator error: " << s.ToString(); | 31 LOG(ERROR) << "LevelDB iterator error: " << s.ToString(); |
| 30 } | 32 } |
| 31 | 33 |
| 32 bool LevelDBIteratorImpl::IsValid() const { | 34 bool LevelDBIteratorImpl::IsValid() const { |
| 33 return iterator_->Valid(); | 35 return iterator_->Valid(); |
| 34 } | 36 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 63 DCHECK(IsValid()); | 65 DCHECK(IsValid()); |
| 64 return MakeStringPiece(iterator_->key()); | 66 return MakeStringPiece(iterator_->key()); |
| 65 } | 67 } |
| 66 | 68 |
| 67 base::StringPiece LevelDBIteratorImpl::Value() const { | 69 base::StringPiece LevelDBIteratorImpl::Value() const { |
| 68 DCHECK(IsValid()); | 70 DCHECK(IsValid()); |
| 69 return MakeStringPiece(iterator_->value()); | 71 return MakeStringPiece(iterator_->value()); |
| 70 } | 72 } |
| 71 | 73 |
| 72 } // namespace content | 74 } // namespace content |
| OLD | NEW |