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

Unified Diff: content/browser/indexed_db/leveldb/leveldb_write_batch.cc

Issue 15564008: Migrate the IndexedDB backend from Blink to Chromium (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Accessor naming, use LevelDBSlice ctor explicitly 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_write_batch.cc
diff --git a/content/browser/indexed_db/leveldb/leveldb_write_batch.cc b/content/browser/indexed_db/leveldb/leveldb_write_batch.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b15c4faeb26925877dbe9fd4f733b21d43dc993d
--- /dev/null
+++ b/content/browser/indexed_db/leveldb/leveldb_write_batch.cc
@@ -0,0 +1,37 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/indexed_db/leveldb/leveldb_write_batch.h"
+
+#include "content/browser/indexed_db/leveldb/leveldb_slice.h"
+#include "third_party/leveldatabase/src/include/leveldb/slice.h"
+#include "third_party/leveldatabase/src/include/leveldb/write_batch.h"
+
+namespace content {
+
+scoped_ptr<LevelDBWriteBatch> LevelDBWriteBatch::Create() {
+ return make_scoped_ptr(new LevelDBWriteBatch);
+}
+
+LevelDBWriteBatch::LevelDBWriteBatch()
+ : write_batch_(new leveldb::WriteBatch) {}
+
+LevelDBWriteBatch::~LevelDBWriteBatch() {}
+
+static leveldb::Slice MakeSlice(const LevelDBSlice& s) {
+ return leveldb::Slice(s.begin(), s.end() - s.begin());
+}
+
+void LevelDBWriteBatch::Put(const LevelDBSlice& key,
+ const LevelDBSlice& value) {
+ write_batch_->Put(MakeSlice(key), MakeSlice(value));
+}
+
+void LevelDBWriteBatch::Remove(const LevelDBSlice& key) {
+ write_batch_->Delete(MakeSlice(key));
+}
+
+void LevelDBWriteBatch::Clear() { write_batch_->Clear(); }
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698