netwerk/protocol/wyciwyg/nsWyciwygChannel.h

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef nsWyciwygChannel_h___
michael@0 8 #define nsWyciwygChannel_h___
michael@0 9
michael@0 10 #include "nsString.h"
michael@0 11 #include "nsCOMPtr.h"
michael@0 12
michael@0 13 #include "nsIWyciwygChannel.h"
michael@0 14 #include "nsIStreamListener.h"
michael@0 15 #include "nsICacheEntryOpenCallback.h"
michael@0 16 #include "PrivateBrowsingChannel.h"
michael@0 17
michael@0 18 class nsICacheEntry;
michael@0 19 class nsIEventTarget;
michael@0 20 class nsIInputStream;
michael@0 21 class nsIInputStreamPump;
michael@0 22 class nsILoadGroup;
michael@0 23 class nsIOutputStream;
michael@0 24 class nsIProgressEventSink;
michael@0 25 class nsIURI;
michael@0 26
michael@0 27 extern PRLogModuleInfo * gWyciwygLog;
michael@0 28
michael@0 29 //-----------------------------------------------------------------------------
michael@0 30
michael@0 31 class nsWyciwygChannel: public nsIWyciwygChannel,
michael@0 32 public nsIStreamListener,
michael@0 33 public nsICacheEntryOpenCallback,
michael@0 34 public mozilla::net::PrivateBrowsingChannel<nsWyciwygChannel>
michael@0 35 {
michael@0 36 public:
michael@0 37 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 38 NS_DECL_NSIREQUEST
michael@0 39 NS_DECL_NSICHANNEL
michael@0 40 NS_DECL_NSIWYCIWYGCHANNEL
michael@0 41 NS_DECL_NSIREQUESTOBSERVER
michael@0 42 NS_DECL_NSISTREAMLISTENER
michael@0 43 NS_DECL_NSICACHEENTRYOPENCALLBACK
michael@0 44
michael@0 45 friend class nsWyciwygSetCharsetandSourceEvent;
michael@0 46 friend class nsWyciwygWriteEvent;
michael@0 47 friend class nsWyciwygCloseEvent;
michael@0 48
michael@0 49 // nsWyciwygChannel methods:
michael@0 50 nsWyciwygChannel();
michael@0 51 virtual ~nsWyciwygChannel();
michael@0 52
michael@0 53 nsresult Init(nsIURI *uri);
michael@0 54
michael@0 55 protected:
michael@0 56 nsresult WriteToCacheEntryInternal(const nsAString& aData);
michael@0 57 void SetCharsetAndSourceInternal();
michael@0 58 nsresult CloseCacheEntryInternal(nsresult reason);
michael@0 59
michael@0 60 nsresult ReadFromCache();
michael@0 61 nsresult EnsureWriteCacheEntry();
michael@0 62 nsresult OpenCacheEntry(nsIURI *aURI, uint32_t aOpenFlags);
michael@0 63
michael@0 64 void WriteCharsetAndSourceToCache(int32_t aSource,
michael@0 65 const nsCString& aCharset);
michael@0 66
michael@0 67 void NotifyListener();
michael@0 68 bool IsOnCacheIOThread();
michael@0 69
michael@0 70 friend class mozilla::net::PrivateBrowsingChannel<nsWyciwygChannel>;
michael@0 71
michael@0 72 enum EMode {
michael@0 73 NONE,
michael@0 74 WRITING,
michael@0 75 READING
michael@0 76 };
michael@0 77
michael@0 78 EMode mMode;
michael@0 79 nsresult mStatus;
michael@0 80 bool mIsPending;
michael@0 81 bool mCharsetAndSourceSet;
michael@0 82 bool mNeedToWriteCharset;
michael@0 83 int32_t mCharsetSource;
michael@0 84 nsCString mCharset;
michael@0 85 int64_t mContentLength;
michael@0 86 uint32_t mLoadFlags;
michael@0 87 uint32_t mAppId;
michael@0 88 bool mInBrowser;
michael@0 89 nsCOMPtr<nsIURI> mURI;
michael@0 90 nsCOMPtr<nsIURI> mOriginalURI;
michael@0 91 nsCOMPtr<nsISupports> mOwner;
michael@0 92 nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
michael@0 93 nsCOMPtr<nsIProgressEventSink> mProgressSink;
michael@0 94 nsCOMPtr<nsILoadGroup> mLoadGroup;
michael@0 95 nsCOMPtr<nsIStreamListener> mListener;
michael@0 96 nsCOMPtr<nsISupports> mListenerContext;
michael@0 97
michael@0 98 // reuse as much of this channel implementation as we can
michael@0 99 nsCOMPtr<nsIInputStreamPump> mPump;
michael@0 100
michael@0 101 // Cache related stuff
michael@0 102 nsCOMPtr<nsICacheEntry> mCacheEntry;
michael@0 103 nsCOMPtr<nsIOutputStream> mCacheOutputStream;
michael@0 104 nsCOMPtr<nsIInputStream> mCacheInputStream;
michael@0 105 nsCOMPtr<nsIEventTarget> mCacheIOTarget;
michael@0 106
michael@0 107 nsCOMPtr<nsISupports> mSecurityInfo;
michael@0 108 };
michael@0 109
michael@0 110 #endif /* nsWyciwygChannel_h___ */

mercurial