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

Side by Side Diff: content/browser/indexed_db/leveldb/leveldb_slice.h

Issue 18075008: IndexedDB: Switch key/value handling from vector<char> to std::string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove C++11ism Created 7 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_SLICE_H_
6 #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_SLICE_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/logging.h"
12 #include "base/strings/string_piece.h"
13
14 namespace content {
15
16 class LevelDBSlice {
17 public:
18 LevelDBSlice(const char* begin, const char* end) : begin_(begin), end_(end) {
19 DCHECK_GE(end_, begin_);
20 }
21
22 explicit LevelDBSlice(const std::vector<char>& v)
23 : begin_(v.empty() ? NULL : &*v.begin()), end_(begin_ + v.size()) {
24 DCHECK_GE(end_, begin_);
25 }
26
27 explicit LevelDBSlice(const std::string& v)
28 : begin_(v.data()), end_(v.data() + v.size()) {
29 DCHECK_GE(end_, begin_);
30 }
31
32 ~LevelDBSlice() {}
33
34 const char* begin() const { return begin_; }
35 const char* end() const { return end_; }
36
37 base::StringPiece AsStringPiece() const {
38 return base::StringPiece(begin_, end_ - begin_);
39 }
40
41 private:
42 const char* begin_;
43 const char* end_;
44 };
45
46 } // namespace content
47
48 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_SLICE_H_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/leveldb/leveldb_iterator.h ('k') | content/browser/indexed_db/leveldb/leveldb_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698