netwerk/protocol/http/HttpChannelParent.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/netwerk/protocol/http/HttpChannelParent.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,167 @@
     1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.5 +/* vim: set sw=2 ts=8 et tw=80 : */
     1.6 +
     1.7 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.8 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.9 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
    1.10 +
    1.11 +#ifndef mozilla_net_HttpChannelParent_h
    1.12 +#define mozilla_net_HttpChannelParent_h
    1.13 +
    1.14 +#include "ADivertableParentChannel.h"
    1.15 +#include "nsHttp.h"
    1.16 +#include "mozilla/dom/PBrowserParent.h"
    1.17 +#include "mozilla/net/PHttpChannelParent.h"
    1.18 +#include "mozilla/net/NeckoCommon.h"
    1.19 +#include "mozilla/net/NeckoParent.h"
    1.20 +#include "nsIParentRedirectingChannel.h"
    1.21 +#include "nsIProgressEventSink.h"
    1.22 +#include "nsHttpChannel.h"
    1.23 +
    1.24 +class nsICacheEntry;
    1.25 +class nsIAssociatedContentSecurity;
    1.26 +
    1.27 +namespace mozilla {
    1.28 +
    1.29 +namespace dom{
    1.30 +class TabParent;
    1.31 +}
    1.32 +
    1.33 +namespace net {
    1.34 +
    1.35 +class HttpChannelParentListener;
    1.36 +
    1.37 +class HttpChannelParent : public PHttpChannelParent
    1.38 +                        , public nsIParentRedirectingChannel
    1.39 +                        , public nsIProgressEventSink
    1.40 +                        , public nsIInterfaceRequestor
    1.41 +                        , public ADivertableParentChannel
    1.42 +{
    1.43 +public:
    1.44 +  NS_DECL_ISUPPORTS
    1.45 +  NS_DECL_NSIREQUESTOBSERVER
    1.46 +  NS_DECL_NSISTREAMLISTENER
    1.47 +  NS_DECL_NSIPARENTCHANNEL
    1.48 +  NS_DECL_NSIPARENTREDIRECTINGCHANNEL
    1.49 +  NS_DECL_NSIPROGRESSEVENTSINK
    1.50 +  NS_DECL_NSIINTERFACEREQUESTOR
    1.51 +
    1.52 +  HttpChannelParent(mozilla::dom::PBrowserParent* iframeEmbedding,
    1.53 +                    nsILoadContext* aLoadContext,
    1.54 +                    PBOverrideStatus aStatus);
    1.55 +  virtual ~HttpChannelParent();
    1.56 +
    1.57 +  bool Init(const HttpChannelCreationArgs& aOpenArgs);
    1.58 +
    1.59 +  // ADivertableParentChannel functions.
    1.60 +  void DivertTo(nsIStreamListener *aListener) MOZ_OVERRIDE;
    1.61 +  nsresult SuspendForDiversion() MOZ_OVERRIDE;
    1.62 +
    1.63 +  // Calls OnStartRequest for "DivertTo" listener, then notifies child channel
    1.64 +  // that it should divert OnDataAvailable and OnStopRequest calls to this
    1.65 +  // parent channel.
    1.66 +  void StartDiversion();
    1.67 +
    1.68 +  // Handles calling OnStart/Stop if there are errors during diversion.
    1.69 +  // Called asynchronously from FailDiversion.
    1.70 +  void NotifyDiversionFailed(nsresult aErrorCode, bool aSkipResume = true);
    1.71 +
    1.72 +protected:
    1.73 +  // used to connect redirected-to channel in parent with just created
    1.74 +  // ChildChannel.  Used during redirects.
    1.75 +  bool ConnectChannel(const uint32_t& channelId);
    1.76 +
    1.77 +  bool DoAsyncOpen(const URIParams&           uri,
    1.78 +                   const OptionalURIParams&   originalUri,
    1.79 +                   const OptionalURIParams&   docUri,
    1.80 +                   const OptionalURIParams&   referrerUri,
    1.81 +                   const OptionalURIParams&   internalRedirectUri,
    1.82 +                   const uint32_t&            loadFlags,
    1.83 +                   const RequestHeaderTuples& requestHeaders,
    1.84 +                   const nsCString&           requestMethod,
    1.85 +                   const OptionalInputStreamParams& uploadStream,
    1.86 +                   const bool&                uploadStreamHasHeaders,
    1.87 +                   const uint16_t&            priority,
    1.88 +                   const uint8_t&             redirectionLimit,
    1.89 +                   const bool&                allowPipelining,
    1.90 +                   const bool&                forceAllowThirdPartyCookie,
    1.91 +                   const bool&                doResumeAt,
    1.92 +                   const uint64_t&            startPos,
    1.93 +                   const nsCString&           entityID,
    1.94 +                   const bool&                chooseApplicationCache,
    1.95 +                   const nsCString&           appCacheClientID,
    1.96 +                   const bool&                allowSpdy,
    1.97 +                   const OptionalFileDescriptorSet& aFds);
    1.98 +
    1.99 +  virtual bool RecvSetPriority(const uint16_t& priority) MOZ_OVERRIDE;
   1.100 +  virtual bool RecvSetCacheTokenCachedCharset(const nsCString& charset) MOZ_OVERRIDE;
   1.101 +  virtual bool RecvSuspend() MOZ_OVERRIDE;
   1.102 +  virtual bool RecvResume() MOZ_OVERRIDE;
   1.103 +  virtual bool RecvCancel(const nsresult& status) MOZ_OVERRIDE;
   1.104 +  virtual bool RecvRedirect2Verify(const nsresult& result,
   1.105 +                                   const RequestHeaderTuples& changedHeaders,
   1.106 +                                   const OptionalURIParams& apiRedirectUri) MOZ_OVERRIDE;
   1.107 +  virtual bool RecvUpdateAssociatedContentSecurity(const int32_t& broken,
   1.108 +                                                   const int32_t& no) MOZ_OVERRIDE;
   1.109 +  virtual bool RecvDocumentChannelCleanup() MOZ_OVERRIDE;
   1.110 +  virtual bool RecvMarkOfflineCacheEntryAsForeign() MOZ_OVERRIDE;
   1.111 +  virtual bool RecvDivertOnDataAvailable(const nsCString& data,
   1.112 +                                         const uint64_t& offset,
   1.113 +                                         const uint32_t& count) MOZ_OVERRIDE;
   1.114 +  virtual bool RecvDivertOnStopRequest(const nsresult& statusCode) MOZ_OVERRIDE;
   1.115 +  virtual bool RecvDivertComplete() MOZ_OVERRIDE;
   1.116 +  virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE;
   1.117 +
   1.118 +  // Supporting function for ADivertableParentChannel.
   1.119 +  nsresult ResumeForDiversion();
   1.120 +
   1.121 +  // Asynchronously calls NotifyDiversionFailed.
   1.122 +  void FailDiversion(nsresult aErrorCode, bool aSkipResume = true);
   1.123 +
   1.124 +  friend class HttpChannelParentListener;
   1.125 +  nsRefPtr<mozilla::dom::TabParent> mTabParent;
   1.126 +
   1.127 +private:
   1.128 +  nsRefPtr<nsHttpChannel>       mChannel;
   1.129 +  nsCOMPtr<nsICacheEntry>       mCacheEntry;
   1.130 +  nsCOMPtr<nsIAssociatedContentSecurity>  mAssociatedContentSecurity;
   1.131 +  bool mIPCClosed;                // PHttpChannel actor has been Closed()
   1.132 +
   1.133 +  nsCOMPtr<nsIChannel> mRedirectChannel;
   1.134 +  nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
   1.135 +
   1.136 +  nsAutoPtr<class nsHttpChannel::OfflineCacheEntryAsForeignMarker> mOfflineForeignMarker;
   1.137 +
   1.138 +  // state for combining OnStatus/OnProgress with OnDataAvailable
   1.139 +  // into one IPDL call to child.
   1.140 +  nsresult mStoredStatus;
   1.141 +  uint64_t mStoredProgress;
   1.142 +  uint64_t mStoredProgressMax;
   1.143 +
   1.144 +  bool mSentRedirect1Begin          : 1;
   1.145 +  bool mSentRedirect1BeginFailed    : 1;
   1.146 +  bool mReceivedRedirect2Verify     : 1;
   1.147 +
   1.148 +  PBOverrideStatus mPBOverride;
   1.149 +
   1.150 +  nsCOMPtr<nsILoadContext> mLoadContext;
   1.151 +  nsRefPtr<nsHttpHandler>  mHttpHandler;
   1.152 +
   1.153 +  nsRefPtr<HttpChannelParentListener> mParentListener;
   1.154 +  // Set to the canceled status value if the main channel was canceled.
   1.155 +  nsresult mStatus;
   1.156 +  // Once set, no OnStart/OnData/OnStop calls should be accepted; conversely, it
   1.157 +  // must be set when RecvDivertOnData/~DivertOnStop/~DivertComplete are
   1.158 +  // received from the child channel.
   1.159 +  bool mDivertingFromChild;
   1.160 +
   1.161 +  // Set if OnStart|StopRequest was called during a diversion from the child.
   1.162 +  bool mDivertedOnStartRequest;
   1.163 +
   1.164 +  bool mSuspendedForDiversion;
   1.165 +};
   1.166 +
   1.167 +} // namespace net
   1.168 +} // namespace mozilla
   1.169 +
   1.170 +#endif // mozilla_net_HttpChannelParent_h

mercurial