| OLD | NEW |
| (Empty) |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/leveldb/util.h" | |
| 6 | |
| 7 #include "third_party/leveldatabase/src/include/leveldb/status.h" | |
| 8 | |
| 9 namespace leveldb { | |
| 10 | |
| 11 DatabaseError LeveldbStatusToError(const leveldb::Status& s) { | |
| 12 if (s.ok()) | |
| 13 return DatabaseError::OK; | |
| 14 if (s.IsNotFound()) | |
| 15 return DatabaseError::NOT_FOUND; | |
| 16 if (s.IsCorruption()) | |
| 17 return DatabaseError::CORRUPTION; | |
| 18 if (s.IsNotSupportedError()) | |
| 19 return DatabaseError::NOT_SUPPORTED; | |
| 20 if (s.IsIOError()) | |
| 21 return DatabaseError::IO_ERROR; | |
| 22 return DatabaseError::INVALID_ARGUMENT; | |
| 23 } | |
| 24 | |
| 25 leveldb::Slice GetSliceFor(const mojo::Array<uint8_t>& key) { | |
| 26 if (key.size() == 0) | |
| 27 return leveldb::Slice(); | |
| 28 return leveldb::Slice(reinterpret_cast<const char*>(&key.front()), | |
| 29 key.size()); | |
| 30 } | |
| 31 | |
| 32 } // namespace leveldb | |
| OLD | NEW |