dom/indexedDB/IDBRequest.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_indexeddb_idbrequest_h__
michael@0 8 #define mozilla_dom_indexeddb_idbrequest_h__
michael@0 9
michael@0 10 #include "mozilla/dom/indexedDB/IndexedDatabase.h"
michael@0 11
michael@0 12 #include "mozilla/Attributes.h"
michael@0 13 #include "mozilla/EventForwards.h"
michael@0 14 #include "mozilla/dom/DOMError.h"
michael@0 15 #include "mozilla/dom/IDBRequestBinding.h"
michael@0 16 #include "mozilla/ErrorResult.h"
michael@0 17 #include "nsCycleCollectionParticipant.h"
michael@0 18 #include "nsWrapperCache.h"
michael@0 19
michael@0 20 #include "mozilla/dom/indexedDB/IDBWrapperCache.h"
michael@0 21
michael@0 22 class nsIScriptContext;
michael@0 23 class nsPIDOMWindow;
michael@0 24
michael@0 25 namespace mozilla {
michael@0 26 class EventChainPostVisitor;
michael@0 27 class EventChainPreVisitor;
michael@0 28 namespace dom {
michael@0 29 class OwningIDBObjectStoreOrIDBIndexOrIDBCursor;
michael@0 30 class ErrorEventInit;
michael@0 31 }
michael@0 32 }
michael@0 33
michael@0 34 BEGIN_INDEXEDDB_NAMESPACE
michael@0 35
michael@0 36 class HelperBase;
michael@0 37 class IDBCursor;
michael@0 38 class IDBFactory;
michael@0 39 class IDBIndex;
michael@0 40 class IDBObjectStore;
michael@0 41 class IDBTransaction;
michael@0 42 class IndexedDBRequestParentBase;
michael@0 43
michael@0 44 class IDBRequest : public IDBWrapperCache
michael@0 45 {
michael@0 46 public:
michael@0 47 NS_DECL_ISUPPORTS_INHERITED
michael@0 48 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(IDBRequest,
michael@0 49 IDBWrapperCache)
michael@0 50
michael@0 51 static
michael@0 52 already_AddRefed<IDBRequest> Create(IDBDatabase* aDatabase,
michael@0 53 IDBTransaction* aTransaction);
michael@0 54
michael@0 55 static
michael@0 56 already_AddRefed<IDBRequest> Create(IDBObjectStore* aSource,
michael@0 57 IDBDatabase* aDatabase,
michael@0 58 IDBTransaction* aTransaction);
michael@0 59
michael@0 60 static
michael@0 61 already_AddRefed<IDBRequest> Create(IDBIndex* aSource,
michael@0 62 IDBDatabase* aDatabase,
michael@0 63 IDBTransaction* aTransaction);
michael@0 64
michael@0 65 // nsIDOMEventTarget
michael@0 66 virtual nsresult PreHandleEvent(EventChainPreVisitor& aVisitor) MOZ_OVERRIDE;
michael@0 67
michael@0 68 void GetSource(Nullable<OwningIDBObjectStoreOrIDBIndexOrIDBCursor>& aSource) const;
michael@0 69
michael@0 70 void Reset();
michael@0 71
michael@0 72 nsresult NotifyHelperCompleted(HelperBase* aHelper);
michael@0 73 void NotifyHelperSentResultsToChildProcess(nsresult aRv);
michael@0 74
michael@0 75 void SetError(nsresult aRv);
michael@0 76
michael@0 77 nsresult
michael@0 78 GetErrorCode() const
michael@0 79 #ifdef DEBUG
michael@0 80 ;
michael@0 81 #else
michael@0 82 {
michael@0 83 return mErrorCode;
michael@0 84 }
michael@0 85 #endif
michael@0 86
michael@0 87 DOMError* GetError(ErrorResult& aRv);
michael@0 88
michael@0 89 JSContext* GetJSContext();
michael@0 90
michael@0 91 void
michael@0 92 SetActor(IndexedDBRequestParentBase* aActorParent)
michael@0 93 {
michael@0 94 NS_ASSERTION(!aActorParent || !mActorParent,
michael@0 95 "Shouldn't have more than one!");
michael@0 96 mActorParent = aActorParent;
michael@0 97 }
michael@0 98
michael@0 99 IndexedDBRequestParentBase*
michael@0 100 GetActorParent() const
michael@0 101 {
michael@0 102 return mActorParent;
michael@0 103 }
michael@0 104
michael@0 105 void CaptureCaller();
michael@0 106
michael@0 107 void FillScriptErrorEvent(ErrorEventInit& aEventInit) const;
michael@0 108
michael@0 109 bool
michael@0 110 IsPending() const
michael@0 111 {
michael@0 112 return !mHaveResultOrErrorCode;
michael@0 113 }
michael@0 114
michael@0 115 #ifdef MOZ_ENABLE_PROFILER_SPS
michael@0 116 uint64_t
michael@0 117 GetSerialNumber() const
michael@0 118 {
michael@0 119 return mSerialNumber;
michael@0 120 }
michael@0 121 #endif
michael@0 122
michael@0 123 // nsWrapperCache
michael@0 124 virtual JSObject*
michael@0 125 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 126
michael@0 127 // WebIDL
michael@0 128 nsPIDOMWindow*
michael@0 129 GetParentObject() const
michael@0 130 {
michael@0 131 return GetOwner();
michael@0 132 }
michael@0 133
michael@0 134 void
michael@0 135 GetResult(JSContext* aCx, JS::MutableHandle<JS::Value> aResult,
michael@0 136 ErrorResult& aRv) const;
michael@0 137
michael@0 138 IDBTransaction*
michael@0 139 GetTransaction() const
michael@0 140 {
michael@0 141 NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
michael@0 142 return mTransaction;
michael@0 143 }
michael@0 144
michael@0 145 IDBRequestReadyState
michael@0 146 ReadyState() const;
michael@0 147
michael@0 148 IMPL_EVENT_HANDLER(success);
michael@0 149 IMPL_EVENT_HANDLER(error);
michael@0 150
michael@0 151 protected:
michael@0 152 IDBRequest(IDBDatabase* aDatabase);
michael@0 153 IDBRequest(nsPIDOMWindow* aOwner);
michael@0 154 ~IDBRequest();
michael@0 155
michael@0 156 // At most one of these three fields can be non-null.
michael@0 157 nsRefPtr<IDBObjectStore> mSourceAsObjectStore;
michael@0 158 nsRefPtr<IDBIndex> mSourceAsIndex;
michael@0 159 nsRefPtr<IDBCursor> mSourceAsCursor;
michael@0 160
michael@0 161 // Check that the above condition holds.
michael@0 162 #ifdef DEBUG
michael@0 163 void AssertSourceIsCorrect() const;
michael@0 164 #else
michael@0 165 void AssertSourceIsCorrect() const {}
michael@0 166 #endif
michael@0 167
michael@0 168 nsRefPtr<IDBTransaction> mTransaction;
michael@0 169
michael@0 170 JS::Heap<JS::Value> mResultVal;
michael@0 171 nsRefPtr<mozilla::dom::DOMError> mError;
michael@0 172 IndexedDBRequestParentBase* mActorParent;
michael@0 173 nsString mFilename;
michael@0 174 #ifdef MOZ_ENABLE_PROFILER_SPS
michael@0 175 uint64_t mSerialNumber;
michael@0 176 #endif
michael@0 177 nsresult mErrorCode;
michael@0 178 uint32_t mLineNo;
michael@0 179 bool mHaveResultOrErrorCode;
michael@0 180 };
michael@0 181
michael@0 182 class IDBOpenDBRequest : public IDBRequest
michael@0 183 {
michael@0 184 public:
michael@0 185 NS_DECL_ISUPPORTS_INHERITED
michael@0 186 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBOpenDBRequest, IDBRequest)
michael@0 187
michael@0 188 static
michael@0 189 already_AddRefed<IDBOpenDBRequest>
michael@0 190 Create(IDBFactory* aFactory,
michael@0 191 nsPIDOMWindow* aOwner,
michael@0 192 JS::Handle<JSObject*> aScriptOwner);
michael@0 193
michael@0 194 void SetTransaction(IDBTransaction* aTransaction);
michael@0 195
michael@0 196 // nsIDOMEventTarget
michael@0 197 virtual nsresult PostHandleEvent(
michael@0 198 EventChainPostVisitor& aVisitor) MOZ_OVERRIDE;
michael@0 199
michael@0 200 DOMError* GetError(ErrorResult& aRv)
michael@0 201 {
michael@0 202 return IDBRequest::GetError(aRv);
michael@0 203 }
michael@0 204
michael@0 205 IDBFactory*
michael@0 206 Factory() const
michael@0 207 {
michael@0 208 return mFactory;
michael@0 209 }
michael@0 210
michael@0 211 // nsWrapperCache
michael@0 212 virtual JSObject*
michael@0 213 WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 214
michael@0 215 // WebIDL
michael@0 216 IMPL_EVENT_HANDLER(blocked);
michael@0 217 IMPL_EVENT_HANDLER(upgradeneeded);
michael@0 218
michael@0 219 protected:
michael@0 220 IDBOpenDBRequest(nsPIDOMWindow* aOwner);
michael@0 221 ~IDBOpenDBRequest();
michael@0 222
michael@0 223 // Only touched on the main thread.
michael@0 224 nsRefPtr<IDBFactory> mFactory;
michael@0 225 };
michael@0 226
michael@0 227 END_INDEXEDDB_NAMESPACE
michael@0 228
michael@0 229 #endif // mozilla_dom_indexeddb_idbrequest_h__

mercurial