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 | /* vim:set ts=2 sw=2 et tw=78: */ |
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_TextTrack_h |
michael@0 | 8 | #define mozilla_dom_TextTrack_h |
michael@0 | 9 | |
michael@0 | 10 | #include "mozilla/DOMEventTargetHelper.h" |
michael@0 | 11 | #include "mozilla/dom/TextTrackBinding.h" |
michael@0 | 12 | #include "nsCOMPtr.h" |
michael@0 | 13 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 14 | #include "nsString.h" |
michael@0 | 15 | |
michael@0 | 16 | namespace mozilla { |
michael@0 | 17 | namespace dom { |
michael@0 | 18 | |
michael@0 | 19 | class TextTrackList; |
michael@0 | 20 | class TextTrackCue; |
michael@0 | 21 | class TextTrackCueList; |
michael@0 | 22 | class TextTrackRegion; |
michael@0 | 23 | class HTMLTrackElement; |
michael@0 | 24 | |
michael@0 | 25 | enum TextTrackSource { |
michael@0 | 26 | Track, |
michael@0 | 27 | AddTextTrack, |
michael@0 | 28 | MediaResourceSpecific |
michael@0 | 29 | }; |
michael@0 | 30 | |
michael@0 | 31 | // Constants for numeric readyState property values. |
michael@0 | 32 | enum TextTrackReadyState { |
michael@0 | 33 | NotLoaded = 0U, |
michael@0 | 34 | Loading = 1U, |
michael@0 | 35 | Loaded = 2U, |
michael@0 | 36 | FailedToLoad = 3U |
michael@0 | 37 | }; |
michael@0 | 38 | |
michael@0 | 39 | class TextTrack MOZ_FINAL : public DOMEventTargetHelper |
michael@0 | 40 | { |
michael@0 | 41 | public: |
michael@0 | 42 | NS_DECL_ISUPPORTS_INHERITED |
michael@0 | 43 | NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TextTrack, DOMEventTargetHelper) |
michael@0 | 44 | |
michael@0 | 45 | TextTrack(nsPIDOMWindow* aOwnerWindow, |
michael@0 | 46 | TextTrackKind aKind, |
michael@0 | 47 | const nsAString& aLabel, |
michael@0 | 48 | const nsAString& aLanguage, |
michael@0 | 49 | TextTrackMode aMode, |
michael@0 | 50 | TextTrackReadyState aReadyState, |
michael@0 | 51 | TextTrackSource aTextTrackSource); |
michael@0 | 52 | TextTrack(nsPIDOMWindow* aOwnerWindow, |
michael@0 | 53 | TextTrackList* aTextTrackList, |
michael@0 | 54 | TextTrackKind aKind, |
michael@0 | 55 | const nsAString& aLabel, |
michael@0 | 56 | const nsAString& aLanguage, |
michael@0 | 57 | TextTrackMode aMode, |
michael@0 | 58 | TextTrackReadyState aReadyState, |
michael@0 | 59 | TextTrackSource aTextTrackSource); |
michael@0 | 60 | |
michael@0 | 61 | void SetDefaultSettings(); |
michael@0 | 62 | |
michael@0 | 63 | virtual JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 64 | |
michael@0 | 65 | TextTrackKind Kind() const |
michael@0 | 66 | { |
michael@0 | 67 | return mKind; |
michael@0 | 68 | } |
michael@0 | 69 | void GetLabel(nsAString& aLabel) const |
michael@0 | 70 | { |
michael@0 | 71 | aLabel = mLabel; |
michael@0 | 72 | } |
michael@0 | 73 | void GetLanguage(nsAString& aLanguage) const |
michael@0 | 74 | { |
michael@0 | 75 | aLanguage = mLanguage; |
michael@0 | 76 | } |
michael@0 | 77 | void GetInBandMetadataTrackDispatchType(nsAString& aType) const |
michael@0 | 78 | { |
michael@0 | 79 | aType = mType; |
michael@0 | 80 | } |
michael@0 | 81 | void GetId(nsAString& aId) const; |
michael@0 | 82 | |
michael@0 | 83 | TextTrackMode Mode() const |
michael@0 | 84 | { |
michael@0 | 85 | return mMode; |
michael@0 | 86 | } |
michael@0 | 87 | void SetMode(TextTrackMode aValue); |
michael@0 | 88 | |
michael@0 | 89 | TextTrackCueList* GetCues() const |
michael@0 | 90 | { |
michael@0 | 91 | if (mMode == TextTrackMode::Disabled) { |
michael@0 | 92 | return nullptr; |
michael@0 | 93 | } |
michael@0 | 94 | return mCueList; |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | TextTrackCueList* GetActiveCues(); |
michael@0 | 98 | void UpdateActiveCueList(); |
michael@0 | 99 | void GetActiveCueArray(nsTArray<nsRefPtr<TextTrackCue> >& aCues); |
michael@0 | 100 | |
michael@0 | 101 | TextTrackReadyState ReadyState() const; |
michael@0 | 102 | void SetReadyState(TextTrackReadyState aState); |
michael@0 | 103 | void SetReadyState(uint32_t aReadyState); |
michael@0 | 104 | |
michael@0 | 105 | void AddCue(TextTrackCue& aCue); |
michael@0 | 106 | void RemoveCue(TextTrackCue& aCue, ErrorResult& aRv); |
michael@0 | 107 | void SetDirty() { mDirty = true; } |
michael@0 | 108 | void SetCuesDirty(); |
michael@0 | 109 | |
michael@0 | 110 | TextTrackList* GetTextTrackList(); |
michael@0 | 111 | void SetTextTrackList(TextTrackList* aTextTrackList); |
michael@0 | 112 | |
michael@0 | 113 | IMPL_EVENT_HANDLER(cuechange) |
michael@0 | 114 | |
michael@0 | 115 | HTMLTrackElement* GetTrackElement(); |
michael@0 | 116 | void SetTrackElement(HTMLTrackElement* aTrackElement); |
michael@0 | 117 | |
michael@0 | 118 | TextTrackSource GetTextTrackSource() { |
michael@0 | 119 | return mTextTrackSource; |
michael@0 | 120 | } |
michael@0 | 121 | |
michael@0 | 122 | private: |
michael@0 | 123 | nsRefPtr<TextTrackList> mTextTrackList; |
michael@0 | 124 | |
michael@0 | 125 | TextTrackKind mKind; |
michael@0 | 126 | nsString mLabel; |
michael@0 | 127 | nsString mLanguage; |
michael@0 | 128 | nsString mType; |
michael@0 | 129 | TextTrackMode mMode; |
michael@0 | 130 | |
michael@0 | 131 | nsRefPtr<TextTrackCueList> mCueList; |
michael@0 | 132 | nsRefPtr<TextTrackCueList> mActiveCueList; |
michael@0 | 133 | nsRefPtr<HTMLTrackElement> mTrackElement; |
michael@0 | 134 | |
michael@0 | 135 | uint32_t mCuePos; |
michael@0 | 136 | TextTrackReadyState mReadyState; |
michael@0 | 137 | bool mDirty; |
michael@0 | 138 | |
michael@0 | 139 | // An enum that represents where the track was sourced from. |
michael@0 | 140 | TextTrackSource mTextTrackSource; |
michael@0 | 141 | }; |
michael@0 | 142 | |
michael@0 | 143 | } // namespace dom |
michael@0 | 144 | } // namespace mozilla |
michael@0 | 145 | |
michael@0 | 146 | #endif // mozilla_dom_TextTrack_h |