dom/indexedDB/ipc/IndexedDBChild.h

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:bea4aa3fe571
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #ifndef mozilla_dom_indexeddb_ipc_indexeddbchild_h__
6 #define mozilla_dom_indexeddb_ipc_indexeddbchild_h__
7
8 #include "mozilla/Attributes.h"
9 #include "mozilla/DebugOnly.h"
10
11 #include "mozilla/dom/indexedDB/IndexedDatabase.h"
12
13 #include "mozilla/dom/indexedDB/PIndexedDBChild.h"
14 #include "mozilla/dom/indexedDB/PIndexedDBCursorChild.h"
15 #include "mozilla/dom/indexedDB/PIndexedDBDatabaseChild.h"
16 #include "mozilla/dom/indexedDB/PIndexedDBDeleteDatabaseRequestChild.h"
17 #include "mozilla/dom/indexedDB/PIndexedDBIndexChild.h"
18 #include "mozilla/dom/indexedDB/PIndexedDBObjectStoreChild.h"
19 #include "mozilla/dom/indexedDB/PIndexedDBRequestChild.h"
20 #include "mozilla/dom/indexedDB/PIndexedDBTransactionChild.h"
21
22 BEGIN_INDEXEDDB_NAMESPACE
23
24 class AsyncConnectionHelper;
25 class IDBCursor;
26 class IDBFactory;
27 class IDBIndex;
28 class IDBOpenDBRequest;
29 class IDBRequest;
30 class IDBTransactionListener;
31
32 /*******************************************************************************
33 * IndexedDBChild
34 ******************************************************************************/
35
36 class IndexedDBChild : public PIndexedDBChild
37 {
38 IDBFactory* mFactory;
39 nsCString mASCIIOrigin;
40
41 #ifdef DEBUG
42 bool mDisconnected;
43 #endif
44
45 public:
46 IndexedDBChild(const nsCString& aASCIIOrigin);
47 virtual ~IndexedDBChild();
48
49 const nsCString&
50 ASCIIOrigin() const
51 {
52 return mASCIIOrigin;
53 }
54
55 void
56 SetFactory(IDBFactory* aFactory);
57
58 void
59 Disconnect();
60
61 protected:
62 virtual void
63 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
64
65 virtual PIndexedDBDatabaseChild*
66 AllocPIndexedDBDatabaseChild(const nsString& aName, const uint64_t& aVersion,
67 const PersistenceType& aPersistenceType)
68 MOZ_OVERRIDE;
69
70 virtual bool
71 DeallocPIndexedDBDatabaseChild(PIndexedDBDatabaseChild* aActor) MOZ_OVERRIDE;
72
73 virtual PIndexedDBDeleteDatabaseRequestChild*
74 AllocPIndexedDBDeleteDatabaseRequestChild(
75 const nsString& aName,
76 const PersistenceType& aPersistenceType)
77 MOZ_OVERRIDE;
78
79 virtual bool
80 DeallocPIndexedDBDeleteDatabaseRequestChild(
81 PIndexedDBDeleteDatabaseRequestChild* aActor)
82 MOZ_OVERRIDE;
83 };
84
85 /*******************************************************************************
86 * IndexedDBDatabaseChild
87 ******************************************************************************/
88
89 class IndexedDBDatabaseChild : public PIndexedDBDatabaseChild
90 {
91 IDBDatabase* mDatabase;
92 nsString mName;
93 uint64_t mVersion;
94
95 nsRefPtr<IDBOpenDBRequest> mRequest;
96 nsRefPtr<AsyncConnectionHelper> mOpenHelper;
97
98 // Only used during version change transactions and blocked events.
99 nsRefPtr<IDBDatabase> mStrongDatabase;
100
101 public:
102 IndexedDBDatabaseChild(const nsString& aName, uint64_t aVersion);
103 virtual ~IndexedDBDatabaseChild();
104
105 void
106 SetRequest(IDBOpenDBRequest* aRequest);
107
108 void
109 Disconnect();
110
111 protected:
112 bool
113 EnsureDatabase(IDBOpenDBRequest* aRequest,
114 const DatabaseInfoGuts& aDBInfo,
115 const InfallibleTArray<ObjectStoreInfoGuts>& aOSInfo);
116
117 virtual void
118 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
119
120 virtual bool
121 RecvSuccess(const DatabaseInfoGuts& aDBInfo,
122 const InfallibleTArray<ObjectStoreInfoGuts>& aOSInfo)
123 MOZ_OVERRIDE;
124
125 virtual bool
126 RecvError(const nsresult& aRv) MOZ_OVERRIDE;
127
128 virtual bool
129 RecvBlocked(const uint64_t& aOldVersion) MOZ_OVERRIDE;
130
131 virtual bool
132 RecvVersionChange(const uint64_t& aOldVersion, const uint64_t& aNewVersion)
133 MOZ_OVERRIDE;
134
135 virtual bool
136 RecvInvalidate() MOZ_OVERRIDE;
137
138 virtual bool
139 RecvPIndexedDBTransactionConstructor(PIndexedDBTransactionChild* aActor,
140 const TransactionParams& aParams)
141 MOZ_OVERRIDE;
142
143 virtual PIndexedDBTransactionChild*
144 AllocPIndexedDBTransactionChild(const TransactionParams& aParams) MOZ_OVERRIDE;
145
146 virtual bool
147 DeallocPIndexedDBTransactionChild(PIndexedDBTransactionChild* aActor) MOZ_OVERRIDE;
148 };
149
150 /*******************************************************************************
151 * IndexedDBTransactionChild
152 ******************************************************************************/
153
154 class IndexedDBTransactionChild : public PIndexedDBTransactionChild
155 {
156 IDBTransaction* mTransaction;
157
158 nsRefPtr<IDBTransaction> mStrongTransaction;
159 nsRefPtr<IDBTransactionListener> mTransactionListener;
160
161 public:
162 IndexedDBTransactionChild();
163 virtual ~IndexedDBTransactionChild();
164
165 void
166 SetTransaction(IDBTransaction* aTransaction);
167
168 IDBTransaction*
169 GetTransaction() const
170 {
171 return mTransaction;
172 }
173
174 void
175 Disconnect();
176
177 protected:
178 void
179 FireCompleteEvent(nsresult aRv);
180
181 virtual void
182 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
183
184 virtual bool
185 RecvComplete(const CompleteParams& aParams) MOZ_OVERRIDE;
186
187 virtual PIndexedDBObjectStoreChild*
188 AllocPIndexedDBObjectStoreChild(const ObjectStoreConstructorParams& aParams)
189 MOZ_OVERRIDE;
190
191 virtual bool
192 DeallocPIndexedDBObjectStoreChild(PIndexedDBObjectStoreChild* aActor) MOZ_OVERRIDE;
193 };
194
195 /*******************************************************************************
196 * IndexedDBObjectStoreChild
197 ******************************************************************************/
198
199 class IndexedDBObjectStoreChild : public PIndexedDBObjectStoreChild
200 {
201 IDBObjectStore* mObjectStore;
202
203 public:
204 IndexedDBObjectStoreChild(IDBObjectStore* aObjectStore);
205 virtual ~IndexedDBObjectStoreChild();
206
207 void
208 Disconnect();
209
210 protected:
211 virtual void
212 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
213
214 virtual bool
215 RecvPIndexedDBCursorConstructor(
216 PIndexedDBCursorChild* aActor,
217 const ObjectStoreCursorConstructorParams& aParams)
218 MOZ_OVERRIDE;
219
220 virtual PIndexedDBRequestChild*
221 AllocPIndexedDBRequestChild(const ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
222
223 virtual bool
224 DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE;
225
226 virtual PIndexedDBIndexChild*
227 AllocPIndexedDBIndexChild(const IndexConstructorParams& aParams) MOZ_OVERRIDE;
228
229 virtual bool
230 DeallocPIndexedDBIndexChild(PIndexedDBIndexChild* aActor) MOZ_OVERRIDE;
231
232 virtual PIndexedDBCursorChild*
233 AllocPIndexedDBCursorChild(const ObjectStoreCursorConstructorParams& aParams)
234 MOZ_OVERRIDE;
235
236 virtual bool
237 DeallocPIndexedDBCursorChild(PIndexedDBCursorChild* aActor) MOZ_OVERRIDE;
238 };
239
240 /*******************************************************************************
241 * IndexedDBIndexChild
242 ******************************************************************************/
243
244 class IndexedDBIndexChild : public PIndexedDBIndexChild
245 {
246 IDBIndex* mIndex;
247
248 public:
249 IndexedDBIndexChild(IDBIndex* aIndex);
250 virtual ~IndexedDBIndexChild();
251
252 void
253 Disconnect();
254
255 protected:
256 virtual void
257 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
258
259 virtual bool
260 RecvPIndexedDBCursorConstructor(PIndexedDBCursorChild* aActor,
261 const IndexCursorConstructorParams& aParams)
262 MOZ_OVERRIDE;
263
264 virtual PIndexedDBRequestChild*
265 AllocPIndexedDBRequestChild(const IndexRequestParams& aParams) MOZ_OVERRIDE;
266
267 virtual bool
268 DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE;
269
270 virtual PIndexedDBCursorChild*
271 AllocPIndexedDBCursorChild(const IndexCursorConstructorParams& aParams)
272 MOZ_OVERRIDE;
273
274 virtual bool
275 DeallocPIndexedDBCursorChild(PIndexedDBCursorChild* aActor) MOZ_OVERRIDE;
276 };
277
278 /*******************************************************************************
279 * IndexedDBCursorChild
280 ******************************************************************************/
281
282 class IndexedDBCursorChild : public PIndexedDBCursorChild
283 {
284 IDBCursor* mCursor;
285
286 nsRefPtr<IDBCursor> mStrongCursor;
287
288 public:
289 IndexedDBCursorChild();
290 virtual ~IndexedDBCursorChild();
291
292 void
293 SetCursor(IDBCursor* aCursor);
294
295 already_AddRefed<IDBCursor>
296 ForgetStrongCursor()
297 {
298 return mStrongCursor.forget();
299 }
300
301 void
302 Disconnect();
303
304 protected:
305 virtual void
306 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
307
308 virtual PIndexedDBRequestChild*
309 AllocPIndexedDBRequestChild(const CursorRequestParams& aParams) MOZ_OVERRIDE;
310
311 virtual bool
312 DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE;
313 };
314
315 /*******************************************************************************
316 * IndexedDBRequestChildBase
317 ******************************************************************************/
318
319 class IndexedDBRequestChildBase : public PIndexedDBRequestChild
320 {
321 protected:
322 nsRefPtr<AsyncConnectionHelper> mHelper;
323
324 public:
325 IDBRequest*
326 GetRequest() const;
327
328 void
329 Disconnect();
330
331 protected:
332 IndexedDBRequestChildBase(AsyncConnectionHelper* aHelper);
333 virtual ~IndexedDBRequestChildBase();
334
335 virtual bool
336 Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
337 };
338
339 /*******************************************************************************
340 * IndexedDBObjectStoreRequestChild
341 ******************************************************************************/
342
343 class IndexedDBObjectStoreRequestChild : public IndexedDBRequestChildBase
344 {
345 nsRefPtr<IDBObjectStore> mObjectStore;
346
347 typedef ipc::ObjectStoreRequestParams ParamsUnionType;
348 typedef ParamsUnionType::Type RequestType;
349 DebugOnly<RequestType> mRequestType;
350
351 public:
352 IndexedDBObjectStoreRequestChild(AsyncConnectionHelper* aHelper,
353 IDBObjectStore* aObjectStore,
354 RequestType aRequestType);
355 virtual ~IndexedDBObjectStoreRequestChild();
356
357 protected:
358 virtual bool
359 Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
360 };
361
362 /*******************************************************************************
363 * IndexedDBIndexRequestChild
364 ******************************************************************************/
365
366 class IndexedDBIndexRequestChild : public IndexedDBRequestChildBase
367 {
368 nsRefPtr<IDBIndex> mIndex;
369
370 typedef ipc::IndexRequestParams ParamsUnionType;
371 typedef ParamsUnionType::Type RequestType;
372 DebugOnly<RequestType> mRequestType;
373
374 public:
375 IndexedDBIndexRequestChild(AsyncConnectionHelper* aHelper, IDBIndex* aIndex,
376 RequestType aRequestType);
377 virtual ~IndexedDBIndexRequestChild();
378
379 protected:
380 virtual bool
381 Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
382 };
383
384 /*******************************************************************************
385 * IndexedDBCursorRequestChild
386 ******************************************************************************/
387
388 class IndexedDBCursorRequestChild : public IndexedDBRequestChildBase
389 {
390 nsRefPtr<IDBCursor> mCursor;
391
392 typedef ipc::CursorRequestParams ParamsUnionType;
393 typedef ParamsUnionType::Type RequestType;
394 DebugOnly<RequestType> mRequestType;
395
396 public:
397 IndexedDBCursorRequestChild(AsyncConnectionHelper* aHelper,
398 IDBCursor* aCursor,
399 RequestType aRequestType);
400 virtual ~IndexedDBCursorRequestChild();
401
402 protected:
403 virtual bool
404 Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
405 };
406
407 /*******************************************************************************
408 * IndexedDBDeleteDatabaseRequestChild
409 ******************************************************************************/
410
411 class IndexedDBDeleteDatabaseRequestChild :
412 public PIndexedDBDeleteDatabaseRequestChild
413 {
414 nsRefPtr<IDBFactory> mFactory;
415 nsRefPtr<IDBOpenDBRequest> mOpenRequest;
416 nsCString mDatabaseId;
417
418 public:
419 IndexedDBDeleteDatabaseRequestChild(IDBFactory* aFactory,
420 IDBOpenDBRequest* aOpenRequest,
421 const nsACString& aDatabaseId);
422 virtual ~IndexedDBDeleteDatabaseRequestChild();
423
424 protected:
425 virtual bool
426 Recv__delete__(const nsresult& aRv) MOZ_OVERRIDE;
427
428 virtual bool
429 RecvBlocked(const uint64_t& aCurrentVersion) MOZ_OVERRIDE;
430 };
431
432 END_INDEXEDDB_NAMESPACE
433
434 #endif // mozilla_dom_indexeddb_ipc_indexeddbchild_h__

mercurial