Sat, 03 Jan 2015 20:18:00 +0100
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.
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_domrequest_h__
8 #define mozilla_dom_domrequest_h__
10 #include "nsIDOMDOMRequest.h"
11 #include "mozilla/Attributes.h"
12 #include "mozilla/DOMEventTargetHelper.h"
13 #include "mozilla/dom/DOMRequestBinding.h"
15 #include "nsCOMPtr.h"
17 namespace mozilla {
18 namespace dom {
20 class DOMRequest : public DOMEventTargetHelper,
21 public nsIDOMDOMRequest
22 {
23 protected:
24 JS::Heap<JS::Value> mResult;
25 nsCOMPtr<nsISupports> mError;
26 bool mDone;
28 public:
29 NS_DECL_ISUPPORTS_INHERITED
30 NS_DECL_NSIDOMDOMREQUEST
31 NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
33 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(DOMRequest,
34 DOMEventTargetHelper)
36 // WrapperCache
37 nsPIDOMWindow* GetParentObject() const
38 {
39 return GetOwner();
40 }
42 virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE;
44 // WebIDL Interface
45 DOMRequestReadyState ReadyState() const
46 {
47 return mDone ? DOMRequestReadyState::Done
48 : DOMRequestReadyState::Pending;
49 }
51 void GetResult(JSContext*, JS::MutableHandle<JS::Value> aRetval) const
52 {
53 NS_ASSERTION(mDone || mResult == JSVAL_VOID,
54 "Result should be undefined when pending");
55 JS::ExposeValueToActiveJS(mResult);
56 aRetval.set(mResult);
57 }
59 nsISupports* GetError() const
60 {
61 NS_ASSERTION(mDone || !mError,
62 "Error should be null when pending");
63 return mError;
64 }
66 IMPL_EVENT_HANDLER(success)
67 IMPL_EVENT_HANDLER(error)
70 void FireSuccess(JS::Handle<JS::Value> aResult);
71 void FireError(const nsAString& aError);
72 void FireError(nsresult aError);
73 void FireDetailedError(nsISupports* aError);
75 DOMRequest(nsPIDOMWindow* aWindow);
77 virtual ~DOMRequest()
78 {
79 mResult = JSVAL_VOID;
80 mozilla::DropJSObjects(this);
81 }
83 protected:
84 void FireEvent(const nsAString& aType, bool aBubble, bool aCancelable);
86 void RootResultVal();
87 };
89 class DOMRequestService MOZ_FINAL : public nsIDOMRequestService
90 {
91 public:
92 NS_DECL_ISUPPORTS
93 NS_DECL_NSIDOMREQUESTSERVICE
95 // Returns an owning reference! No one should call this but the factory.
96 static DOMRequestService* FactoryCreate()
97 {
98 DOMRequestService* res = new DOMRequestService;
99 NS_ADDREF(res);
100 return res;
101 }
102 };
104 } // namespace dom
105 } // namespace mozilla
107 #define DOMREQUEST_SERVICE_CONTRACTID "@mozilla.org/dom/dom-request-service;1"
109 #endif // mozilla_dom_domrequest_h__