Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 #include "nsHtml5StreamListener.h"
7 NS_IMPL_ADDREF(nsHtml5StreamListener)
8 NS_IMPL_RELEASE(nsHtml5StreamListener)
10 NS_INTERFACE_MAP_BEGIN(nsHtml5StreamListener)
11 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIRequestObserver)
12 NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
13 NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
14 NS_INTERFACE_MAP_ENTRY(nsIThreadRetargetableStreamListener)
15 NS_INTERFACE_MAP_END_THREADSAFE
17 nsHtml5StreamListener::nsHtml5StreamListener(nsHtml5StreamParser* aDelegate)
18 : mDelegate(aDelegate)
19 {
20 }
22 nsHtml5StreamListener::~nsHtml5StreamListener()
23 {
24 }
26 void
27 nsHtml5StreamListener::DropDelegate()
28 {
29 MOZ_ASSERT(NS_IsMainThread(),
30 "Must not call DropDelegate from non-main threads.");
31 mDelegate = nullptr;
32 }
34 NS_IMETHODIMP
35 nsHtml5StreamListener::CheckListenerChain()
36 {
37 if (MOZ_UNLIKELY(!mDelegate)) {
38 return NS_ERROR_NOT_AVAILABLE;
39 }
40 return mDelegate->CheckListenerChain();
41 }
43 NS_IMETHODIMP
44 nsHtml5StreamListener::OnStartRequest(nsIRequest* aRequest,
45 nsISupports* aContext)
46 {
47 if (MOZ_UNLIKELY(!mDelegate)) {
48 return NS_ERROR_NOT_AVAILABLE;
49 }
50 return mDelegate->OnStartRequest(aRequest, aContext);
51 }
53 NS_IMETHODIMP
54 nsHtml5StreamListener::OnStopRequest(nsIRequest* aRequest,
55 nsISupports* aContext,
56 nsresult aStatus)
57 {
58 if (MOZ_UNLIKELY(!mDelegate)) {
59 return NS_ERROR_NOT_AVAILABLE;
60 }
61 return mDelegate->OnStopRequest(aRequest,
62 aContext,
63 aStatus);
64 }
66 NS_IMETHODIMP
67 nsHtml5StreamListener::OnDataAvailable(nsIRequest* aRequest,
68 nsISupports* aContext,
69 nsIInputStream* aInStream,
70 uint64_t aSourceOffset,
71 uint32_t aLength)
72 {
73 if (MOZ_UNLIKELY(!mDelegate)) {
74 return NS_ERROR_NOT_AVAILABLE;
75 }
76 return mDelegate->OnDataAvailable(aRequest,
77 aContext,
78 aInStream,
79 aSourceOffset,
80 aLength);
81 }