michael@0: /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsWyciwygChannel_h___ michael@0: #define nsWyciwygChannel_h___ michael@0: michael@0: #include "nsString.h" michael@0: #include "nsCOMPtr.h" michael@0: michael@0: #include "nsIWyciwygChannel.h" michael@0: #include "nsIStreamListener.h" michael@0: #include "nsICacheEntryOpenCallback.h" michael@0: #include "PrivateBrowsingChannel.h" michael@0: michael@0: class nsICacheEntry; michael@0: class nsIEventTarget; michael@0: class nsIInputStream; michael@0: class nsIInputStreamPump; michael@0: class nsILoadGroup; michael@0: class nsIOutputStream; michael@0: class nsIProgressEventSink; michael@0: class nsIURI; michael@0: michael@0: extern PRLogModuleInfo * gWyciwygLog; michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: class nsWyciwygChannel: public nsIWyciwygChannel, michael@0: public nsIStreamListener, michael@0: public nsICacheEntryOpenCallback, michael@0: public mozilla::net::PrivateBrowsingChannel michael@0: { michael@0: public: michael@0: NS_DECL_THREADSAFE_ISUPPORTS michael@0: NS_DECL_NSIREQUEST michael@0: NS_DECL_NSICHANNEL michael@0: NS_DECL_NSIWYCIWYGCHANNEL michael@0: NS_DECL_NSIREQUESTOBSERVER michael@0: NS_DECL_NSISTREAMLISTENER michael@0: NS_DECL_NSICACHEENTRYOPENCALLBACK michael@0: michael@0: friend class nsWyciwygSetCharsetandSourceEvent; michael@0: friend class nsWyciwygWriteEvent; michael@0: friend class nsWyciwygCloseEvent; michael@0: michael@0: // nsWyciwygChannel methods: michael@0: nsWyciwygChannel(); michael@0: virtual ~nsWyciwygChannel(); michael@0: michael@0: nsresult Init(nsIURI *uri); michael@0: michael@0: protected: michael@0: nsresult WriteToCacheEntryInternal(const nsAString& aData); michael@0: void SetCharsetAndSourceInternal(); michael@0: nsresult CloseCacheEntryInternal(nsresult reason); michael@0: michael@0: nsresult ReadFromCache(); michael@0: nsresult EnsureWriteCacheEntry(); michael@0: nsresult OpenCacheEntry(nsIURI *aURI, uint32_t aOpenFlags); michael@0: michael@0: void WriteCharsetAndSourceToCache(int32_t aSource, michael@0: const nsCString& aCharset); michael@0: michael@0: void NotifyListener(); michael@0: bool IsOnCacheIOThread(); michael@0: michael@0: friend class mozilla::net::PrivateBrowsingChannel; michael@0: michael@0: enum EMode { michael@0: NONE, michael@0: WRITING, michael@0: READING michael@0: }; michael@0: michael@0: EMode mMode; michael@0: nsresult mStatus; michael@0: bool mIsPending; michael@0: bool mCharsetAndSourceSet; michael@0: bool mNeedToWriteCharset; michael@0: int32_t mCharsetSource; michael@0: nsCString mCharset; michael@0: int64_t mContentLength; michael@0: uint32_t mLoadFlags; michael@0: uint32_t mAppId; michael@0: bool mInBrowser; michael@0: nsCOMPtr mURI; michael@0: nsCOMPtr mOriginalURI; michael@0: nsCOMPtr mOwner; michael@0: nsCOMPtr mCallbacks; michael@0: nsCOMPtr mProgressSink; michael@0: nsCOMPtr mLoadGroup; michael@0: nsCOMPtr mListener; michael@0: nsCOMPtr mListenerContext; michael@0: michael@0: // reuse as much of this channel implementation as we can michael@0: nsCOMPtr mPump; michael@0: michael@0: // Cache related stuff michael@0: nsCOMPtr mCacheEntry; michael@0: nsCOMPtr mCacheOutputStream; michael@0: nsCOMPtr mCacheInputStream; michael@0: nsCOMPtr mCacheIOTarget; michael@0: michael@0: nsCOMPtr mSecurityInfo; michael@0: }; michael@0: michael@0: #endif /* nsWyciwygChannel_h___ */