Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #ifndef nsDSURIContentListener_h__
8 : #define nsDSURIContentListener_h__
9 :
10 : #include "nsCOMPtr.h"
11 : #include "nsIURIContentListener.h"
12 : #include "nsWeakReference.h"
13 :
14 : class nsDocShell;
15 : class nsIWebNavigationInfo;
16 :
17 : class nsDSURIContentListener final
18 : : public nsIURIContentListener
19 : , public nsSupportsWeakReference
20 : {
21 : friend class nsDocShell;
22 :
23 : public:
24 : NS_DECL_THREADSAFE_ISUPPORTS
25 : NS_DECL_NSIURICONTENTLISTENER
26 :
27 : nsresult Init();
28 :
29 : protected:
30 : explicit nsDSURIContentListener(nsDocShell* aDocShell);
31 : virtual ~nsDSURIContentListener();
32 :
33 1 : void DropDocShellReference()
34 : {
35 1 : mDocShell = nullptr;
36 1 : mExistingJPEGRequest = nullptr;
37 1 : mExistingJPEGStreamListener = nullptr;
38 1 : }
39 :
40 : protected:
41 : nsDocShell* mDocShell;
42 : // Hack to handle multipart images without creating a new viewer
43 : nsCOMPtr<nsIStreamListener> mExistingJPEGStreamListener;
44 : nsCOMPtr<nsIChannel> mExistingJPEGRequest;
45 :
46 : // Store the parent listener in either of these depending on
47 : // if supports weak references or not. Proper weak refs are
48 : // preferred and encouraged!
49 : nsWeakPtr mWeakParentContentListener;
50 : nsIURIContentListener* mParentContentListener;
51 :
52 : nsCOMPtr<nsIWebNavigationInfo> mNavInfo;
53 : };
54 :
55 : #endif /* nsDSURIContentListener_h__ */
|