|
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 "nsIWyciwygChannel.h" |
|
14 #include "nsIStreamListener.h" |
|
15 #include "nsICacheEntryOpenCallback.h" |
|
16 #include "PrivateBrowsingChannel.h" |
|
17 |
|
18 class nsICacheEntry; |
|
19 class nsIEventTarget; |
|
20 class nsIInputStream; |
|
21 class nsIInputStreamPump; |
|
22 class nsILoadGroup; |
|
23 class nsIOutputStream; |
|
24 class nsIProgressEventSink; |
|
25 class nsIURI; |
|
26 |
|
27 extern PRLogModuleInfo * gWyciwygLog; |
|
28 |
|
29 //----------------------------------------------------------------------------- |
|
30 |
|
31 class nsWyciwygChannel: public nsIWyciwygChannel, |
|
32 public nsIStreamListener, |
|
33 public nsICacheEntryOpenCallback, |
|
34 public mozilla::net::PrivateBrowsingChannel<nsWyciwygChannel> |
|
35 { |
|
36 public: |
|
37 NS_DECL_THREADSAFE_ISUPPORTS |
|
38 NS_DECL_NSIREQUEST |
|
39 NS_DECL_NSICHANNEL |
|
40 NS_DECL_NSIWYCIWYGCHANNEL |
|
41 NS_DECL_NSIREQUESTOBSERVER |
|
42 NS_DECL_NSISTREAMLISTENER |
|
43 NS_DECL_NSICACHEENTRYOPENCALLBACK |
|
44 |
|
45 friend class nsWyciwygSetCharsetandSourceEvent; |
|
46 friend class nsWyciwygWriteEvent; |
|
47 friend class nsWyciwygCloseEvent; |
|
48 |
|
49 // nsWyciwygChannel methods: |
|
50 nsWyciwygChannel(); |
|
51 virtual ~nsWyciwygChannel(); |
|
52 |
|
53 nsresult Init(nsIURI *uri); |
|
54 |
|
55 protected: |
|
56 nsresult WriteToCacheEntryInternal(const nsAString& aData); |
|
57 void SetCharsetAndSourceInternal(); |
|
58 nsresult CloseCacheEntryInternal(nsresult reason); |
|
59 |
|
60 nsresult ReadFromCache(); |
|
61 nsresult EnsureWriteCacheEntry(); |
|
62 nsresult OpenCacheEntry(nsIURI *aURI, uint32_t aOpenFlags); |
|
63 |
|
64 void WriteCharsetAndSourceToCache(int32_t aSource, |
|
65 const nsCString& aCharset); |
|
66 |
|
67 void NotifyListener(); |
|
68 bool IsOnCacheIOThread(); |
|
69 |
|
70 friend class mozilla::net::PrivateBrowsingChannel<nsWyciwygChannel>; |
|
71 |
|
72 enum EMode { |
|
73 NONE, |
|
74 WRITING, |
|
75 READING |
|
76 }; |
|
77 |
|
78 EMode mMode; |
|
79 nsresult mStatus; |
|
80 bool mIsPending; |
|
81 bool mCharsetAndSourceSet; |
|
82 bool mNeedToWriteCharset; |
|
83 int32_t mCharsetSource; |
|
84 nsCString mCharset; |
|
85 int64_t mContentLength; |
|
86 uint32_t mLoadFlags; |
|
87 uint32_t mAppId; |
|
88 bool mInBrowser; |
|
89 nsCOMPtr<nsIURI> mURI; |
|
90 nsCOMPtr<nsIURI> mOriginalURI; |
|
91 nsCOMPtr<nsISupports> mOwner; |
|
92 nsCOMPtr<nsIInterfaceRequestor> mCallbacks; |
|
93 nsCOMPtr<nsIProgressEventSink> mProgressSink; |
|
94 nsCOMPtr<nsILoadGroup> mLoadGroup; |
|
95 nsCOMPtr<nsIStreamListener> mListener; |
|
96 nsCOMPtr<nsISupports> mListenerContext; |
|
97 |
|
98 // reuse as much of this channel implementation as we can |
|
99 nsCOMPtr<nsIInputStreamPump> mPump; |
|
100 |
|
101 // Cache related stuff |
|
102 nsCOMPtr<nsICacheEntry> mCacheEntry; |
|
103 nsCOMPtr<nsIOutputStream> mCacheOutputStream; |
|
104 nsCOMPtr<nsIInputStream> mCacheInputStream; |
|
105 nsCOMPtr<nsIEventTarget> mCacheIOTarget; |
|
106 |
|
107 nsCOMPtr<nsISupports> mSecurityInfo; |
|
108 }; |
|
109 |
|
110 #endif /* nsWyciwygChannel_h___ */ |