blob: 2e62aa84fb31c11f1dc090a75b00771bbbec24af [file] [log] [blame]
// 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.
#ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_WRITE_BATCH_H_
#define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_WRITE_BATCH_H_
#include <memory>
#include "base/strings/string_piece.h"
#include "content/common/content_export.h"
namespace leveldb {
class WriteBatch;
}
namespace content {
// Wrapper around leveldb::WriteBatch.
// This class holds a collection of updates to apply atomically to a database.
// TODO(dmurph): Remove this and just use a leveldb::WriteBatch.
class CONTENT_EXPORT LevelDBWriteBatch {
public:
static std::unique_ptr<LevelDBWriteBatch> Create();
~LevelDBWriteBatch();
void Put(const base::StringPiece& key, const base::StringPiece& value);
void Remove(const base::StringPiece& key);
void Clear();
private:
friend class TransactionalLevelDBDatabase;
LevelDBWriteBatch();
std::unique_ptr<leveldb::WriteBatch> write_batch_;
};
} // namespace content
#endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_WRITE_BATCH_H_