dom/indexedDB/ipc/IndexedDBChild.h

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rw-r--r--

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

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

mercurial