Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
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 #ifndef mozilla_net_WyciwygChannelChild_h
6 #define mozilla_net_WyciwygChannelChild_h
8 #include "mozilla/net/PWyciwygChannelChild.h"
9 #include "nsIWyciwygChannel.h"
10 #include "nsIChannel.h"
11 #include "PrivateBrowsingChannel.h"
13 class nsIProgressEventSink;
15 namespace mozilla {
16 namespace net {
18 class ChannelEventQueue;
20 // TODO: replace with IPDL states
21 enum WyciwygChannelChildState {
22 WCC_NEW,
23 WCC_INIT,
25 // States when reading from the channel
26 WCC_OPENED,
27 WCC_ONSTART,
28 WCC_ONDATA,
29 WCC_ONSTOP,
31 // States when writing to the cache
32 WCC_ONWRITE,
33 WCC_ONCLOSED
34 };
37 // Header file contents
38 class WyciwygChannelChild : public PWyciwygChannelChild
39 , public nsIWyciwygChannel
40 , public PrivateBrowsingChannel<WyciwygChannelChild>
41 {
42 public:
43 NS_DECL_ISUPPORTS
44 NS_DECL_NSIREQUEST
45 NS_DECL_NSICHANNEL
46 NS_DECL_NSIWYCIWYGCHANNEL
48 WyciwygChannelChild();
49 virtual ~WyciwygChannelChild();
51 void AddIPDLReference();
52 void ReleaseIPDLReference();
54 nsresult Init(nsIURI *uri);
56 bool IsSuspended();
58 protected:
59 bool RecvOnStartRequest(const nsresult& statusCode,
60 const int64_t& contentLength,
61 const int32_t& source,
62 const nsCString& charset,
63 const nsCString& securityInfo) MOZ_OVERRIDE;
64 bool RecvOnDataAvailable(const nsCString& data,
65 const uint64_t& offset) MOZ_OVERRIDE;
66 bool RecvOnStopRequest(const nsresult& statusCode) MOZ_OVERRIDE;
67 bool RecvCancelEarly(const nsresult& statusCode) MOZ_OVERRIDE;
69 void OnStartRequest(const nsresult& statusCode,
70 const int64_t& contentLength,
71 const int32_t& source,
72 const nsCString& charset,
73 const nsCString& securityInfo);
74 void OnDataAvailable(const nsCString& data,
75 const uint64_t& offset);
76 void OnStopRequest(const nsresult& statusCode);
77 void CancelEarly(const nsresult& statusCode);
79 friend class PrivateBrowsingChannel<WyciwygChannelChild>;
81 private:
82 nsresult mStatus;
83 bool mIsPending;
84 bool mCanceled;
85 uint32_t mLoadFlags;
86 int64_t mContentLength;
87 int32_t mCharsetSource;
88 nsCString mCharset;
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 nsCOMPtr<nsISupports> mSecurityInfo;
99 // FIXME: replace with IPDL states (bug 536319)
100 enum WyciwygChannelChildState mState;
102 bool mIPCOpen;
103 bool mSentAppData;
104 nsRefPtr<ChannelEventQueue> mEventQ;
106 friend class WyciwygStartRequestEvent;
107 friend class WyciwygDataAvailableEvent;
108 friend class WyciwygStopRequestEvent;
109 friend class WyciwygCancelEvent;
110 };
112 inline bool
113 WyciwygChannelChild::IsSuspended()
114 {
115 return false;
116 }
118 } // namespace net
119 } // namespace mozilla
121 #endif // mozilla_net_WyciwygChannelChild_h