Tue, 06 Jan 2015 21:39:09 +0100
Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_dom_MessageEvent_h_ |
michael@0 | 7 | #define mozilla_dom_MessageEvent_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "mozilla/dom/Event.h" |
michael@0 | 10 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 11 | #include "nsIDOMMessageEvent.h" |
michael@0 | 12 | #include "mozilla/dom/MessagePortList.h" |
michael@0 | 13 | |
michael@0 | 14 | namespace mozilla { |
michael@0 | 15 | namespace dom { |
michael@0 | 16 | |
michael@0 | 17 | class MessageEventInit; |
michael@0 | 18 | class MessagePort; |
michael@0 | 19 | class MessagePortBase; |
michael@0 | 20 | class MessagePortList; |
michael@0 | 21 | class OwningWindowProxyOrMessagePort; |
michael@0 | 22 | |
michael@0 | 23 | /** |
michael@0 | 24 | * Implements the MessageEvent event, used for cross-document messaging and |
michael@0 | 25 | * server-sent events. |
michael@0 | 26 | * |
michael@0 | 27 | * See http://www.whatwg.org/specs/web-apps/current-work/#messageevent for |
michael@0 | 28 | * further details. |
michael@0 | 29 | */ |
michael@0 | 30 | class MessageEvent : public Event, |
michael@0 | 31 | public nsIDOMMessageEvent |
michael@0 | 32 | { |
michael@0 | 33 | public: |
michael@0 | 34 | MessageEvent(EventTarget* aOwner, |
michael@0 | 35 | nsPresContext* aPresContext, |
michael@0 | 36 | WidgetEvent* aEvent); |
michael@0 | 37 | ~MessageEvent(); |
michael@0 | 38 | |
michael@0 | 39 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 40 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MessageEvent, Event) |
michael@0 | 41 | |
michael@0 | 42 | NS_DECL_NSIDOMMESSAGEEVENT |
michael@0 | 43 | |
michael@0 | 44 | // Forward to base class |
michael@0 | 45 | NS_FORWARD_TO_EVENT |
michael@0 | 46 | |
michael@0 | 47 | virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 48 | |
michael@0 | 49 | void GetData(JSContext* aCx, JS::MutableHandle<JS::Value> aData, |
michael@0 | 50 | ErrorResult& aRv); |
michael@0 | 51 | |
michael@0 | 52 | void GetSource(Nullable<OwningWindowProxyOrMessagePort>& aValue) const; |
michael@0 | 53 | |
michael@0 | 54 | MessagePortList* GetPorts() |
michael@0 | 55 | { |
michael@0 | 56 | return mPorts; |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | void SetPorts(MessagePortList* aPorts); |
michael@0 | 60 | |
michael@0 | 61 | // Non WebIDL methods |
michael@0 | 62 | void SetSource(mozilla::dom::MessagePort* aPort) |
michael@0 | 63 | { |
michael@0 | 64 | mPortSource = aPort; |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | void SetSource(nsPIDOMWindow* aWindow) |
michael@0 | 68 | { |
michael@0 | 69 | mWindowSource = aWindow; |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | static already_AddRefed<MessageEvent> |
michael@0 | 73 | Constructor(const GlobalObject& aGlobal, JSContext* aCx, |
michael@0 | 74 | const nsAString& aType, |
michael@0 | 75 | const MessageEventInit& aEventInit, |
michael@0 | 76 | ErrorResult& aRv); |
michael@0 | 77 | |
michael@0 | 78 | private: |
michael@0 | 79 | JS::Heap<JS::Value> mData; |
michael@0 | 80 | nsString mOrigin; |
michael@0 | 81 | nsString mLastEventId; |
michael@0 | 82 | nsCOMPtr<nsIDOMWindow> mWindowSource; |
michael@0 | 83 | nsRefPtr<MessagePortBase> mPortSource; |
michael@0 | 84 | nsRefPtr<MessagePortList> mPorts; |
michael@0 | 85 | }; |
michael@0 | 86 | |
michael@0 | 87 | } // namespace dom |
michael@0 | 88 | } // namespace mozilla |
michael@0 | 89 | |
michael@0 | 90 | #endif // mozilla_dom_MessageEvent_h_ |