Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
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/. */
7 #ifndef nsWyciwygChannel_h___
8 #define nsWyciwygChannel_h___
10 #include "nsString.h"
11 #include "nsCOMPtr.h"
13 #include "nsIWyciwygChannel.h"
14 #include "nsIStreamListener.h"
15 #include "nsICacheEntryOpenCallback.h"
16 #include "PrivateBrowsingChannel.h"
18 class nsICacheEntry;
19 class nsIEventTarget;
20 class nsIInputStream;
21 class nsIInputStreamPump;
22 class nsILoadGroup;
23 class nsIOutputStream;
24 class nsIProgressEventSink;
25 class nsIURI;
27 extern PRLogModuleInfo * gWyciwygLog;
29 //-----------------------------------------------------------------------------
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
45 friend class nsWyciwygSetCharsetandSourceEvent;
46 friend class nsWyciwygWriteEvent;
47 friend class nsWyciwygCloseEvent;
49 // nsWyciwygChannel methods:
50 nsWyciwygChannel();
51 virtual ~nsWyciwygChannel();
53 nsresult Init(nsIURI *uri);
55 protected:
56 nsresult WriteToCacheEntryInternal(const nsAString& aData);
57 void SetCharsetAndSourceInternal();
58 nsresult CloseCacheEntryInternal(nsresult reason);
60 nsresult ReadFromCache();
61 nsresult EnsureWriteCacheEntry();
62 nsresult OpenCacheEntry(nsIURI *aURI, uint32_t aOpenFlags);
64 void WriteCharsetAndSourceToCache(int32_t aSource,
65 const nsCString& aCharset);
67 void NotifyListener();
68 bool IsOnCacheIOThread();
70 friend class mozilla::net::PrivateBrowsingChannel<nsWyciwygChannel>;
72 enum EMode {
73 NONE,
74 WRITING,
75 READING
76 };
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;
98 // reuse as much of this channel implementation as we can
99 nsCOMPtr<nsIInputStreamPump> mPump;
101 // Cache related stuff
102 nsCOMPtr<nsICacheEntry> mCacheEntry;
103 nsCOMPtr<nsIOutputStream> mCacheOutputStream;
104 nsCOMPtr<nsIInputStream> mCacheInputStream;
105 nsCOMPtr<nsIEventTarget> mCacheIOTarget;
107 nsCOMPtr<nsISupports> mSecurityInfo;
108 };
110 #endif /* nsWyciwygChannel_h___ */