netwerk/protocol/wyciwyg/nsWyciwygChannel.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/wyciwyg/nsWyciwygChannel.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,110 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef nsWyciwygChannel_h___
    1.11 +#define nsWyciwygChannel_h___
    1.12 +
    1.13 +#include "nsString.h"
    1.14 +#include "nsCOMPtr.h"
    1.15 +
    1.16 +#include "nsIWyciwygChannel.h"
    1.17 +#include "nsIStreamListener.h"
    1.18 +#include "nsICacheEntryOpenCallback.h"
    1.19 +#include "PrivateBrowsingChannel.h"
    1.20 +
    1.21 +class nsICacheEntry;
    1.22 +class nsIEventTarget;
    1.23 +class nsIInputStream;
    1.24 +class nsIInputStreamPump;
    1.25 +class nsILoadGroup;
    1.26 +class nsIOutputStream;
    1.27 +class nsIProgressEventSink;
    1.28 +class nsIURI;
    1.29 +
    1.30 +extern PRLogModuleInfo * gWyciwygLog;
    1.31 +
    1.32 +//-----------------------------------------------------------------------------
    1.33 +
    1.34 +class nsWyciwygChannel: public nsIWyciwygChannel,
    1.35 +                        public nsIStreamListener,
    1.36 +                        public nsICacheEntryOpenCallback,
    1.37 +                        public mozilla::net::PrivateBrowsingChannel<nsWyciwygChannel>
    1.38 +{
    1.39 +public:
    1.40 +    NS_DECL_THREADSAFE_ISUPPORTS
    1.41 +    NS_DECL_NSIREQUEST
    1.42 +    NS_DECL_NSICHANNEL
    1.43 +    NS_DECL_NSIWYCIWYGCHANNEL
    1.44 +    NS_DECL_NSIREQUESTOBSERVER
    1.45 +    NS_DECL_NSISTREAMLISTENER
    1.46 +    NS_DECL_NSICACHEENTRYOPENCALLBACK
    1.47 +
    1.48 +    friend class nsWyciwygSetCharsetandSourceEvent;
    1.49 +    friend class nsWyciwygWriteEvent;
    1.50 +    friend class nsWyciwygCloseEvent;
    1.51 +
    1.52 +    // nsWyciwygChannel methods:
    1.53 +    nsWyciwygChannel();
    1.54 +    virtual ~nsWyciwygChannel();
    1.55 +
    1.56 +    nsresult Init(nsIURI *uri);
    1.57 +
    1.58 +protected:
    1.59 +    nsresult WriteToCacheEntryInternal(const nsAString& aData);
    1.60 +    void SetCharsetAndSourceInternal();
    1.61 +    nsresult CloseCacheEntryInternal(nsresult reason);
    1.62 +
    1.63 +    nsresult ReadFromCache();
    1.64 +    nsresult EnsureWriteCacheEntry();
    1.65 +    nsresult OpenCacheEntry(nsIURI *aURI, uint32_t aOpenFlags);
    1.66 +
    1.67 +    void WriteCharsetAndSourceToCache(int32_t aSource,
    1.68 +                                      const nsCString& aCharset);
    1.69 +
    1.70 +    void NotifyListener();
    1.71 +    bool IsOnCacheIOThread();
    1.72 +
    1.73 +    friend class mozilla::net::PrivateBrowsingChannel<nsWyciwygChannel>;
    1.74 +
    1.75 +    enum EMode {
    1.76 +      NONE,
    1.77 +      WRITING,
    1.78 +      READING
    1.79 +    };
    1.80 +
    1.81 +    EMode                               mMode;
    1.82 +    nsresult                            mStatus;
    1.83 +    bool                                mIsPending;
    1.84 +    bool                                mCharsetAndSourceSet;
    1.85 +    bool                                mNeedToWriteCharset;
    1.86 +    int32_t                             mCharsetSource;
    1.87 +    nsCString                           mCharset;
    1.88 +    int64_t                             mContentLength;
    1.89 +    uint32_t                            mLoadFlags;
    1.90 +    uint32_t                            mAppId;
    1.91 +    bool                                mInBrowser;
    1.92 +    nsCOMPtr<nsIURI>                    mURI;
    1.93 +    nsCOMPtr<nsIURI>                    mOriginalURI;
    1.94 +    nsCOMPtr<nsISupports>               mOwner;
    1.95 +    nsCOMPtr<nsIInterfaceRequestor>     mCallbacks;
    1.96 +    nsCOMPtr<nsIProgressEventSink>      mProgressSink;
    1.97 +    nsCOMPtr<nsILoadGroup>              mLoadGroup;
    1.98 +    nsCOMPtr<nsIStreamListener>         mListener;
    1.99 +    nsCOMPtr<nsISupports>               mListenerContext;
   1.100 +
   1.101 +    // reuse as much of this channel implementation as we can
   1.102 +    nsCOMPtr<nsIInputStreamPump>        mPump;
   1.103 +    
   1.104 +    // Cache related stuff    
   1.105 +    nsCOMPtr<nsICacheEntry>             mCacheEntry;
   1.106 +    nsCOMPtr<nsIOutputStream>           mCacheOutputStream;
   1.107 +    nsCOMPtr<nsIInputStream>            mCacheInputStream;
   1.108 +    nsCOMPtr<nsIEventTarget>            mCacheIOTarget;
   1.109 +
   1.110 +    nsCOMPtr<nsISupports>               mSecurityInfo;
   1.111 +};
   1.112 +
   1.113 +#endif /* nsWyciwygChannel_h___ */

mercurial