OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef COMPONENTS_LEVELDB_PUBLIC_CPP_UTIL_H_ | 5 #ifndef COMPONENTS_LEVELDB_PUBLIC_CPP_UTIL_H_ |
6 #define COMPONENTS_LEVELDB_PUBLIC_CPP_UTIL_H_ | 6 #define COMPONENTS_LEVELDB_PUBLIC_CPP_UTIL_H_ |
7 | 7 |
8 #include "components/leveldb/public/interfaces/leveldb.mojom.h" | 8 #include "components/leveldb/public/interfaces/leveldb.mojom.h" |
| 9 #include "third_party/leveldatabase/env_chromium.h" |
9 | 10 |
10 namespace leveldb { | 11 namespace leveldb { |
11 | 12 |
12 class Slice; | 13 class Slice; |
13 class Status; | 14 class Status; |
14 | 15 |
15 // Builds a mojo mojom::DatabaseError from a leveldb::Status object. | 16 // Builds a mojo mojom::DatabaseError from a leveldb::Status object. |
16 mojom::DatabaseError LeveldbStatusToError(const leveldb::Status& s); | 17 mojom::DatabaseError LeveldbStatusToError(const leveldb::Status& s); |
17 | 18 |
18 // Creates a leveldb Status object form a database error and two optional | 19 // Creates a leveldb Status object form a database error and two optional |
19 // messages. A mojoification of the various static leveldb::Status | 20 // messages. A mojoification of the various static leveldb::Status |
20 // constructors. | 21 // constructors. |
21 leveldb::Status DatabaseErrorToStatus(mojom::DatabaseError e, | 22 leveldb::Status DatabaseErrorToStatus(mojom::DatabaseError e, |
22 const Slice& msg, | 23 const Slice& msg, |
23 const Slice& msg2); | 24 const Slice& msg2); |
24 | 25 |
25 // Returns an UMA value for a mojom::DatabaseError. | 26 // Returns an UMA value for a mojom::DatabaseError. |
26 int GetLevelDBStatusUMAValue(mojom::DatabaseError status); | 27 leveldb_env::LevelDBStatusValue GetLevelDBStatusUMAValue( |
| 28 mojom::DatabaseError status); |
27 | 29 |
28 // Builds a Slice pointing to the data inside |a|. This is not a type-converter | 30 // Builds a Slice pointing to the data inside |a|. This is not a type-converter |
29 // as it is not a copy operation; the returned Slice points into |a| and must | 31 // as it is not a copy operation; the returned Slice points into |a| and must |
30 // outlive |a|. | 32 // outlive |a|. |
31 leveldb::Slice GetSliceFor(const std::vector<uint8_t>& a); | 33 leveldb::Slice GetSliceFor(const std::vector<uint8_t>& a); |
32 | 34 |
33 // Copies the data that |s| points to into a std::vector. | 35 // Copies the data that |s| points to into a std::vector. |
34 std::vector<uint8_t> GetVectorFor(const leveldb::Slice& s); | 36 std::vector<uint8_t> GetVectorFor(const leveldb::Slice& s); |
35 | 37 |
36 std::string Uint8VectorToStdString(const std::vector<uint8_t>& input); | 38 std::string Uint8VectorToStdString(const std::vector<uint8_t>& input); |
37 | 39 |
38 std::vector<uint8_t> StdStringToUint8Vector(const std::string& input); | 40 std::vector<uint8_t> StdStringToUint8Vector(const std::string& input); |
39 | 41 |
40 } // namespace leveldb | 42 } // namespace leveldb |
41 | 43 |
42 #endif // COMPONENTS_LEVELDB_PUBLIC_CPP_UTIL_H_ | 44 #endif // COMPONENTS_LEVELDB_PUBLIC_CPP_UTIL_H_ |
OLD | NEW |