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

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

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

Powered by Google App Engine
This is Rietveld 408576698