michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_WebVTTLoadListener_h michael@0: #define mozilla_dom_WebVTTLoadListener_h michael@0: michael@0: #include "nsIWebVTTListener.h" michael@0: #include "nsIStreamListener.h" michael@0: #include "nsIChannelEventSink.h" michael@0: #include "nsAutoPtr.h" michael@0: #include "nsIInterfaceRequestor.h" michael@0: #include "nsCycleCollectionParticipant.h" michael@0: michael@0: class nsIWebVTTParserWrapper; michael@0: michael@0: namespace mozilla { michael@0: namespace dom { michael@0: michael@0: class HTMLTrackElement; michael@0: michael@0: class WebVTTListener MOZ_FINAL : public nsIWebVTTListener, michael@0: public nsIStreamListener, michael@0: public nsIChannelEventSink, michael@0: public nsIInterfaceRequestor michael@0: { michael@0: NS_DECL_CYCLE_COLLECTING_ISUPPORTS michael@0: NS_DECL_NSIWEBVTTLISTENER michael@0: NS_DECL_NSIREQUESTOBSERVER michael@0: NS_DECL_NSISTREAMLISTENER michael@0: NS_DECL_NSICHANNELEVENTSINK michael@0: NS_DECL_NSIINTERFACEREQUESTOR michael@0: michael@0: NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(WebVTTListener, michael@0: nsIStreamListener) michael@0: michael@0: public: michael@0: WebVTTListener(HTMLTrackElement* aElement); michael@0: ~WebVTTListener(); michael@0: michael@0: /** michael@0: * Loads the WebVTTListener. Must call this in order for the listener to be michael@0: * ready to parse data that is passed to it. michael@0: */ michael@0: nsresult LoadResource(); michael@0: michael@0: private: michael@0: // List of error codes returned from the WebVTT parser that we care about. michael@0: enum ErrorCodes { michael@0: BadSignature = 0 michael@0: }; michael@0: static NS_METHOD ParseChunk(nsIInputStream* aInStream, void* aClosure, michael@0: const char* aFromSegment, uint32_t aToOffset, michael@0: uint32_t aCount, uint32_t* aWriteCount); michael@0: michael@0: nsRefPtr mElement; michael@0: nsCOMPtr mParserWrapper; michael@0: }; michael@0: michael@0: } // namespace dom michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_dom_WebVTTListener_h