michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim: set sw=2 ts=8 et tw=80 : */ michael@0: michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_net_HttpChannelParent_h michael@0: #define mozilla_net_HttpChannelParent_h michael@0: michael@0: #include "ADivertableParentChannel.h" michael@0: #include "nsHttp.h" michael@0: #include "mozilla/dom/PBrowserParent.h" michael@0: #include "mozilla/net/PHttpChannelParent.h" michael@0: #include "mozilla/net/NeckoCommon.h" michael@0: #include "mozilla/net/NeckoParent.h" michael@0: #include "nsIParentRedirectingChannel.h" michael@0: #include "nsIProgressEventSink.h" michael@0: #include "nsHttpChannel.h" michael@0: michael@0: class nsICacheEntry; michael@0: class nsIAssociatedContentSecurity; michael@0: michael@0: namespace mozilla { michael@0: michael@0: namespace dom{ michael@0: class TabParent; michael@0: } michael@0: michael@0: namespace net { michael@0: michael@0: class HttpChannelParentListener; michael@0: michael@0: class HttpChannelParent : public PHttpChannelParent michael@0: , public nsIParentRedirectingChannel michael@0: , public nsIProgressEventSink michael@0: , public nsIInterfaceRequestor michael@0: , public ADivertableParentChannel michael@0: { michael@0: public: michael@0: NS_DECL_ISUPPORTS michael@0: NS_DECL_NSIREQUESTOBSERVER michael@0: NS_DECL_NSISTREAMLISTENER michael@0: NS_DECL_NSIPARENTCHANNEL michael@0: NS_DECL_NSIPARENTREDIRECTINGCHANNEL michael@0: NS_DECL_NSIPROGRESSEVENTSINK michael@0: NS_DECL_NSIINTERFACEREQUESTOR michael@0: michael@0: HttpChannelParent(mozilla::dom::PBrowserParent* iframeEmbedding, michael@0: nsILoadContext* aLoadContext, michael@0: PBOverrideStatus aStatus); michael@0: virtual ~HttpChannelParent(); michael@0: michael@0: bool Init(const HttpChannelCreationArgs& aOpenArgs); michael@0: michael@0: // ADivertableParentChannel functions. michael@0: void DivertTo(nsIStreamListener *aListener) MOZ_OVERRIDE; michael@0: nsresult SuspendForDiversion() MOZ_OVERRIDE; michael@0: michael@0: // Calls OnStartRequest for "DivertTo" listener, then notifies child channel michael@0: // that it should divert OnDataAvailable and OnStopRequest calls to this michael@0: // parent channel. michael@0: void StartDiversion(); michael@0: michael@0: // Handles calling OnStart/Stop if there are errors during diversion. michael@0: // Called asynchronously from FailDiversion. michael@0: void NotifyDiversionFailed(nsresult aErrorCode, bool aSkipResume = true); michael@0: michael@0: protected: michael@0: // used to connect redirected-to channel in parent with just created michael@0: // ChildChannel. Used during redirects. michael@0: bool ConnectChannel(const uint32_t& channelId); michael@0: michael@0: bool DoAsyncOpen(const URIParams& uri, michael@0: const OptionalURIParams& originalUri, michael@0: const OptionalURIParams& docUri, michael@0: const OptionalURIParams& referrerUri, michael@0: const OptionalURIParams& internalRedirectUri, michael@0: const uint32_t& loadFlags, michael@0: const RequestHeaderTuples& requestHeaders, michael@0: const nsCString& requestMethod, michael@0: const OptionalInputStreamParams& uploadStream, michael@0: const bool& uploadStreamHasHeaders, michael@0: const uint16_t& priority, michael@0: const uint8_t& redirectionLimit, michael@0: const bool& allowPipelining, michael@0: const bool& forceAllowThirdPartyCookie, michael@0: const bool& doResumeAt, michael@0: const uint64_t& startPos, michael@0: const nsCString& entityID, michael@0: const bool& chooseApplicationCache, michael@0: const nsCString& appCacheClientID, michael@0: const bool& allowSpdy, michael@0: const OptionalFileDescriptorSet& aFds); michael@0: michael@0: virtual bool RecvSetPriority(const uint16_t& priority) MOZ_OVERRIDE; michael@0: virtual bool RecvSetCacheTokenCachedCharset(const nsCString& charset) MOZ_OVERRIDE; michael@0: virtual bool RecvSuspend() MOZ_OVERRIDE; michael@0: virtual bool RecvResume() MOZ_OVERRIDE; michael@0: virtual bool RecvCancel(const nsresult& status) MOZ_OVERRIDE; michael@0: virtual bool RecvRedirect2Verify(const nsresult& result, michael@0: const RequestHeaderTuples& changedHeaders, michael@0: const OptionalURIParams& apiRedirectUri) MOZ_OVERRIDE; michael@0: virtual bool RecvUpdateAssociatedContentSecurity(const int32_t& broken, michael@0: const int32_t& no) MOZ_OVERRIDE; michael@0: virtual bool RecvDocumentChannelCleanup() MOZ_OVERRIDE; michael@0: virtual bool RecvMarkOfflineCacheEntryAsForeign() MOZ_OVERRIDE; michael@0: virtual bool RecvDivertOnDataAvailable(const nsCString& data, michael@0: const uint64_t& offset, michael@0: const uint32_t& count) MOZ_OVERRIDE; michael@0: virtual bool RecvDivertOnStopRequest(const nsresult& statusCode) MOZ_OVERRIDE; michael@0: virtual bool RecvDivertComplete() MOZ_OVERRIDE; michael@0: virtual void ActorDestroy(ActorDestroyReason why) MOZ_OVERRIDE; michael@0: michael@0: // Supporting function for ADivertableParentChannel. michael@0: nsresult ResumeForDiversion(); michael@0: michael@0: // Asynchronously calls NotifyDiversionFailed. michael@0: void FailDiversion(nsresult aErrorCode, bool aSkipResume = true); michael@0: michael@0: friend class HttpChannelParentListener; michael@0: nsRefPtr mTabParent; michael@0: michael@0: private: michael@0: nsRefPtr mChannel; michael@0: nsCOMPtr mCacheEntry; michael@0: nsCOMPtr mAssociatedContentSecurity; michael@0: bool mIPCClosed; // PHttpChannel actor has been Closed() michael@0: michael@0: nsCOMPtr mRedirectChannel; michael@0: nsCOMPtr mRedirectCallback; michael@0: michael@0: nsAutoPtr mOfflineForeignMarker; michael@0: michael@0: // state for combining OnStatus/OnProgress with OnDataAvailable michael@0: // into one IPDL call to child. michael@0: nsresult mStoredStatus; michael@0: uint64_t mStoredProgress; michael@0: uint64_t mStoredProgressMax; michael@0: michael@0: bool mSentRedirect1Begin : 1; michael@0: bool mSentRedirect1BeginFailed : 1; michael@0: bool mReceivedRedirect2Verify : 1; michael@0: michael@0: PBOverrideStatus mPBOverride; michael@0: michael@0: nsCOMPtr mLoadContext; michael@0: nsRefPtr mHttpHandler; michael@0: michael@0: nsRefPtr mParentListener; michael@0: // Set to the canceled status value if the main channel was canceled. michael@0: nsresult mStatus; michael@0: // Once set, no OnStart/OnData/OnStop calls should be accepted; conversely, it michael@0: // must be set when RecvDivertOnData/~DivertOnStop/~DivertComplete are michael@0: // received from the child channel. michael@0: bool mDivertingFromChild; michael@0: michael@0: // Set if OnStart|StopRequest was called during a diversion from the child. michael@0: bool mDivertedOnStartRequest; michael@0: michael@0: bool mSuspendedForDiversion; michael@0: }; michael@0: michael@0: } // namespace net michael@0: } // namespace mozilla michael@0: michael@0: #endif // mozilla_net_HttpChannelParent_h