Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: components/leveldb/public/cpp/util.cc

Issue 2285623002: [Leveldb] Use std::{string,vector} instead of mojo::{String,Array}. (Closed)
Patch Set: Address comments from Yuzhu Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/leveldb/public/cpp/util.h ('k') | components/leveldb/public/interfaces/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/leveldb/public/cpp/util.cc
diff --git a/components/leveldb/public/cpp/util.cc b/components/leveldb/public/cpp/util.cc
index 647f12c0d80f25eb26105acdb7c27c117b453d25..d2dd6a60ce7566c6ff4e1ef0b65546fe67147b0a 100644
--- a/components/leveldb/public/cpp/util.cc
+++ b/components/leveldb/public/cpp/util.cc
@@ -45,19 +45,28 @@ leveldb::Status DatabaseErrorToStatus(mojom::DatabaseError e,
return leveldb::Status::InvalidArgument(msg, msg2);
}
-leveldb::Slice GetSliceFor(const mojo::Array<uint8_t>& key) {
+leveldb::Slice GetSliceFor(const std::vector<uint8_t>& key) {
if (key.size() == 0)
return leveldb::Slice();
return leveldb::Slice(reinterpret_cast<const char*>(&key.front()),
key.size());
}
-mojo::Array<uint8_t> GetArrayFor(const leveldb::Slice& s) {
+std::vector<uint8_t> GetVectorFor(const leveldb::Slice& s) {
if (s.size() == 0)
- return mojo::Array<uint8_t>();
- return mojo::Array<uint8_t>(std::vector<uint8_t>(
+ return std::vector<uint8_t>();
+ return std::vector<uint8_t>(
reinterpret_cast<const uint8_t*>(s.data()),
- reinterpret_cast<const uint8_t*>(s.data() + s.size())));
+ reinterpret_cast<const uint8_t*>(s.data() + s.size()));
+}
+
+std::string Uint8VectorToStdString(const std::vector<uint8_t>& input) {
+ return std::string(reinterpret_cast<const char*>(input.data()), input.size());
+}
+
+std::vector<uint8_t> StdStringToUint8Vector(const std::string& input) {
+ const uint8_t* data = reinterpret_cast<const uint8_t*>(input.data());
+ return std::vector<uint8_t>(data, data + input.size());
}
} // namespace leveldb
« no previous file with comments | « components/leveldb/public/cpp/util.h ('k') | components/leveldb/public/interfaces/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698