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_WebVTTLoadListener_h |
michael@0 | 7 | #define mozilla_dom_WebVTTLoadListener_h |
michael@0 | 8 | |
michael@0 | 9 | #include "nsIWebVTTListener.h" |
michael@0 | 10 | #include "nsIStreamListener.h" |
michael@0 | 11 | #include "nsIChannelEventSink.h" |
michael@0 | 12 | #include "nsAutoPtr.h" |
michael@0 | 13 | #include "nsIInterfaceRequestor.h" |
michael@0 | 14 | #include "nsCycleCollectionParticipant.h" |
michael@0 | 15 | |
michael@0 | 16 | class nsIWebVTTParserWrapper; |
michael@0 | 17 | |
michael@0 | 18 | namespace mozilla { |
michael@0 | 19 | namespace dom { |
michael@0 | 20 | |
michael@0 | 21 | class HTMLTrackElement; |
michael@0 | 22 | |
michael@0 | 23 | class WebVTTListener MOZ_FINAL : public nsIWebVTTListener, |
michael@0 | 24 | public nsIStreamListener, |
michael@0 | 25 | public nsIChannelEventSink, |
michael@0 | 26 | public nsIInterfaceRequestor |
michael@0 | 27 | { |
michael@0 | 28 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 29 | NS_DECL_NSIWEBVTTLISTENER |
michael@0 | 30 | NS_DECL_NSIREQUESTOBSERVER |
michael@0 | 31 | NS_DECL_NSISTREAMLISTENER |
michael@0 | 32 | NS_DECL_NSICHANNELEVENTSINK |
michael@0 | 33 | NS_DECL_NSIINTERFACEREQUESTOR |
michael@0 | 34 | |
michael@0 | 35 | NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(WebVTTListener, |
michael@0 | 36 | nsIStreamListener) |
michael@0 | 37 | |
michael@0 | 38 | public: |
michael@0 | 39 | WebVTTListener(HTMLTrackElement* aElement); |
michael@0 | 40 | ~WebVTTListener(); |
michael@0 | 41 | |
michael@0 | 42 | /** |
michael@0 | 43 | * Loads the WebVTTListener. Must call this in order for the listener to be |
michael@0 | 44 | * ready to parse data that is passed to it. |
michael@0 | 45 | */ |
michael@0 | 46 | nsresult LoadResource(); |
michael@0 | 47 | |
michael@0 | 48 | private: |
michael@0 | 49 | // List of error codes returned from the WebVTT parser that we care about. |
michael@0 | 50 | enum ErrorCodes { |
michael@0 | 51 | BadSignature = 0 |
michael@0 | 52 | }; |
michael@0 | 53 | static NS_METHOD ParseChunk(nsIInputStream* aInStream, void* aClosure, |
michael@0 | 54 | const char* aFromSegment, uint32_t aToOffset, |
michael@0 | 55 | uint32_t aCount, uint32_t* aWriteCount); |
michael@0 | 56 | |
michael@0 | 57 | nsRefPtr<HTMLTrackElement> mElement; |
michael@0 | 58 | nsCOMPtr<nsIWebVTTParserWrapper> mParserWrapper; |
michael@0 | 59 | }; |
michael@0 | 60 | |
michael@0 | 61 | } // namespace dom |
michael@0 | 62 | } // namespace mozilla |
michael@0 | 63 | |
michael@0 | 64 | #endif // mozilla_dom_WebVTTListener_h |