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.)

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

mercurial