1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved.
2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file.
4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_WRITE_BATCH_H_
6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_WRITE_BATCH_H_
7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
97dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include "base/strings/string_piece.h"
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace leveldb {
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class WriteBatch;
13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content {
16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Wrapper around leveldb::WriteBatch.
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// This class holds a collection of updates to apply atomically to a database.
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class LevelDBWriteBatch {
20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public:
21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  static scoped_ptr<LevelDBWriteBatch> Create();
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  ~LevelDBWriteBatch();
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
247dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  void Put(const base::StringPiece& key, const base::StringPiece& value);
257dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch  void Remove(const base::StringPiece& key);  // Add remove operation to the
267dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch                                              // batch.
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  void Clear();
28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private:
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  friend class LevelDBDatabase;
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  LevelDBWriteBatch();
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_ptr<leveldb::WriteBatch> write_batch_;
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)};
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}  // namespace content
37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif  // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_WRITE_BATCH_H_
39