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

Side by Side Diff: content/browser/indexed_db/indexed_db_database_impl.h

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 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_INDEXED_DB_DATABASE_IMPL_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_IMPL_H_
7
8 #include <list>
9 #include <map>
10
11 #include "content/browser/indexed_db/indexed_db_callbacks_wrapper.h"
12 #include "content/browser/indexed_db/indexed_db_metadata.h"
13 #include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
14 #include "content/browser/indexed_db/list_set.h"
15
16 namespace content {
17
18 class IndexedDBBackingStore;
19 class IndexedDBDatabase;
20 class IndexedDBFactoryImpl;
21 class IndexedDBTransaction;
22
23 class IndexedDBDatabaseImpl : public IndexedDBDatabase {
24 public:
25 static scoped_refptr<IndexedDBDatabaseImpl> Create(
26 const string16& name,
27 IndexedDBBackingStore* database,
28 IndexedDBFactoryImpl*,
29 const string16& unique_identifier);
30 scoped_refptr<IndexedDBBackingStore> BackingStore() const;
31
32 static const int64_t InvalidId = 0;
33 int64_t id() const { return metadata_.id; }
34 void AddObjectStore(const IndexedDBObjectStoreMetadata&,
35 int64_t new_max_object_store_id);
36 void RemoveObjectStore(int64_t object_store_id);
37 void AddIndex(int64_t object_store_id,
38 const IndexedDBIndexMetadata&,
39 int64_t new_max_index_id);
40 void RemoveIndex(int64_t object_store_id, int64_t index_id);
41
42 void OpenConnection(scoped_refptr<IndexedDBCallbacksWrapper>,
43 scoped_refptr<IndexedDBDatabaseCallbacksWrapper>,
44 int64_t transaction_id,
45 int64_t version);
46 void DeleteDatabase(scoped_refptr<IndexedDBCallbacksWrapper>);
47 const IndexedDBDatabaseMetadata& metadata() const { return metadata_; }
48
49 // IndexedDBDatabase
50 virtual void CreateObjectStore(int64_t transaction_id,
51 int64_t object_store_id,
52 const string16& name,
53 const IndexedDBKeyPath&,
54 bool auto_increment) OVERRIDE;
55 virtual void DeleteObjectStore(int64_t transaction_id,
56 int64_t object_store_id) OVERRIDE;
57 virtual void CreateTransaction(
58 int64_t transaction_id,
59 scoped_refptr<IndexedDBDatabaseCallbacksWrapper>,
60 const std::vector<int64_t>& object_store_ids,
61 unsigned short mode) OVERRIDE;
62 virtual void Close(scoped_refptr<IndexedDBDatabaseCallbacksWrapper>) OVERRIDE;
63
64 virtual void Commit(int64_t transaction_id) OVERRIDE;
65 virtual void Abort(int64_t transaction_id) OVERRIDE;
66 virtual void Abort(int64_t transaction_id,
67 scoped_refptr<IndexedDBDatabaseError>) OVERRIDE;
68
69 virtual void CreateIndex(int64_t transaction_id,
70 int64_t object_store_id,
71 int64_t index_id,
72 const string16& name,
73 const IndexedDBKeyPath&,
74 bool unique,
75 bool multi_entry) OVERRIDE;
76 virtual void DeleteIndex(int64_t transaction_id,
77 int64_t object_store_id,
78 int64_t index_id) OVERRIDE;
79
80 IndexedDBTransactionCoordinator& transaction_coordinator() {
81 return transaction_coordinator_;
82 }
83
84 void TransactionStarted(IndexedDBTransaction*);
85 void TransactionFinished(IndexedDBTransaction*);
86 void TransactionFinishedAndCompleteFired(IndexedDBTransaction*);
87 void TransactionFinishedAndAbortFired(IndexedDBTransaction*);
88
89 virtual void Get(int64_t transaction_id,
90 int64_t object_store_id,
91 int64_t index_id,
92 scoped_ptr<IndexedDBKeyRange>,
93 bool key_only,
94 scoped_refptr<IndexedDBCallbacksWrapper>) OVERRIDE;
95 virtual void Put(int64_t transaction_id,
96 int64_t object_store_id,
97 std::vector<char>* value,
98 scoped_ptr<IndexedDBKey>,
99 PutMode,
100 scoped_refptr<IndexedDBCallbacksWrapper>,
101 const std::vector<int64_t>& index_ids,
102 const std::vector<IndexKeys>&) OVERRIDE;
103 virtual void SetIndexKeys(int64_t transaction_id,
104 int64_t object_store_id,
105 scoped_ptr<IndexedDBKey> primary_key,
106 const std::vector<int64_t>& index_ids,
107 const std::vector<IndexKeys>&) OVERRIDE;
108 virtual void SetIndexesReady(int64_t transaction_id,
109 int64_t object_store_id,
110 const std::vector<int64_t>& index_ids) OVERRIDE;
111 virtual void OpenCursor(int64_t transaction_id,
112 int64_t object_store_id,
113 int64_t index_id,
114 scoped_ptr<IndexedDBKeyRange>,
115 IndexedDB::CursorDirection,
116 bool key_only,
117 TaskType,
118 scoped_refptr<IndexedDBCallbacksWrapper>) OVERRIDE;
119 virtual void Count(int64_t transaction_id,
120 int64_t object_store_id,
121 int64_t index_id,
122 scoped_ptr<IndexedDBKeyRange>,
123 scoped_refptr<IndexedDBCallbacksWrapper>) OVERRIDE;
124 virtual void DeleteRange(int64_t transaction_id,
125 int64_t object_store_id,
126 scoped_ptr<IndexedDBKeyRange>,
127 scoped_refptr<IndexedDBCallbacksWrapper>) OVERRIDE;
128 virtual void Clear(int64_t transaction_id,
129 int64_t object_store_id,
130 scoped_refptr<IndexedDBCallbacksWrapper>) OVERRIDE;
131
132 private:
133 IndexedDBDatabaseImpl(const string16& name,
134 IndexedDBBackingStore* database,
135 IndexedDBFactoryImpl*,
136 const string16& unique_identifier);
137 virtual ~IndexedDBDatabaseImpl();
138
139 bool IsOpenConnectionBlocked() const;
140 bool OpenInternal();
141 void RunVersionChangeTransaction(
142 scoped_refptr<IndexedDBCallbacksWrapper>,
143 scoped_refptr<IndexedDBDatabaseCallbacksWrapper>,
144 int64_t transaction_id,
145 int64_t requested_version);
146 void RunVersionChangeTransactionFinal(
147 scoped_refptr<IndexedDBCallbacksWrapper>,
148 scoped_refptr<IndexedDBDatabaseCallbacksWrapper>,
149 int64_t transaction_id,
150 int64_t requested_version);
151 size_t ConnectionCount() const;
152 void ProcessPendingCalls();
153
154 bool IsDeleteDatabaseBlocked() const;
155 void DeleteDatabaseFinal(scoped_refptr<IndexedDBCallbacksWrapper>);
156
157 class VersionChangeOperation;
158
159 // When a "versionchange" transaction aborts, these restore the back-end
160 // object hierarchy.
161 class VersionChangeAbortOperation;
162
163 scoped_refptr<IndexedDBBackingStore> backing_store_;
164 IndexedDBDatabaseMetadata metadata_;
165
166 string16 identifier_;
167 // This might not need to be a scoped_refptr since the factory's lifetime is
168 // that of the page group, but it's better to be conservitive than sorry.
169 scoped_refptr<IndexedDBFactoryImpl> factory_;
170
171 IndexedDBTransactionCoordinator transaction_coordinator_;
172 IndexedDBTransaction* running_version_change_transaction_;
173
174 typedef std::map<int64_t, IndexedDBTransaction*> TransactionMap;
175 TransactionMap transactions_;
176
177 class PendingOpenCall;
178 typedef std::list<PendingOpenCall*> PendingOpenCallList;
179 PendingOpenCallList pending_open_calls_;
180 scoped_ptr<PendingOpenCall> pending_run_version_change_transaction_call_;
181 scoped_ptr<PendingOpenCall> pending_second_half_open_;
182
183 class PendingDeleteCall;
184 typedef std::list<PendingDeleteCall*> PendingDeleteCallList;
185 PendingDeleteCallList pending_delete_calls_;
186
187 typedef list_set<scoped_refptr<IndexedDBDatabaseCallbacksWrapper> >
188 DatabaseCallbacksSet;
189 DatabaseCallbacksSet database_callbacks_set_;
190
191 bool closing_connection_;
192 };
193
194 } // namespace content
195
196 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698