/src/mozilla-central/netwerk/protocol/wyciwyg/nsWyciwygChannel.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
2 | | * |
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 nsWyciwygChannel_h___ |
8 | | #define nsWyciwygChannel_h___ |
9 | | |
10 | | #include "nsString.h" |
11 | | #include "nsCOMPtr.h" |
12 | | |
13 | | #include "nsILoadInfo.h" |
14 | | #include "nsIWyciwygChannel.h" |
15 | | #include "nsIStreamListener.h" |
16 | | #include "nsICacheEntryOpenCallback.h" |
17 | | #include "PrivateBrowsingChannel.h" |
18 | | #include "mozilla/BasePrincipal.h" |
19 | | |
20 | | class nsICacheEntry; |
21 | | class nsICacheStorage; |
22 | | class nsIInputStream; |
23 | | class nsIInputStreamPump; |
24 | | class nsILoadGroup; |
25 | | class nsIOutputStream; |
26 | | class nsIProgressEventSink; |
27 | | class nsIURI; |
28 | | |
29 | | extern mozilla::LazyLogModule gWyciwygLog; |
30 | | |
31 | | //----------------------------------------------------------------------------- |
32 | | |
33 | | class nsWyciwygChannel final: public nsIWyciwygChannel, |
34 | | public nsIStreamListener, |
35 | | public nsICacheEntryOpenCallback, |
36 | | public mozilla::net::PrivateBrowsingChannel<nsWyciwygChannel> |
37 | | { |
38 | | public: |
39 | | NS_DECL_THREADSAFE_ISUPPORTS |
40 | | NS_DECL_NSIREQUEST |
41 | | NS_DECL_NSICHANNEL |
42 | | NS_DECL_NSIWYCIWYGCHANNEL |
43 | | NS_DECL_NSIREQUESTOBSERVER |
44 | | NS_DECL_NSISTREAMLISTENER |
45 | | NS_DECL_NSICACHEENTRYOPENCALLBACK |
46 | | |
47 | | // nsWyciwygChannel methods: |
48 | | nsWyciwygChannel(); |
49 | | |
50 | | nsresult Init(nsIURI *uri); |
51 | | |
52 | | protected: |
53 | | virtual ~nsWyciwygChannel(); |
54 | | |
55 | | nsresult ReadFromCache(); |
56 | | nsresult EnsureWriteCacheEntry(); |
57 | | nsresult GetCacheStorage(nsICacheStorage **_retval); |
58 | | nsresult OpenCacheEntryForReading(nsIURI *aURI); |
59 | | nsresult OpenCacheEntryForWriting(nsIURI *aURI); |
60 | | |
61 | | void WriteCharsetAndSourceToCache(int32_t aSource, |
62 | | const nsCString& aCharset); |
63 | | |
64 | | void NotifyListener(); |
65 | | |
66 | | friend class mozilla::net::PrivateBrowsingChannel<nsWyciwygChannel>; |
67 | | |
68 | | enum EMode { |
69 | | NONE, |
70 | | WRITING, |
71 | | READING |
72 | | }; |
73 | | |
74 | | EMode mMode; |
75 | | nsresult mStatus; |
76 | | bool mIsPending; |
77 | | bool mNeedToWriteCharset; |
78 | | int32_t mCharsetSource; |
79 | | nsCString mCharset; |
80 | | int64_t mContentLength; |
81 | | uint32_t mLoadFlags; |
82 | | mozilla::OriginAttributes mOriginAttributes; |
83 | | nsCOMPtr<nsIURI> mURI; |
84 | | nsCOMPtr<nsIURI> mOriginalURI; |
85 | | nsCOMPtr<nsISupports> mOwner; |
86 | | nsCOMPtr<nsILoadInfo> mLoadInfo; |
87 | | nsCOMPtr<nsIInterfaceRequestor> mCallbacks; |
88 | | nsCOMPtr<nsIProgressEventSink> mProgressSink; |
89 | | nsCOMPtr<nsILoadGroup> mLoadGroup; |
90 | | nsCOMPtr<nsIStreamListener> mListener; |
91 | | nsCOMPtr<nsISupports> mListenerContext; |
92 | | |
93 | | // reuse as much of this channel implementation as we can |
94 | | nsCOMPtr<nsIInputStreamPump> mPump; |
95 | | |
96 | | // Cache related stuff |
97 | | nsCOMPtr<nsICacheEntry> mCacheEntry; |
98 | | nsCOMPtr<nsIOutputStream> mCacheOutputStream; |
99 | | |
100 | | bool mNeedToSetSecurityInfo; |
101 | | nsCOMPtr<nsISupports> mSecurityInfo; |
102 | | }; |
103 | | |
104 | | /** |
105 | | * Casting nsWyciwygChannel to nsISupports is ambiguous. |
106 | | * This method handles that. |
107 | | */ |
108 | | inline nsISupports* |
109 | | ToSupports(nsWyciwygChannel* p) |
110 | 0 | { |
111 | 0 | return NS_ISUPPORTS_CAST(nsIStreamListener*, p); |
112 | 0 | } |
113 | | |
114 | | #endif /* nsWyciwygChannel_h___ */ |