Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / content / browser / indexed_db / indexed_db_fake_backing_store.h
blob652b65eb7eb354a07ac7ed48997617066a25fca3
1 // Copyright 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.
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_
8 #include <vector>
10 #include "content/browser/indexed_db/indexed_db_backing_store.h"
12 namespace base {
13 class SequencedTaskRunner;
16 namespace content {
18 class IndexedDBFactory;
20 class IndexedDBFakeBackingStore : public IndexedDBBackingStore {
21 public:
22 IndexedDBFakeBackingStore();
23 IndexedDBFakeBackingStore(IndexedDBFactory* factory,
24 base::SequencedTaskRunner* task_runner);
25 virtual std::vector<base::string16> GetDatabaseNames(leveldb::Status* s)
26 OVERRIDE;
27 virtual leveldb::Status GetIDBDatabaseMetaData(const base::string16& name,
28 IndexedDBDatabaseMetadata*,
29 bool* found) OVERRIDE;
30 virtual leveldb::Status CreateIDBDatabaseMetaData(
31 const base::string16& name,
32 const base::string16& version,
33 int64 int_version,
34 int64* row_id) OVERRIDE;
35 virtual bool UpdateIDBDatabaseIntVersion(Transaction*,
36 int64 row_id,
37 int64 version) OVERRIDE;
38 virtual leveldb::Status DeleteDatabase(const base::string16& name) OVERRIDE;
40 virtual leveldb::Status CreateObjectStore(Transaction*,
41 int64 database_id,
42 int64 object_store_id,
43 const base::string16& name,
44 const IndexedDBKeyPath&,
45 bool auto_increment) OVERRIDE;
47 virtual leveldb::Status DeleteObjectStore(Transaction* transaction,
48 int64 database_id,
49 int64 object_store_id) OVERRIDE;
51 virtual leveldb::Status PutRecord(
52 IndexedDBBackingStore::Transaction* transaction,
53 int64 database_id,
54 int64 object_store_id,
55 const IndexedDBKey& key,
56 IndexedDBValue* value,
57 ScopedVector<storage::BlobDataHandle>* handles,
58 RecordIdentifier* record) OVERRIDE;
60 virtual leveldb::Status ClearObjectStore(Transaction*,
61 int64 database_id,
62 int64 object_store_id) OVERRIDE;
63 virtual leveldb::Status DeleteRecord(Transaction*,
64 int64 database_id,
65 int64 object_store_id,
66 const RecordIdentifier&) OVERRIDE;
67 virtual leveldb::Status GetKeyGeneratorCurrentNumber(Transaction*,
68 int64 database_id,
69 int64 object_store_id,
70 int64* current_number)
71 OVERRIDE;
72 virtual leveldb::Status MaybeUpdateKeyGeneratorCurrentNumber(
73 Transaction*,
74 int64 database_id,
75 int64 object_store_id,
76 int64 new_number,
77 bool check_current) OVERRIDE;
78 virtual leveldb::Status KeyExistsInObjectStore(
79 Transaction*,
80 int64 database_id,
81 int64 object_store_id,
82 const IndexedDBKey&,
83 RecordIdentifier* found_record_identifier,
84 bool* found) OVERRIDE;
86 virtual leveldb::Status CreateIndex(Transaction*,
87 int64 database_id,
88 int64 object_store_id,
89 int64 index_id,
90 const base::string16& name,
91 const IndexedDBKeyPath&,
92 bool is_unique,
93 bool is_multi_entry) OVERRIDE;
94 virtual leveldb::Status DeleteIndex(Transaction*,
95 int64 database_id,
96 int64 object_store_id,
97 int64 index_id) OVERRIDE;
98 virtual leveldb::Status PutIndexDataForRecord(Transaction*,
99 int64 database_id,
100 int64 object_store_id,
101 int64 index_id,
102 const IndexedDBKey&,
103 const RecordIdentifier&)
104 OVERRIDE;
105 virtual void ReportBlobUnused(int64 database_id, int64 blob_key) OVERRIDE;
106 virtual scoped_ptr<Cursor> OpenObjectStoreKeyCursor(
107 Transaction* transaction,
108 int64 database_id,
109 int64 object_store_id,
110 const IndexedDBKeyRange& key_range,
111 blink::WebIDBCursorDirection,
112 leveldb::Status*) OVERRIDE;
113 virtual scoped_ptr<Cursor> OpenObjectStoreCursor(
114 Transaction* transaction,
115 int64 database_id,
116 int64 object_store_id,
117 const IndexedDBKeyRange& key_range,
118 blink::WebIDBCursorDirection,
119 leveldb::Status*) OVERRIDE;
120 virtual scoped_ptr<Cursor> OpenIndexKeyCursor(
121 Transaction* transaction,
122 int64 database_id,
123 int64 object_store_id,
124 int64 index_id,
125 const IndexedDBKeyRange& key_range,
126 blink::WebIDBCursorDirection,
127 leveldb::Status*) OVERRIDE;
128 virtual scoped_ptr<Cursor> OpenIndexCursor(Transaction* transaction,
129 int64 database_id,
130 int64 object_store_id,
131 int64 index_id,
132 const IndexedDBKeyRange& key_range,
133 blink::WebIDBCursorDirection,
134 leveldb::Status*) OVERRIDE;
136 class FakeTransaction : public IndexedDBBackingStore::Transaction {
137 public:
138 explicit FakeTransaction(leveldb::Status phase_two_result);
139 virtual void Begin() OVERRIDE;
140 virtual leveldb::Status CommitPhaseOne(
141 scoped_refptr<BlobWriteCallback>) OVERRIDE;
142 virtual leveldb::Status CommitPhaseTwo() OVERRIDE;
143 virtual void Rollback() OVERRIDE;
145 private:
146 leveldb::Status result_;
148 DISALLOW_COPY_AND_ASSIGN(FakeTransaction);
151 protected:
152 friend class base::RefCounted<IndexedDBFakeBackingStore>;
153 virtual ~IndexedDBFakeBackingStore();
155 private:
156 DISALLOW_COPY_AND_ASSIGN(IndexedDBFakeBackingStore);
159 } // namespace content
161 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_