dom/indexedDB/ipc/IndexedDBChild.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/indexedDB/ipc/IndexedDBChild.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,434 @@
     1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.7 +
     1.8 +#ifndef mozilla_dom_indexeddb_ipc_indexeddbchild_h__
     1.9 +#define mozilla_dom_indexeddb_ipc_indexeddbchild_h__
    1.10 +
    1.11 +#include "mozilla/Attributes.h"
    1.12 +#include "mozilla/DebugOnly.h"
    1.13 +
    1.14 +#include "mozilla/dom/indexedDB/IndexedDatabase.h"
    1.15 +
    1.16 +#include "mozilla/dom/indexedDB/PIndexedDBChild.h"
    1.17 +#include "mozilla/dom/indexedDB/PIndexedDBCursorChild.h"
    1.18 +#include "mozilla/dom/indexedDB/PIndexedDBDatabaseChild.h"
    1.19 +#include "mozilla/dom/indexedDB/PIndexedDBDeleteDatabaseRequestChild.h"
    1.20 +#include "mozilla/dom/indexedDB/PIndexedDBIndexChild.h"
    1.21 +#include "mozilla/dom/indexedDB/PIndexedDBObjectStoreChild.h"
    1.22 +#include "mozilla/dom/indexedDB/PIndexedDBRequestChild.h"
    1.23 +#include "mozilla/dom/indexedDB/PIndexedDBTransactionChild.h"
    1.24 +
    1.25 +BEGIN_INDEXEDDB_NAMESPACE
    1.26 +
    1.27 +class AsyncConnectionHelper;
    1.28 +class IDBCursor;
    1.29 +class IDBFactory;
    1.30 +class IDBIndex;
    1.31 +class IDBOpenDBRequest;
    1.32 +class IDBRequest;
    1.33 +class IDBTransactionListener;
    1.34 +
    1.35 +/*******************************************************************************
    1.36 + * IndexedDBChild
    1.37 + ******************************************************************************/
    1.38 +
    1.39 +class IndexedDBChild : public PIndexedDBChild
    1.40 +{
    1.41 +  IDBFactory* mFactory;
    1.42 +  nsCString mASCIIOrigin;
    1.43 +
    1.44 +#ifdef DEBUG
    1.45 +  bool mDisconnected;
    1.46 +#endif
    1.47 +
    1.48 +public:
    1.49 +  IndexedDBChild(const nsCString& aASCIIOrigin);
    1.50 +  virtual ~IndexedDBChild();
    1.51 +
    1.52 +  const nsCString&
    1.53 +  ASCIIOrigin() const
    1.54 +  {
    1.55 +    return mASCIIOrigin;
    1.56 +  }
    1.57 +
    1.58 +  void
    1.59 +  SetFactory(IDBFactory* aFactory);
    1.60 +
    1.61 +  void
    1.62 +  Disconnect();
    1.63 +
    1.64 +protected:
    1.65 +  virtual void
    1.66 +  ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
    1.67 +
    1.68 +  virtual PIndexedDBDatabaseChild*
    1.69 +  AllocPIndexedDBDatabaseChild(const nsString& aName, const uint64_t& aVersion,
    1.70 +                               const PersistenceType& aPersistenceType)
    1.71 +                               MOZ_OVERRIDE;
    1.72 +
    1.73 +  virtual bool
    1.74 +  DeallocPIndexedDBDatabaseChild(PIndexedDBDatabaseChild* aActor) MOZ_OVERRIDE;
    1.75 +
    1.76 +  virtual PIndexedDBDeleteDatabaseRequestChild*
    1.77 +  AllocPIndexedDBDeleteDatabaseRequestChild(
    1.78 +                                        const nsString& aName,
    1.79 +                                        const PersistenceType& aPersistenceType)
    1.80 +                                        MOZ_OVERRIDE;
    1.81 +
    1.82 +  virtual bool
    1.83 +  DeallocPIndexedDBDeleteDatabaseRequestChild(
    1.84 +                                   PIndexedDBDeleteDatabaseRequestChild* aActor)
    1.85 +                                   MOZ_OVERRIDE;
    1.86 +};
    1.87 +
    1.88 +/*******************************************************************************
    1.89 + * IndexedDBDatabaseChild
    1.90 + ******************************************************************************/
    1.91 +
    1.92 +class IndexedDBDatabaseChild : public PIndexedDBDatabaseChild
    1.93 +{
    1.94 +  IDBDatabase* mDatabase;
    1.95 +  nsString mName;
    1.96 +  uint64_t mVersion;
    1.97 +
    1.98 +  nsRefPtr<IDBOpenDBRequest> mRequest;
    1.99 +  nsRefPtr<AsyncConnectionHelper> mOpenHelper;
   1.100 +
   1.101 +  // Only used during version change transactions and blocked events.
   1.102 +  nsRefPtr<IDBDatabase> mStrongDatabase;
   1.103 +
   1.104 +public:
   1.105 +  IndexedDBDatabaseChild(const nsString& aName, uint64_t aVersion);
   1.106 +  virtual ~IndexedDBDatabaseChild();
   1.107 +
   1.108 +  void
   1.109 +  SetRequest(IDBOpenDBRequest* aRequest);
   1.110 +
   1.111 +  void
   1.112 +  Disconnect();
   1.113 +
   1.114 +protected:
   1.115 +  bool
   1.116 +  EnsureDatabase(IDBOpenDBRequest* aRequest,
   1.117 +                 const DatabaseInfoGuts& aDBInfo,
   1.118 +                 const InfallibleTArray<ObjectStoreInfoGuts>& aOSInfo);
   1.119 +
   1.120 +  virtual void
   1.121 +  ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   1.122 +
   1.123 +  virtual bool
   1.124 +  RecvSuccess(const DatabaseInfoGuts& aDBInfo,
   1.125 +              const InfallibleTArray<ObjectStoreInfoGuts>& aOSInfo)
   1.126 +              MOZ_OVERRIDE;
   1.127 +
   1.128 +  virtual bool
   1.129 +  RecvError(const nsresult& aRv) MOZ_OVERRIDE;
   1.130 +
   1.131 +  virtual bool
   1.132 +  RecvBlocked(const uint64_t& aOldVersion) MOZ_OVERRIDE;
   1.133 +
   1.134 +  virtual bool
   1.135 +  RecvVersionChange(const uint64_t& aOldVersion, const uint64_t& aNewVersion)
   1.136 +                    MOZ_OVERRIDE;
   1.137 +
   1.138 +  virtual bool
   1.139 +  RecvInvalidate() MOZ_OVERRIDE;
   1.140 +
   1.141 +  virtual bool
   1.142 +  RecvPIndexedDBTransactionConstructor(PIndexedDBTransactionChild* aActor,
   1.143 +                                       const TransactionParams& aParams)
   1.144 +                                       MOZ_OVERRIDE;
   1.145 +
   1.146 +  virtual PIndexedDBTransactionChild*
   1.147 +  AllocPIndexedDBTransactionChild(const TransactionParams& aParams) MOZ_OVERRIDE;
   1.148 +
   1.149 +  virtual bool
   1.150 +  DeallocPIndexedDBTransactionChild(PIndexedDBTransactionChild* aActor) MOZ_OVERRIDE;
   1.151 +};
   1.152 +
   1.153 +/*******************************************************************************
   1.154 + * IndexedDBTransactionChild
   1.155 + ******************************************************************************/
   1.156 +
   1.157 +class IndexedDBTransactionChild : public PIndexedDBTransactionChild
   1.158 +{
   1.159 +  IDBTransaction* mTransaction;
   1.160 +
   1.161 +  nsRefPtr<IDBTransaction> mStrongTransaction;
   1.162 +  nsRefPtr<IDBTransactionListener> mTransactionListener;
   1.163 +
   1.164 +public:
   1.165 +  IndexedDBTransactionChild();
   1.166 +  virtual ~IndexedDBTransactionChild();
   1.167 +
   1.168 +  void
   1.169 +  SetTransaction(IDBTransaction* aTransaction);
   1.170 +
   1.171 +  IDBTransaction*
   1.172 +  GetTransaction() const
   1.173 +  {
   1.174 +    return mTransaction;
   1.175 +  }
   1.176 +
   1.177 +  void
   1.178 +  Disconnect();
   1.179 +
   1.180 +protected:
   1.181 +  void
   1.182 +  FireCompleteEvent(nsresult aRv);
   1.183 +
   1.184 +  virtual void
   1.185 +  ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   1.186 +
   1.187 +  virtual bool
   1.188 +  RecvComplete(const CompleteParams& aParams) MOZ_OVERRIDE;
   1.189 +
   1.190 +  virtual PIndexedDBObjectStoreChild*
   1.191 +  AllocPIndexedDBObjectStoreChild(const ObjectStoreConstructorParams& aParams)
   1.192 +                                  MOZ_OVERRIDE;
   1.193 +
   1.194 +  virtual bool
   1.195 +  DeallocPIndexedDBObjectStoreChild(PIndexedDBObjectStoreChild* aActor) MOZ_OVERRIDE;
   1.196 +};
   1.197 +
   1.198 +/*******************************************************************************
   1.199 + * IndexedDBObjectStoreChild
   1.200 + ******************************************************************************/
   1.201 +
   1.202 +class IndexedDBObjectStoreChild : public PIndexedDBObjectStoreChild
   1.203 +{
   1.204 +  IDBObjectStore* mObjectStore;
   1.205 +
   1.206 +public:
   1.207 +  IndexedDBObjectStoreChild(IDBObjectStore* aObjectStore);
   1.208 +  virtual ~IndexedDBObjectStoreChild();
   1.209 +
   1.210 +  void
   1.211 +  Disconnect();
   1.212 +
   1.213 +protected:
   1.214 +  virtual void
   1.215 +  ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   1.216 +
   1.217 +  virtual bool
   1.218 +  RecvPIndexedDBCursorConstructor(
   1.219 +                              PIndexedDBCursorChild* aActor,
   1.220 +                              const ObjectStoreCursorConstructorParams& aParams)
   1.221 +                              MOZ_OVERRIDE;
   1.222 +
   1.223 +  virtual PIndexedDBRequestChild*
   1.224 +  AllocPIndexedDBRequestChild(const ObjectStoreRequestParams& aParams) MOZ_OVERRIDE;
   1.225 +
   1.226 +  virtual bool
   1.227 +  DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE;
   1.228 +
   1.229 +  virtual PIndexedDBIndexChild*
   1.230 +  AllocPIndexedDBIndexChild(const IndexConstructorParams& aParams) MOZ_OVERRIDE;
   1.231 +
   1.232 +  virtual bool
   1.233 +  DeallocPIndexedDBIndexChild(PIndexedDBIndexChild* aActor) MOZ_OVERRIDE;
   1.234 +
   1.235 +  virtual PIndexedDBCursorChild*
   1.236 +  AllocPIndexedDBCursorChild(const ObjectStoreCursorConstructorParams& aParams)
   1.237 +                             MOZ_OVERRIDE;
   1.238 +
   1.239 +  virtual bool
   1.240 +  DeallocPIndexedDBCursorChild(PIndexedDBCursorChild* aActor) MOZ_OVERRIDE;
   1.241 +};
   1.242 +
   1.243 +/*******************************************************************************
   1.244 + * IndexedDBIndexChild
   1.245 + ******************************************************************************/
   1.246 +
   1.247 +class IndexedDBIndexChild : public PIndexedDBIndexChild
   1.248 +{
   1.249 +  IDBIndex* mIndex;
   1.250 +
   1.251 +public:
   1.252 +  IndexedDBIndexChild(IDBIndex* aIndex);
   1.253 +  virtual ~IndexedDBIndexChild();
   1.254 +
   1.255 +  void
   1.256 +  Disconnect();
   1.257 +
   1.258 +protected:
   1.259 +  virtual void
   1.260 +  ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   1.261 +
   1.262 +  virtual bool
   1.263 +  RecvPIndexedDBCursorConstructor(PIndexedDBCursorChild* aActor,
   1.264 +                                  const IndexCursorConstructorParams& aParams)
   1.265 +                                  MOZ_OVERRIDE;
   1.266 +
   1.267 +  virtual PIndexedDBRequestChild*
   1.268 +  AllocPIndexedDBRequestChild(const IndexRequestParams& aParams) MOZ_OVERRIDE;
   1.269 +
   1.270 +  virtual bool
   1.271 +  DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE;
   1.272 +
   1.273 +  virtual PIndexedDBCursorChild*
   1.274 +  AllocPIndexedDBCursorChild(const IndexCursorConstructorParams& aParams)
   1.275 +                             MOZ_OVERRIDE;
   1.276 +
   1.277 +  virtual bool
   1.278 +  DeallocPIndexedDBCursorChild(PIndexedDBCursorChild* aActor) MOZ_OVERRIDE;
   1.279 +};
   1.280 +
   1.281 +/*******************************************************************************
   1.282 + * IndexedDBCursorChild
   1.283 + ******************************************************************************/
   1.284 +
   1.285 +class IndexedDBCursorChild : public PIndexedDBCursorChild
   1.286 +{
   1.287 +  IDBCursor* mCursor;
   1.288 +
   1.289 +  nsRefPtr<IDBCursor> mStrongCursor;
   1.290 +
   1.291 +public:
   1.292 +  IndexedDBCursorChild();
   1.293 +  virtual ~IndexedDBCursorChild();
   1.294 +
   1.295 +  void
   1.296 +  SetCursor(IDBCursor* aCursor);
   1.297 +
   1.298 +  already_AddRefed<IDBCursor>
   1.299 +  ForgetStrongCursor()
   1.300 +  {
   1.301 +    return mStrongCursor.forget();
   1.302 +  }
   1.303 +
   1.304 +  void
   1.305 +  Disconnect();
   1.306 +
   1.307 +protected:
   1.308 +  virtual void
   1.309 +  ActorDestroy(ActorDestroyReason aWhy) MOZ_OVERRIDE;
   1.310 +
   1.311 +  virtual PIndexedDBRequestChild*
   1.312 +  AllocPIndexedDBRequestChild(const CursorRequestParams& aParams) MOZ_OVERRIDE;
   1.313 +
   1.314 +  virtual bool
   1.315 +  DeallocPIndexedDBRequestChild(PIndexedDBRequestChild* aActor) MOZ_OVERRIDE;
   1.316 +};
   1.317 +
   1.318 +/*******************************************************************************
   1.319 + * IndexedDBRequestChildBase
   1.320 + ******************************************************************************/
   1.321 +
   1.322 +class IndexedDBRequestChildBase : public PIndexedDBRequestChild
   1.323 +{
   1.324 +protected:
   1.325 +  nsRefPtr<AsyncConnectionHelper> mHelper;
   1.326 +
   1.327 +public:
   1.328 +  IDBRequest*
   1.329 +  GetRequest() const;
   1.330 +
   1.331 +  void
   1.332 +  Disconnect();
   1.333 +
   1.334 +protected:
   1.335 +  IndexedDBRequestChildBase(AsyncConnectionHelper* aHelper);
   1.336 +  virtual ~IndexedDBRequestChildBase();
   1.337 +
   1.338 +  virtual bool
   1.339 +  Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
   1.340 +};
   1.341 +
   1.342 +/*******************************************************************************
   1.343 + * IndexedDBObjectStoreRequestChild
   1.344 + ******************************************************************************/
   1.345 +
   1.346 +class IndexedDBObjectStoreRequestChild : public IndexedDBRequestChildBase
   1.347 +{
   1.348 +  nsRefPtr<IDBObjectStore> mObjectStore;
   1.349 +
   1.350 +  typedef ipc::ObjectStoreRequestParams ParamsUnionType;
   1.351 +  typedef ParamsUnionType::Type RequestType;
   1.352 +  DebugOnly<RequestType> mRequestType;
   1.353 +
   1.354 +public:
   1.355 +  IndexedDBObjectStoreRequestChild(AsyncConnectionHelper* aHelper,
   1.356 +                                   IDBObjectStore* aObjectStore,
   1.357 +                                   RequestType aRequestType);
   1.358 +  virtual ~IndexedDBObjectStoreRequestChild();
   1.359 +
   1.360 +protected:
   1.361 +  virtual bool
   1.362 +  Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
   1.363 +};
   1.364 +
   1.365 +/*******************************************************************************
   1.366 + * IndexedDBIndexRequestChild
   1.367 + ******************************************************************************/
   1.368 +
   1.369 +class IndexedDBIndexRequestChild : public IndexedDBRequestChildBase
   1.370 +{
   1.371 +  nsRefPtr<IDBIndex> mIndex;
   1.372 +
   1.373 +  typedef ipc::IndexRequestParams ParamsUnionType;
   1.374 +  typedef ParamsUnionType::Type RequestType;
   1.375 +  DebugOnly<RequestType> mRequestType;
   1.376 +
   1.377 +public:
   1.378 +  IndexedDBIndexRequestChild(AsyncConnectionHelper* aHelper, IDBIndex* aIndex,
   1.379 +                             RequestType aRequestType);
   1.380 +  virtual ~IndexedDBIndexRequestChild();
   1.381 +
   1.382 +protected:
   1.383 +  virtual bool
   1.384 +  Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
   1.385 +};
   1.386 +
   1.387 +/*******************************************************************************
   1.388 + * IndexedDBCursorRequestChild
   1.389 + ******************************************************************************/
   1.390 +
   1.391 +class IndexedDBCursorRequestChild : public IndexedDBRequestChildBase
   1.392 +{
   1.393 +  nsRefPtr<IDBCursor> mCursor;
   1.394 +
   1.395 +  typedef ipc::CursorRequestParams ParamsUnionType;
   1.396 +  typedef ParamsUnionType::Type RequestType;
   1.397 +  DebugOnly<RequestType> mRequestType;
   1.398 +
   1.399 +public:
   1.400 +  IndexedDBCursorRequestChild(AsyncConnectionHelper* aHelper,
   1.401 +                              IDBCursor* aCursor,
   1.402 +                              RequestType aRequestType);
   1.403 +  virtual ~IndexedDBCursorRequestChild();
   1.404 +
   1.405 +protected:
   1.406 +  virtual bool
   1.407 +  Recv__delete__(const ResponseValue& aResponse) MOZ_OVERRIDE;
   1.408 +};
   1.409 +
   1.410 +/*******************************************************************************
   1.411 + * IndexedDBDeleteDatabaseRequestChild
   1.412 + ******************************************************************************/
   1.413 +
   1.414 +class IndexedDBDeleteDatabaseRequestChild :
   1.415 +  public PIndexedDBDeleteDatabaseRequestChild
   1.416 +{
   1.417 +  nsRefPtr<IDBFactory> mFactory;
   1.418 +  nsRefPtr<IDBOpenDBRequest> mOpenRequest;
   1.419 +  nsCString mDatabaseId;
   1.420 +
   1.421 +public:
   1.422 +  IndexedDBDeleteDatabaseRequestChild(IDBFactory* aFactory,
   1.423 +                                      IDBOpenDBRequest* aOpenRequest,
   1.424 +                                      const nsACString& aDatabaseId);
   1.425 +  virtual ~IndexedDBDeleteDatabaseRequestChild();
   1.426 +
   1.427 +protected:
   1.428 +  virtual bool
   1.429 +  Recv__delete__(const nsresult& aRv) MOZ_OVERRIDE;
   1.430 +
   1.431 +  virtual bool
   1.432 +  RecvBlocked(const uint64_t& aCurrentVersion) MOZ_OVERRIDE;
   1.433 +};
   1.434 +
   1.435 +END_INDEXEDDB_NAMESPACE
   1.436 +
   1.437 +#endif // mozilla_dom_indexeddb_ipc_indexeddbchild_h__

mercurial