netwerk/protocol/http/HttpChannelParent.h

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* vim: set sw=2 ts=8 et tw=80 : */
     4 /* This Source Code Form is subject to the terms of the Mozilla Public
     5  * License, v. 2.0. If a copy of the MPL was not distributed with this
     6  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     8 #ifndef mozilla_net_HttpChannelParent_h
     9 #define mozilla_net_HttpChannelParent_h
    11 #include "ADivertableParentChannel.h"
    12 #include "nsHttp.h"
    13 #include "mozilla/dom/PBrowserParent.h"
    14 #include "mozilla/net/PHttpChannelParent.h"
    15 #include "mozilla/net/NeckoCommon.h"
    16 #include "mozilla/net/NeckoParent.h"
    17 #include "nsIParentRedirectingChannel.h"
    18 #include "nsIProgressEventSink.h"
    19 #include "nsHttpChannel.h"
    21 class nsICacheEntry;
    22 class nsIAssociatedContentSecurity;
    24 namespace mozilla {
    26 namespace dom{
    27 class TabParent;
    28 }
    30 namespace net {
    32 class HttpChannelParentListener;
    34 class HttpChannelParent : public PHttpChannelParent
    35                         , public nsIParentRedirectingChannel
    36                         , public nsIProgressEventSink
    37                         , public nsIInterfaceRequestor
    38                         , public ADivertableParentChannel
    39 {
    40 public:
    41   NS_DECL_ISUPPORTS
    42   NS_DECL_NSIREQUESTOBSERVER
    43   NS_DECL_NSISTREAMLISTENER
    44   NS_DECL_NSIPARENTCHANNEL
    45   NS_DECL_NSIPARENTREDIRECTINGCHANNEL
    46   NS_DECL_NSIPROGRESSEVENTSINK
    47   NS_DECL_NSIINTERFACEREQUESTOR
    49   HttpChannelParent(mozilla::dom::PBrowserParent* iframeEmbedding,
    50                     nsILoadContext* aLoadContext,
    51                     PBOverrideStatus aStatus);
    52   virtual ~HttpChannelParent();
    54   bool Init(const HttpChannelCreationArgs& aOpenArgs);
    56   // ADivertableParentChannel functions.
    57   void DivertTo(nsIStreamListener *aListener) MOZ_OVERRIDE;
    58   nsresult SuspendForDiversion() MOZ_OVERRIDE;
    60   // Calls OnStartRequest for "DivertTo" listener, then notifies child channel
    61   // that it should divert OnDataAvailable and OnStopRequest calls to this
    62   // parent channel.
    63   void StartDiversion();
    65   // Handles calling OnStart/Stop if there are errors during diversion.
    66   // Called asynchronously from FailDiversion.
    67   void NotifyDiversionFailed(nsresult aErrorCode, bool aSkipResume = true);
    69 protected:
    70   // used to connect redirected-to channel in parent with just created
    71   // ChildChannel.  Used during redirects.
    72   bool ConnectChannel(const uint32_t& channelId);
    74   bool DoAsyncOpen(const URIParams&           uri,
    75                    const OptionalURIParams&   originalUri,
    76                    const OptionalURIParams&   docUri,
    77                    const OptionalURIParams&   referrerUri,
    78                    const OptionalURIParams&   internalRedirectUri,
    79                    const uint32_t&            loadFlags,
    80                    const RequestHeaderTuples& requestHeaders,
    81                    const nsCString&           requestMethod,
    82                    const OptionalInputStreamParams& uploadStream,
    83                    const bool&                uploadStreamHasHeaders,
    84                    const uint16_t&            priority,
    85                    const uint8_t&             redirectionLimit,
    86                    const bool&                allowPipelining,
    87                    const bool&                forceAllowThirdPartyCookie,
    88                    const bool&                doResumeAt,
    89                    const uint64_t&            startPos,
    90                    const nsCString&           entityID,
    91                    const bool&                chooseApplicationCache,
    92                    const nsCString&           appCacheClientID,
    93                    const bool&                allowSpdy,
    94                    const OptionalFileDescriptorSet& aFds);
    96   virtual bool RecvSetPriority(const uint16_t& priority) MOZ_OVERRIDE;
    97   virtual bool RecvSetCacheTokenCachedCharset(const nsCString& charset) MOZ_OVERRIDE;
    98   virtual bool RecvSuspend() MOZ_OVERRIDE;
    99   virtual bool RecvResume() MOZ_OVERRIDE;
   100   virtual bool RecvCancel(const nsresult& status) MOZ_OVERRIDE;
   101   virtual bool RecvRedirect2Verify(const nsresult& result,
   102                                    const RequestHeaderTuples& changedHeaders,
   103                                    const OptionalURIParams& apiRedirectUri) MOZ_OVERRIDE;
   104   virtual bool RecvUpdateAssociatedContentSecurity(const int32_t& broken,
   105                                                    const int32_t& no) MOZ_OVERRIDE;
   106   virtual bool RecvDocumentChannelCleanup() MOZ_OVERRIDE;
   107   virtual bool RecvMarkOfflineCacheEntryAsForeign() MOZ_OVERRIDE;
   108   virtual bool RecvDivertOnDataAvailable(const nsCString& data,
   109                                          const uint64_t& offset,
   110                                          const uint32_t& count) MOZ_OVERRIDE;
   111   virtual bool RecvDivertOnStopRequest(const nsresult& statusCode) MOZ_OVERRIDE;
   112   virtual bool RecvDivertComplete() MOZ_OVERRIDE;
   113   virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
   115   // Supporting function for ADivertableParentChannel.
   116   nsresult ResumeForDiversion();
   118   // Asynchronously calls NotifyDiversionFailed.
   119   void FailDiversion(nsresult aErrorCode, bool aSkipResume = true);
   121   friend class HttpChannelParentListener;
   122   nsRefPtr<mozilla::dom::TabParent> mTabParent;
   124 private:
   125   nsRefPtr<nsHttpChannel>       mChannel;
   126   nsCOMPtr<nsICacheEntry>       mCacheEntry;
   127   nsCOMPtr<nsIAssociatedContentSecurity>  mAssociatedContentSecurity;
   128   bool mIPCClosed;                // PHttpChannel actor has been Closed()
   130   nsCOMPtr<nsIChannel> mRedirectChannel;
   131   nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
   133   nsAutoPtr<class nsHttpChannel::OfflineCacheEntryAsForeignMarker> mOfflineForeignMarker;
   135   // state for combining OnStatus/OnProgress with OnDataAvailable
   136   // into one IPDL call to child.
   137   nsresult mStoredStatus;
   138   uint64_t mStoredProgress;
   139   uint64_t mStoredProgressMax;
   141   bool mSentRedirect1Begin          : 1;
   142   bool mSentRedirect1BeginFailed    : 1;
   143   bool mReceivedRedirect2Verify     : 1;
   145   PBOverrideStatus mPBOverride;
   147   nsCOMPtr<nsILoadContext> mLoadContext;
   148   nsRefPtr<nsHttpHandler>  mHttpHandler;
   150   nsRefPtr<HttpChannelParentListener> mParentListener;
   151   // Set to the canceled status value if the main channel was canceled.
   152   nsresult mStatus;
   153   // Once set, no OnStart/OnData/OnStop calls should be accepted; conversely, it
   154   // must be set when RecvDivertOnData/~DivertOnStop/~DivertComplete are
   155   // received from the child channel.
   156   bool mDivertingFromChild;
   158   // Set if OnStart|StopRequest was called during a diversion from the child.
   159   bool mDivertedOnStartRequest;
   161   bool mSuspendedForDiversion;
   162 };
   164 } // namespace net
   165 } // namespace mozilla
   167 #endif // mozilla_net_HttpChannelParent_h

mercurial