summaryrefslogtreecommitdiffstats
path: root/dom/indexedDB/IDBFactory.h
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/indexedDB/IDBFactory.h
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/indexedDB/IDBFactory.h')
-rw-r--r--dom/indexedDB/IDBFactory.h258
1 files changed, 258 insertions, 0 deletions
diff --git a/dom/indexedDB/IDBFactory.h b/dom/indexedDB/IDBFactory.h
new file mode 100644
index 000000000..15c53530d
--- /dev/null
+++ b/dom/indexedDB/IDBFactory.h
@@ -0,0 +1,258 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_dom_idbfactory_h__
+#define mozilla_dom_idbfactory_h__
+
+#include "mozilla/Attributes.h"
+#include "mozilla/dom/StorageTypeBinding.h"
+#include "nsAutoPtr.h"
+#include "nsCOMPtr.h"
+#include "nsCycleCollectionParticipant.h"
+#include "nsISupports.h"
+#include "nsString.h"
+#include "nsTArray.h"
+#include "nsWrapperCache.h"
+
+class nsIPrincipal;
+class nsPIDOMWindowInner;
+struct PRThread;
+
+namespace mozilla {
+
+class ErrorResult;
+
+namespace ipc {
+
+class PBackgroundChild;
+class PrincipalInfo;
+
+} // namespace ipc
+
+namespace dom {
+
+struct IDBOpenDBOptions;
+class IDBOpenDBRequest;
+template <typename> class Optional;
+class TabChild;
+
+namespace indexedDB {
+class BackgroundFactoryChild;
+class FactoryRequestParams;
+class LoggingInfo;
+}
+
+class IDBFactory final
+ : public nsISupports
+ , public nsWrapperCache
+{
+ typedef mozilla::dom::StorageType StorageType;
+ typedef mozilla::ipc::PBackgroundChild PBackgroundChild;
+ typedef mozilla::ipc::PrincipalInfo PrincipalInfo;
+
+ class BackgroundCreateCallback;
+ struct PendingRequestInfo;
+
+ nsAutoPtr<PrincipalInfo> mPrincipalInfo;
+
+ // If this factory lives on a window then mWindow must be non-null. Otherwise
+ // mOwningObject must be non-null.
+ nsCOMPtr<nsPIDOMWindowInner> mWindow;
+ JS::Heap<JSObject*> mOwningObject;
+
+ // This will only be set if the factory belongs to a window in a child
+ // process.
+ RefPtr<TabChild> mTabChild;
+
+ nsTArray<nsAutoPtr<PendingRequestInfo>> mPendingRequests;
+
+ indexedDB::BackgroundFactoryChild* mBackgroundActor;
+
+#ifdef DEBUG
+ PRThread* mOwningThread;
+#endif
+
+ uint64_t mInnerWindowID;
+
+ bool mBackgroundActorFailed;
+ bool mPrivateBrowsingMode;
+
+public:
+ static nsresult
+ CreateForWindow(nsPIDOMWindowInner* aWindow,
+ IDBFactory** aFactory);
+
+ static nsresult
+ CreateForMainThreadJS(JSContext* aCx,
+ JS::Handle<JSObject*> aOwningObject,
+ IDBFactory** aFactory);
+
+ static nsresult
+ CreateForWorker(JSContext* aCx,
+ JS::Handle<JSObject*> aOwningObject,
+ const PrincipalInfo& aPrincipalInfo,
+ uint64_t aInnerWindowID,
+ IDBFactory** aFactory);
+
+ static bool
+ AllowedForWindow(nsPIDOMWindowInner* aWindow);
+
+ static bool
+ AllowedForPrincipal(nsIPrincipal* aPrincipal,
+ bool* aIsSystemPrincipal = nullptr);
+
+#ifdef DEBUG
+ void
+ AssertIsOnOwningThread() const;
+
+ PRThread*
+ OwningThread() const;
+#else
+ void
+ AssertIsOnOwningThread() const
+ { }
+#endif
+
+ void
+ ClearBackgroundActor()
+ {
+ AssertIsOnOwningThread();
+
+ mBackgroundActor = nullptr;
+ }
+
+ void
+ IncrementParentLoggingRequestSerialNumber();
+
+ nsPIDOMWindowInner*
+ GetParentObject() const
+ {
+ return mWindow;
+ }
+
+ TabChild*
+ GetTabChild() const
+ {
+ return mTabChild;
+ }
+
+ PrincipalInfo*
+ GetPrincipalInfo() const
+ {
+ AssertIsOnOwningThread();
+
+ return mPrincipalInfo;
+ }
+
+ uint64_t
+ InnerWindowID() const
+ {
+ AssertIsOnOwningThread();
+
+ return mInnerWindowID;
+ }
+
+ bool
+ IsChrome() const;
+
+ already_AddRefed<IDBOpenDBRequest>
+ Open(JSContext* aCx,
+ const nsAString& aName,
+ uint64_t aVersion,
+ ErrorResult& aRv);
+
+ already_AddRefed<IDBOpenDBRequest>
+ Open(JSContext* aCx,
+ const nsAString& aName,
+ const IDBOpenDBOptions& aOptions,
+ ErrorResult& aRv);
+
+ already_AddRefed<IDBOpenDBRequest>
+ DeleteDatabase(JSContext* aCx,
+ const nsAString& aName,
+ const IDBOpenDBOptions& aOptions,
+ ErrorResult& aRv);
+
+ int16_t
+ Cmp(JSContext* aCx,
+ JS::Handle<JS::Value> aFirst,
+ JS::Handle<JS::Value> aSecond,
+ ErrorResult& aRv);
+
+ already_AddRefed<IDBOpenDBRequest>
+ OpenForPrincipal(JSContext* aCx,
+ nsIPrincipal* aPrincipal,
+ const nsAString& aName,
+ uint64_t aVersion,
+ ErrorResult& aRv);
+
+ already_AddRefed<IDBOpenDBRequest>
+ OpenForPrincipal(JSContext* aCx,
+ nsIPrincipal* aPrincipal,
+ const nsAString& aName,
+ const IDBOpenDBOptions& aOptions,
+ ErrorResult& aRv);
+
+ already_AddRefed<IDBOpenDBRequest>
+ DeleteForPrincipal(JSContext* aCx,
+ nsIPrincipal* aPrincipal,
+ const nsAString& aName,
+ const IDBOpenDBOptions& aOptions,
+ ErrorResult& aRv);
+
+ NS_DECL_CYCLE_COLLECTING_ISUPPORTS
+ NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBFactory)
+
+ // nsWrapperCache
+ virtual JSObject*
+ WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
+
+private:
+ IDBFactory();
+ ~IDBFactory();
+
+ static nsresult
+ CreateForMainThreadJSInternal(JSContext* aCx,
+ JS::Handle<JSObject*> aOwningObject,
+ nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
+ IDBFactory** aFactory);
+
+ static nsresult
+ CreateForJSInternal(JSContext* aCx,
+ JS::Handle<JSObject*> aOwningObject,
+ nsAutoPtr<PrincipalInfo>& aPrincipalInfo,
+ uint64_t aInnerWindowID,
+ IDBFactory** aFactory);
+
+ static nsresult
+ AllowedForWindowInternal(nsPIDOMWindowInner* aWindow,
+ nsIPrincipal** aPrincipal);
+
+ already_AddRefed<IDBOpenDBRequest>
+ OpenInternal(JSContext* aCx,
+ nsIPrincipal* aPrincipal,
+ const nsAString& aName,
+ const Optional<uint64_t>& aVersion,
+ const Optional<StorageType>& aStorageType,
+ bool aDeleting,
+ ErrorResult& aRv);
+
+ nsresult
+ BackgroundActorCreated(PBackgroundChild* aBackgroundActor,
+ const indexedDB::LoggingInfo& aLoggingInfo);
+
+ void
+ BackgroundActorFailed();
+
+ nsresult
+ InitiateRequest(IDBOpenDBRequest* aRequest,
+ const indexedDB::FactoryRequestParams& aParams);
+};
+
+} // namespace dom
+} // namespace mozilla
+
+#endif // mozilla_dom_idbfactory_h__