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

Unified Diff: content/browser/indexed_db/leveldb/leveldb_slice.h

Issue 16256014: IndexedDB: Convert decoding functions to pass StringPieces vs. pointers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 7 years, 7 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
Index: content/browser/indexed_db/leveldb/leveldb_slice.h
diff --git a/content/browser/indexed_db/leveldb/leveldb_slice.h b/content/browser/indexed_db/leveldb/leveldb_slice.h
index 302c0b6b8ca47a0e51127fc0ed638dde4eabbf6e..e9c472779fbc6f9176df87069c24193abb21523b 100644
--- a/content/browser/indexed_db/leveldb/leveldb_slice.h
+++ b/content/browser/indexed_db/leveldb/leveldb_slice.h
@@ -8,6 +8,7 @@
#include <vector>
#include "base/logging.h"
+#include "base/strings/string_piece.h"
namespace content {
@@ -22,10 +23,20 @@ class LevelDBSlice {
DCHECK_GE(end_, begin_);
}
+ explicit LevelDBSlice(const std::string& v)
+ : begin_(v.data()), end_(v.data() + v.size()) {
+ DCHECK_GE(end_, begin_);
+ }
+
~LevelDBSlice() {}
const char* begin() const { return begin_; }
const char* end() const { return end_; }
+ size_t size() const { return end_ - begin_; }
+
+ operator base::StringPiece() const {
alecflett 2013/06/03 21:22:53 I wish there was an easy way to make this explicit
jsbell 2013/06/03 21:37:09 This is just used when initializing a StringPiece
+ return base::StringPiece(begin_, end_ - begin_);
+ }
private:
const char* begin_;

Powered by Google App Engine
This is Rietveld 408576698