Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef mozilla_dom_WebVTTLoadListener_h
7 : #define mozilla_dom_WebVTTLoadListener_h
8 :
9 : #include "nsIWebVTTListener.h"
10 : #include "nsIStreamListener.h"
11 : #include "nsIChannelEventSink.h"
12 : #include "nsIInterfaceRequestor.h"
13 : #include "nsCOMPtr.h"
14 : #include "nsCycleCollectionParticipant.h"
15 :
16 : class nsIWebVTTParserWrapper;
17 :
18 : namespace mozilla {
19 : namespace dom {
20 :
21 : class HTMLTrackElement;
22 :
23 : class WebVTTListener final : public nsIWebVTTListener,
24 : public nsIStreamListener,
25 : public nsIChannelEventSink,
26 : public nsIInterfaceRequestor
27 : {
28 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
29 : NS_DECL_NSIWEBVTTLISTENER
30 : NS_DECL_NSIREQUESTOBSERVER
31 : NS_DECL_NSISTREAMLISTENER
32 : NS_DECL_NSICHANNELEVENTSINK
33 : NS_DECL_NSIINTERFACEREQUESTOR
34 :
35 0 : NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(WebVTTListener,
36 : nsIStreamListener)
37 :
38 : public:
39 : explicit WebVTTListener(HTMLTrackElement* aElement);
40 :
41 : /**
42 : * Loads the WebVTTListener. Must call this in order for the listener to be
43 : * ready to parse data that is passed to it.
44 : */
45 : nsresult LoadResource();
46 :
47 : private:
48 : ~WebVTTListener();
49 :
50 : // List of error codes returned from the WebVTT parser that we care about.
51 : enum ErrorCodes {
52 : BadSignature = 0
53 : };
54 : static nsresult ParseChunk(nsIInputStream* aInStream, void* aClosure,
55 : const char* aFromSegment, uint32_t aToOffset,
56 : uint32_t aCount, uint32_t* aWriteCount);
57 :
58 : RefPtr<HTMLTrackElement> mElement;
59 : nsCOMPtr<nsIWebVTTParserWrapper> mParserWrapper;
60 : };
61 :
62 : } // namespace dom
63 : } // namespace mozilla
64 :
65 : #endif // mozilla_dom_WebVTTListener_h
|