dom/base/DOMRequest.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 file,
michael@0 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef mozilla_dom_domrequest_h__
michael@0 8 #define mozilla_dom_domrequest_h__
michael@0 9
michael@0 10 #include "nsIDOMDOMRequest.h"
michael@0 11 #include "mozilla/Attributes.h"
michael@0 12 #include "mozilla/DOMEventTargetHelper.h"
michael@0 13 #include "mozilla/dom/DOMRequestBinding.h"
michael@0 14
michael@0 15 #include "nsCOMPtr.h"
michael@0 16
michael@0 17 namespace mozilla {
michael@0 18 namespace dom {
michael@0 19
michael@0 20 class DOMRequest : public DOMEventTargetHelper,
michael@0 21 public nsIDOMDOMRequest
michael@0 22 {
michael@0 23 protected:
michael@0 24 JS::Heap<JS::Value> mResult;
michael@0 25 nsCOMPtr<nsISupports> mError;
michael@0 26 bool mDone;
michael@0 27
michael@0 28 public:
michael@0 29 NS_DECL_ISUPPORTS_INHERITED
michael@0 30 NS_DECL_NSIDOMDOMREQUEST
michael@0 31 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
michael@0 32
michael@0 33 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMRequest,
michael@0 34 DOMEventTargetHelper)
michael@0 35
michael@0 36 // WrapperCache
michael@0 37 nsPIDOMWindow* GetParentObject() const
michael@0 38 {
michael@0 39 return GetOwner();
michael@0 40 }
michael@0 41
michael@0 42 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
michael@0 43
michael@0 44 // WebIDL Interface
michael@0 45 DOMRequestReadyState ReadyState() const
michael@0 46 {
michael@0 47 return mDone ? DOMRequestReadyState::Done
michael@0 48 : DOMRequestReadyState::Pending;
michael@0 49 }
michael@0 50
michael@0 51 void GetResult(JSContext*, JS::MutableHandle<JS::Value> aRetval) const
michael@0 52 {
michael@0 53 NS_ASSERTION(mDone || mResult == JSVAL_VOID,
michael@0 54 "Result should be undefined when pending");
michael@0 55 JS::ExposeValueToActiveJS(mResult);
michael@0 56 aRetval.set(mResult);
michael@0 57 }
michael@0 58
michael@0 59 nsISupports* GetError() const
michael@0 60 {
michael@0 61 NS_ASSERTION(mDone || !mError,
michael@0 62 "Error should be null when pending");
michael@0 63 return mError;
michael@0 64 }
michael@0 65
michael@0 66 IMPL_EVENT_HANDLER(success)
michael@0 67 IMPL_EVENT_HANDLER(error)
michael@0 68
michael@0 69
michael@0 70 void FireSuccess(JS::Handle<JS::Value> aResult);
michael@0 71 void FireError(const nsAString& aError);
michael@0 72 void FireError(nsresult aError);
michael@0 73 void FireDetailedError(nsISupports* aError);
michael@0 74
michael@0 75 DOMRequest(nsPIDOMWindow* aWindow);
michael@0 76
michael@0 77 virtual ~DOMRequest()
michael@0 78 {
michael@0 79 mResult = JSVAL_VOID;
michael@0 80 mozilla::DropJSObjects(this);
michael@0 81 }
michael@0 82
michael@0 83 protected:
michael@0 84 void FireEvent(const nsAString& aType, bool aBubble, bool aCancelable);
michael@0 85
michael@0 86 void RootResultVal();
michael@0 87 };
michael@0 88
michael@0 89 class DOMRequestService MOZ_FINAL : public nsIDOMRequestService
michael@0 90 {
michael@0 91 public:
michael@0 92 NS_DECL_ISUPPORTS
michael@0 93 NS_DECL_NSIDOMREQUESTSERVICE
michael@0 94
michael@0 95 // Returns an owning reference! No one should call this but the factory.
michael@0 96 static DOMRequestService* FactoryCreate()
michael@0 97 {
michael@0 98 DOMRequestService* res = new DOMRequestService;
michael@0 99 NS_ADDREF(res);
michael@0 100 return res;
michael@0 101 }
michael@0 102 };
michael@0 103
michael@0 104 } // namespace dom
michael@0 105 } // namespace mozilla
michael@0 106
michael@0 107 #define DOMREQUEST_SERVICE_CONTRACTID "@mozilla.org/dom/dom-request-service;1"
michael@0 108
michael@0 109 #endif // mozilla_dom_domrequest_h__

mercurial