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