Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
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/. */
5 #ifndef mozilla_dom_indexeddb_ipc_indexeddbparent_h__
6 #define mozilla_dom_indexeddb_ipc_indexeddbparent_h__
8 #include "mozilla/Attributes.h"
9 #include "mozilla/DebugOnly.h"
11 #include "mozilla/dom/indexedDB/IndexedDatabase.h"
13 #include "mozilla/dom/indexedDB/PIndexedDBParent.h"
14 #include "mozilla/dom/indexedDB/PIndexedDBCursorParent.h"
15 #include "mozilla/dom/indexedDB/PIndexedDBDatabaseParent.h"
16 #include "mozilla/dom/indexedDB/PIndexedDBDeleteDatabaseRequestParent.h"
17 #include "mozilla/dom/indexedDB/PIndexedDBIndexParent.h"
18 #include "mozilla/dom/indexedDB/PIndexedDBObjectStoreParent.h"
19 #include "mozilla/dom/indexedDB/PIndexedDBRequestParent.h"
20 #include "mozilla/dom/indexedDB/PIndexedDBTransactionParent.h"
22 #include "nsIDOMEventListener.h"
24 namespace mozilla {
25 namespace dom {
26 class ContentParent;
27 class PBlobParent;
28 class TabParent;
29 }
30 }
32 class nsIDOMBlob;
33 class nsIDOMEvent;
35 BEGIN_INDEXEDDB_NAMESPACE
37 class IDBCursor;
38 class IDBDatabase;
39 class IDBFactory;
40 class IDBIndex;
41 class IDBObjectStore;
42 class IDBOpenDBRequest;
43 class IDBTransaction;
45 class IndexedDBCursorParent;
46 class IndexedDBDatabaseParent;
47 class IndexedDBDeleteDatabaseRequestParent;
48 class IndexedDBIndexParent;
49 class IndexedDBObjectStoreParent;
50 class IndexedDBTransactionParent;
51 class IndexedDBVersionChangeTransactionParent;
52 class IndexedDBVersionChangeObjectStoreParent;
54 /*******************************************************************************
55 * AutoSetCurrentTransaction
56 ******************************************************************************/
58 class AutoSetCurrentTransaction
59 {
60 public:
61 AutoSetCurrentTransaction(IDBTransaction* aTransaction);
62 ~AutoSetCurrentTransaction();
63 };
65 /*******************************************************************************
66 * WeakEventListener
67 ******************************************************************************/
69 class WeakEventListenerBase : public nsIDOMEventListener
70 {
71 public:
72 NS_DECL_ISUPPORTS
73 NS_DECL_NSIDOMEVENTLISTENER
75 protected:
76 WeakEventListenerBase()
77 { }
79 virtual ~WeakEventListenerBase()
80 { }
81 };
83 template <class T>
84 class WeakEventListener : public WeakEventListenerBase
85 {
86 T* mActor;
88 public:
89 WeakEventListener(T* aActor)
90 : mActor(aActor)
91 { }
93 void
94 NoteDyingActor()
95 {
96 mActor = nullptr;
97 }
99 NS_IMETHOD
100 HandleEvent(nsIDOMEvent* aEvent) MOZ_OVERRIDE
101 {
102 return mActor ? mActor->HandleEvent(aEvent) : NS_OK;
103 }
105 protected:
106 virtual ~WeakEventListener()
107 { }
108 };
110 template <class T>
111 class AutoWeakEventListener
112 {
113 nsRefPtr<WeakEventListener<T> > mEventListener;
115 public:
116 AutoWeakEventListener(T* aActor)
117 {
118 mEventListener = new WeakEventListener<T>(aActor);
119 }
121 ~AutoWeakEventListener()
122 {
123 mEventListener->NoteDyingActor();
124 }
126 template <class U>
127 operator U*()
128 {
129 return mEventListener;
130 }
132 T*
133 operator ->()
134 {
135 return mEventListener;
136 }
137 };
139 /*******************************************************************************
140 * IndexedDBParent
141 ******************************************************************************/
143 class IndexedDBParent : private PIndexedDBParent
144 {
145 friend class mozilla::dom::ContentParent;
146 friend class mozilla::dom::TabParent;
147 friend class IndexedDBDatabaseParent;
148 friend class IndexedDBDeleteDatabaseRequestParent;
150 nsRefPtr<IDBFactory> mFactory;
151 nsCString mASCIIOrigin;
153 ContentParent* mManagerContent;
154 TabParent* mManagerTab;
156 bool mDisconnected;
158 public:
159 IndexedDBParent(ContentParent* aContentParent);
160 IndexedDBParent(TabParent* aTabParent);
162 virtual ~IndexedDBParent();
164 const nsCString&
165 GetASCIIOrigin() const
166 {
167 return mASCIIOrigin;
168 }
170 void
171 Disconnect();
173 bool
174 IsDisconnected() const
175 {
176 return mDisconnected;
177 }
179 ContentParent*
180 GetManagerContent() const
181 {
182 return mManagerContent;
183 }
185 TabParent*
186 GetManagerTab() const
187 {
188 return mManagerTab;
189 }
191 bool
192 CheckReadPermission(const nsAString& aDatabaseName);
194 bool
195 CheckWritePermission(const nsAString& aDatabaseName);
197 mozilla::ipc::IProtocol*
198 CloneProtocol(Channel* aChannel,
199 mozilla::ipc::ProtocolCloneContext* aCtx) MOZ_OVERRIDE;
201 protected:
202 bool
203 CheckPermissionInternal(const nsAString& aDatabaseName,
204 const nsACString& aPermission);
206 virtual void
207 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
209 virtual bool
210 RecvPIndexedDBDatabaseConstructor(PIndexedDBDatabaseParent* aActor,
211 const nsString& aName,
212 const uint64_t& aVersion,
213 const PersistenceType& aPersistenceType)
214 MOZ_OVERRIDE;
216 virtual bool
217 RecvPIndexedDBDeleteDatabaseRequestConstructor(
218 PIndexedDBDeleteDatabaseRequestParent* aActor,
219 const nsString& aName,
220 const PersistenceType& aPersistenceType)
221 MOZ_OVERRIDE;
223 virtual PIndexedDBDatabaseParent*
224 AllocPIndexedDBDatabaseParent(const nsString& aName, const uint64_t& aVersion,
225 const PersistenceType& aPersistenceType)
226 MOZ_OVERRIDE;
228 virtual bool
229 DeallocPIndexedDBDatabaseParent(PIndexedDBDatabaseParent* aActor) MOZ_OVERRIDE;
231 virtual PIndexedDBDeleteDatabaseRequestParent*
232 AllocPIndexedDBDeleteDatabaseRequestParent(
233 const nsString& aName,
234 const PersistenceType& aPersistenceType)
235 MOZ_OVERRIDE;
237 virtual bool
238 DeallocPIndexedDBDeleteDatabaseRequestParent(
239 PIndexedDBDeleteDatabaseRequestParent* aActor)
240 MOZ_OVERRIDE;
241 };
243 /*******************************************************************************
244 * IndexedDBDatabaseParent
245 ******************************************************************************/
247 class IndexedDBDatabaseParent : private PIndexedDBDatabaseParent
248 {
249 friend class IndexedDBParent;
250 friend class IndexedDBTransactionParent;
251 friend class IndexedDBVersionChangeTransactionParent;
253 AutoWeakEventListener<IndexedDBDatabaseParent> mEventListener;
255 nsRefPtr<IDBOpenDBRequest> mOpenRequest;
256 nsRefPtr<IDBDatabase> mDatabase;
258 public:
259 IndexedDBDatabaseParent();
260 virtual ~IndexedDBDatabaseParent();
262 nsresult
263 SetOpenRequest(IDBOpenDBRequest* aRequest);
265 nsresult
266 HandleEvent(nsIDOMEvent* aEvent);
268 void
269 Disconnect();
271 bool
272 IsDisconnected() const
273 {
274 return static_cast<IndexedDBParent*>(Manager())->IsDisconnected();
275 }
277 bool
278 CheckWritePermission(const nsAString& aDatabaseName);
280 void
281 Invalidate();
283 protected:
284 nsresult
285 HandleRequestEvent(nsIDOMEvent* aEvent, const nsAString& aType);
287 nsresult
288 HandleDatabaseEvent(nsIDOMEvent* aEvent, const nsAString& aType);
290 virtual void
291 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
293 virtual bool
294 RecvClose(const bool& aUnlinked) MOZ_OVERRIDE;
296 virtual bool
297 RecvPIndexedDBTransactionConstructor(PIndexedDBTransactionParent* aActor,
298 const TransactionParams& aParams)
299 MOZ_OVERRIDE;
301 virtual PIndexedDBTransactionParent*
302 AllocPIndexedDBTransactionParent(const TransactionParams& aParams) MOZ_OVERRIDE;
304 virtual bool
305 DeallocPIndexedDBTransactionParent(PIndexedDBTransactionParent* aActor)
306 MOZ_OVERRIDE;
307 };
309 /*******************************************************************************
310 * IndexedDBTransactionParent
311 ******************************************************************************/
313 class IndexedDBTransactionParent : protected PIndexedDBTransactionParent
314 {
315 friend class IndexedDBCursorParent;
316 friend class IndexedDBDatabaseParent;
317 friend class IndexedDBObjectStoreParent;
319 protected:
320 AutoWeakEventListener<IndexedDBTransactionParent> mEventListener;
322 nsRefPtr<IDBTransaction> mTransaction;
324 bool mArtificialRequestCount;
326 public:
327 IndexedDBTransactionParent();
328 virtual ~IndexedDBTransactionParent();
330 bool
331 IsDisconnected() const
332 {
333 return static_cast<IndexedDBDatabaseParent*>(Manager())->IsDisconnected();
334 }
336 nsresult
337 SetTransaction(IDBTransaction* aTransaction);
339 IDBTransaction*
340 GetTransaction() const
341 {
342 return mTransaction;
343 }
345 nsresult
346 HandleEvent(nsIDOMEvent* aEvent);
348 protected:
349 virtual void
350 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
352 virtual bool
353 RecvAbort(const nsresult& aAbortCode) MOZ_OVERRIDE;
355 virtual bool
356 RecvAllRequestsFinished() MOZ_OVERRIDE;
358 virtual bool
359 RecvDeleteObjectStore(const nsString& aName) MOZ_OVERRIDE;
361 virtual bool
362 RecvPIndexedDBObjectStoreConstructor(
363 PIndexedDBObjectStoreParent* aActor,
364 const ObjectStoreConstructorParams& aParams)
365 MOZ_OVERRIDE;
367 virtual PIndexedDBObjectStoreParent*
368 AllocPIndexedDBObjectStoreParent(const ObjectStoreConstructorParams& aParams)
369 MOZ_OVERRIDE;
371 virtual bool
372 DeallocPIndexedDBObjectStoreParent(PIndexedDBObjectStoreParent* aActor)
373 MOZ_OVERRIDE;
374 };
376 /*******************************************************************************
377 * IndexedDBVersionChangeTransactionParent
378 ******************************************************************************/
380 class IndexedDBVersionChangeTransactionParent :
381 public IndexedDBTransactionParent
382 {
383 friend class IndexedDBVersionChangeObjectStoreParent;
385 public:
386 IndexedDBVersionChangeTransactionParent();
387 virtual ~IndexedDBVersionChangeTransactionParent();
389 bool
390 IsDisconnected() const
391 {
392 return static_cast<IndexedDBDatabaseParent*>(Manager())->IsDisconnected();
393 }
395 protected:
396 virtual bool
397 RecvDeleteObjectStore(const nsString& aName) MOZ_OVERRIDE;
399 virtual bool
400 RecvPIndexedDBObjectStoreConstructor(
401 PIndexedDBObjectStoreParent* aActor,
402 const ObjectStoreConstructorParams& aParams)
403 MOZ_OVERRIDE;
405 virtual PIndexedDBObjectStoreParent*
406 AllocPIndexedDBObjectStoreParent(const ObjectStoreConstructorParams& aParams)
407 MOZ_OVERRIDE;
408 };
410 /*******************************************************************************
411 * IndexedDBCursorParent
412 ******************************************************************************/
414 class IndexedDBCursorParent : private PIndexedDBCursorParent
415 {
416 friend class IndexedDBIndexParent;
417 friend class IndexedDBObjectStoreParent;
419 nsRefPtr<IDBCursor> mCursor;
421 public:
422 IDBCursor*
423 GetCursor() const
424 {
425 return mCursor;
426 }
428 bool
429 IsDisconnected() const;
431 protected:
432 IndexedDBCursorParent(IDBCursor* aCursor);
433 virtual ~IndexedDBCursorParent();
435 virtual void
436 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
438 virtual bool
439 RecvPIndexedDBRequestConstructor(PIndexedDBRequestParent* aActor,
440 const CursorRequestParams& aParams)
441 MOZ_OVERRIDE;
443 virtual PIndexedDBRequestParent*
444 AllocPIndexedDBRequestParent(const CursorRequestParams& aParams) MOZ_OVERRIDE;
446 virtual bool
447 DeallocPIndexedDBRequestParent(PIndexedDBRequestParent* aActor) MOZ_OVERRIDE;
448 };
450 /*******************************************************************************
451 * IndexedDBObjectStoreParent
452 ******************************************************************************/
454 class IndexedDBObjectStoreParent : protected PIndexedDBObjectStoreParent
455 {
456 friend class IndexedDBIndexParent;
457 friend class IndexedDBTransactionParent;
458 friend class IndexedDBVersionChangeTransactionParent;
460 typedef mozilla::dom::indexedDB::ipc::OpenCursorResponse OpenCursorResponse;
462 protected:
463 nsRefPtr<IDBObjectStore> mObjectStore;
465 public:
466 IndexedDBObjectStoreParent();
467 virtual ~IndexedDBObjectStoreParent();
469 void
470 SetObjectStore(IDBObjectStore* aObjectStore);
472 IDBObjectStore*
473 GetObjectStore() const
474 {
475 return mObjectStore;
476 }
478 bool
479 IsDisconnected() const
480 {
481 IndexedDBTransactionParent* manager =
482 static_cast<IndexedDBTransactionParent*>(Manager());
483 return manager->IsDisconnected();
484 }
486 // Ordinarily callers could just do this manually using
487 // PIndexedDBObjectStoreParent::SendPIndexedDBCursorConstructor but we're
488 // inheriting the abstract protocol class privately to prevent outside code
489 // from sending messages without checking the disconnected state. Therefore
490 // we need a helper method.
491 bool
492 OpenCursor(IDBCursor* aCursor,
493 const ObjectStoreCursorConstructorParams& aParams,
494 OpenCursorResponse& aResponse) NS_WARN_UNUSED_RESULT
495 {
496 if (IsDisconnected()) {
497 return true;
498 }
500 IndexedDBCursorParent* cursorActor = new IndexedDBCursorParent(aCursor);
502 if (!SendPIndexedDBCursorConstructor(cursorActor, aParams)) {
503 return false;
504 }
506 aResponse = cursorActor;
507 return true;
508 }
510 protected:
511 virtual void
512 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
514 virtual bool
515 RecvDeleteIndex(const nsString& aName) MOZ_OVERRIDE;
517 virtual bool
518 RecvPIndexedDBRequestConstructor(PIndexedDBRequestParent* aActor,
519 const ObjectStoreRequestParams& aParams)
520 MOZ_OVERRIDE;
522 virtual bool
523 RecvPIndexedDBIndexConstructor(PIndexedDBIndexParent* aActor,
524 const IndexConstructorParams& aParams)
525 MOZ_OVERRIDE;
527 virtual PIndexedDBRequestParent*
528 AllocPIndexedDBRequestParent(const ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
530 virtual bool
531 DeallocPIndexedDBRequestParent(PIndexedDBRequestParent* aActor) MOZ_OVERRIDE;
533 virtual PIndexedDBIndexParent*
534 AllocPIndexedDBIndexParent(const IndexConstructorParams& aParams) MOZ_OVERRIDE;
536 virtual bool
537 DeallocPIndexedDBIndexParent(PIndexedDBIndexParent* aActor) MOZ_OVERRIDE;
539 virtual PIndexedDBCursorParent*
540 AllocPIndexedDBCursorParent(const ObjectStoreCursorConstructorParams& aParams)
541 MOZ_OVERRIDE;
543 virtual bool
544 DeallocPIndexedDBCursorParent(PIndexedDBCursorParent* aActor) MOZ_OVERRIDE;
545 };
547 /*******************************************************************************
548 * IndexedDBVersionChangeObjectStoreParent
549 ******************************************************************************/
551 class IndexedDBVersionChangeObjectStoreParent :
552 public IndexedDBObjectStoreParent
553 {
554 friend class IndexedDBVersionChangeTransactionParent;
556 public:
557 IndexedDBVersionChangeObjectStoreParent();
558 virtual ~IndexedDBVersionChangeObjectStoreParent();
560 protected:
561 bool
562 IsDisconnected() const
563 {
564 IndexedDBVersionChangeTransactionParent* manager =
565 static_cast<IndexedDBVersionChangeTransactionParent*>(Manager());
566 return manager->IsDisconnected();
567 }
569 virtual bool
570 RecvDeleteIndex(const nsString& aName) MOZ_OVERRIDE;
572 virtual bool
573 RecvPIndexedDBIndexConstructor(PIndexedDBIndexParent* aActor,
574 const IndexConstructorParams& aParams)
575 MOZ_OVERRIDE;
576 };
578 /*******************************************************************************
579 * IndexedDBIndexParent
580 ******************************************************************************/
582 class IndexedDBIndexParent : private PIndexedDBIndexParent
583 {
584 friend class IndexedDBObjectStoreParent;
585 friend class IndexedDBVersionChangeObjectStoreParent;
587 typedef mozilla::dom::indexedDB::ipc::OpenCursorResponse OpenCursorResponse;
589 nsRefPtr<IDBIndex> mIndex;
591 public:
592 IndexedDBIndexParent();
593 virtual ~IndexedDBIndexParent();
595 void
596 SetIndex(IDBIndex* aObjectStore);
598 IDBIndex*
599 GetIndex() const
600 {
601 return mIndex;
602 }
604 // Ordinarily callers could just do this manually using
605 // PIndexedDBIndexParent::SendPIndexedDBCursorConstructor but we're
606 // inheriting the abstract protocol class privately to prevent outside code
607 // from sending messages without checking the disconnected state. Therefore
608 // we need a helper method.
609 bool
610 OpenCursor(IDBCursor* aCursor, const IndexCursorConstructorParams& aParams,
611 OpenCursorResponse& aResponse) NS_WARN_UNUSED_RESULT
612 {
613 if (IsDisconnected()) {
614 return true;
615 }
617 IndexedDBCursorParent* cursorActor = new IndexedDBCursorParent(aCursor);
619 if (!SendPIndexedDBCursorConstructor(cursorActor, aParams)) {
620 return false;
621 }
623 aResponse = cursorActor;
624 return true;
625 }
627 bool
628 IsDisconnected() const
629 {
630 IndexedDBObjectStoreParent* manager =
631 static_cast<IndexedDBObjectStoreParent*>(Manager());
632 return manager->IsDisconnected();
633 }
635 protected:
636 virtual void
637 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
639 virtual bool
640 RecvPIndexedDBRequestConstructor(PIndexedDBRequestParent* aActor,
641 const IndexRequestParams& aParams)
642 MOZ_OVERRIDE;
644 virtual PIndexedDBRequestParent*
645 AllocPIndexedDBRequestParent(const IndexRequestParams& aParams) MOZ_OVERRIDE;
647 virtual bool
648 DeallocPIndexedDBRequestParent(PIndexedDBRequestParent* aActor) MOZ_OVERRIDE;
650 virtual PIndexedDBCursorParent*
651 AllocPIndexedDBCursorParent(const IndexCursorConstructorParams& aParams)
652 MOZ_OVERRIDE;
654 virtual bool
655 DeallocPIndexedDBCursorParent(PIndexedDBCursorParent* aActor) MOZ_OVERRIDE;
656 };
658 /*******************************************************************************
659 * IndexedDBRequestParentBase
660 ******************************************************************************/
662 class IndexedDBRequestParentBase : public PIndexedDBRequestParent
663 {
664 public:
665 bool
666 SendResponse(const ResponseValue& aResponse) NS_WARN_UNUSED_RESULT
667 {
668 if (IsDisconnected()) {
669 return true;
670 }
672 return Send__delete__(this, aResponse);
673 }
675 protected:
676 // Don't let anyone call this directly, instead go through SendResponse.
677 using PIndexedDBRequestParent::Send__delete__;
679 typedef ipc::ResponseValue ResponseValue;
680 typedef PIndexedDBRequestParent::PBlobParent PBlobParent;
682 nsRefPtr<IDBRequest> mRequest;
684 IndexedDBRequestParentBase();
685 virtual ~IndexedDBRequestParentBase();
687 virtual void
688 ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
690 virtual bool
691 IsDisconnected() = 0;
692 };
694 /*******************************************************************************
695 * IndexedDBObjectStoreRequestParent
696 ******************************************************************************/
698 class IndexedDBObjectStoreRequestParent : public IndexedDBRequestParentBase
699 {
700 friend class IndexedDBObjectStoreParent;
702 nsRefPtr<IDBObjectStore> mObjectStore;
704 typedef ipc::ObjectStoreRequestParams ParamsUnionType;
705 typedef ParamsUnionType::Type RequestType;
706 DebugOnly<RequestType> mRequestType;
708 typedef ipc::AddParams AddParams;
709 typedef ipc::PutParams PutParams;
710 typedef ipc::ClearParams ClearParams;
711 typedef ipc::DeleteParams DeleteParams;
712 typedef ipc::GetParams GetParams;
713 typedef ipc::GetAllParams GetAllParams;
714 typedef ipc::GetAllKeysParams GetAllKeysParams;
715 typedef ipc::CountParams CountParams;
716 typedef ipc::OpenCursorParams OpenCursorParams;
717 typedef ipc::OpenKeyCursorParams OpenKeyCursorParams;
719 public:
720 IndexedDBObjectStoreRequestParent(IDBObjectStore* aObjectStore,
721 RequestType aRequestType);
722 virtual ~IndexedDBObjectStoreRequestParent();
724 bool
725 Get(const GetParams& aParams);
727 bool
728 GetAll(const GetAllParams& aParams);
730 bool
731 GetAllKeys(const GetAllKeysParams& aParams);
733 bool
734 Add(const AddParams& aParams);
736 bool
737 Put(const PutParams& aParams);
739 bool
740 Delete(const DeleteParams& aParams);
742 bool
743 Clear(const ClearParams& aParams);
745 bool
746 Count(const CountParams& aParams);
748 bool
749 OpenCursor(const OpenCursorParams& aParams);
751 bool
752 OpenKeyCursor(const OpenKeyCursorParams& aParams);
754 protected:
755 void
756 ConvertBlobActors(const InfallibleTArray<PBlobParent*>& aActors,
757 nsTArray<nsCOMPtr<nsIDOMBlob> >& aBlobs);
759 private:
760 virtual bool
761 IsDisconnected() MOZ_OVERRIDE;
762 };
764 /*******************************************************************************
765 * IndexedDBIndexRequestParent
766 ******************************************************************************/
768 class IndexedDBIndexRequestParent : public IndexedDBRequestParentBase
769 {
770 friend class IndexedDBIndexParent;
772 nsRefPtr<IDBIndex> mIndex;
774 typedef ipc::IndexRequestParams ParamsUnionType;
775 typedef ParamsUnionType::Type RequestType;
776 DebugOnly<RequestType> mRequestType;
778 typedef ipc::GetKeyParams GetKeyParams;
779 typedef ipc::GetAllKeysParams GetAllKeysParams;
780 typedef ipc::OpenKeyCursorParams OpenKeyCursorParams;
781 typedef ipc::GetParams GetParams;
782 typedef ipc::GetAllParams GetAllParams;
783 typedef ipc::CountParams CountParams;
784 typedef ipc::OpenCursorParams OpenCursorParams;
786 public:
787 IndexedDBIndexRequestParent(IDBIndex* aIndex, RequestType aRequestType);
788 virtual ~IndexedDBIndexRequestParent();
790 bool
791 Get(const GetParams& aParams);
793 bool
794 GetKey(const GetKeyParams& aParams);
796 bool
797 GetAll(const GetAllParams& aParams);
799 bool
800 GetAllKeys(const GetAllKeysParams& aParams);
802 bool
803 Count(const CountParams& aParams);
805 bool
806 OpenCursor(const OpenCursorParams& aParams);
808 bool
809 OpenKeyCursor(const OpenKeyCursorParams& aParams);
811 private:
812 virtual bool
813 IsDisconnected() MOZ_OVERRIDE;
814 };
816 /*******************************************************************************
817 * IndexedDBCursorRequestParent
818 ******************************************************************************/
820 class IndexedDBCursorRequestParent : public IndexedDBRequestParentBase
821 {
822 friend class IndexedDBCursorParent;
824 nsRefPtr<IDBCursor> mCursor;
826 typedef ipc::CursorRequestParams ParamsUnionType;
827 typedef ParamsUnionType::Type RequestType;
828 DebugOnly<RequestType> mRequestType;
830 typedef ipc::ContinueParams ContinueParams;
832 public:
833 IndexedDBCursorRequestParent(IDBCursor* aCursor, RequestType aRequestType);
834 virtual ~IndexedDBCursorRequestParent();
836 bool
837 Continue(const ContinueParams& aParams);
839 private:
840 virtual bool
841 IsDisconnected() MOZ_OVERRIDE;
842 };
844 /*******************************************************************************
845 * IndexedDBDeleteDatabaseRequestParent
846 ******************************************************************************/
848 class IndexedDBDeleteDatabaseRequestParent :
849 private PIndexedDBDeleteDatabaseRequestParent
850 {
851 friend class IndexedDBParent;
853 AutoWeakEventListener<IndexedDBDeleteDatabaseRequestParent> mEventListener;
855 nsRefPtr<IDBFactory> mFactory;
856 nsRefPtr<IDBOpenDBRequest> mOpenRequest;
858 public:
859 nsresult
860 HandleEvent(nsIDOMEvent* aEvent);
862 protected:
863 IndexedDBDeleteDatabaseRequestParent(IDBFactory* aFactory);
864 virtual ~IndexedDBDeleteDatabaseRequestParent();
866 nsresult
867 SetOpenRequest(IDBOpenDBRequest* aOpenRequest);
869 bool
870 IsDisconnected() const
871 {
872 return static_cast<IndexedDBParent*>(Manager())->IsDisconnected();
873 }
874 };
876 END_INDEXEDDB_NAMESPACE
878 #endif // mozilla_dom_indexeddb_ipc_indexeddbparent_h__