2010-04-07 08:43:09 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 ts=8 et tw=80 : */
|
|
|
|
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-04-07 08:43:09 +00:00
|
|
|
|
|
|
|
#ifndef mozilla_net_HttpBaseChannel_h
|
|
|
|
#define mozilla_net_HttpBaseChannel_h
|
|
|
|
|
|
|
|
#include "nsHttp.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsHashPropertyBag.h"
|
|
|
|
#include "nsProxyInfo.h"
|
|
|
|
#include "nsHttpRequestHead.h"
|
|
|
|
#include "nsHttpResponseHead.h"
|
|
|
|
#include "nsHttpConnectionInfo.h"
|
2010-09-15 22:55:08 +00:00
|
|
|
#include "nsIEncodedChannel.h"
|
2010-04-07 08:43:09 +00:00
|
|
|
#include "nsIHttpChannel.h"
|
|
|
|
#include "nsIHttpChannelInternal.h"
|
2010-05-30 22:30:28 +00:00
|
|
|
#include "nsIUploadChannel.h"
|
|
|
|
#include "nsIUploadChannel2.h"
|
2010-04-07 08:43:09 +00:00
|
|
|
#include "nsIProgressEventSink.h"
|
|
|
|
#include "nsIURI.h"
|
2010-09-15 22:55:08 +00:00
|
|
|
#include "nsIStringEnumerator.h"
|
2010-04-11 04:53:35 +00:00
|
|
|
#include "nsISupportsPriority.h"
|
2010-08-11 03:11:57 +00:00
|
|
|
#include "nsIApplicationCache.h"
|
2010-08-11 03:07:09 +00:00
|
|
|
#include "nsIResumableChannel.h"
|
2011-05-24 09:32:26 +00:00
|
|
|
#include "nsITraceableChannel.h"
|
2012-07-22 22:35:33 +00:00
|
|
|
#include "nsILoadContext.h"
|
2010-10-21 21:01:38 +00:00
|
|
|
#include "mozilla/net/NeckoCommon.h"
|
2011-06-12 01:37:03 +00:00
|
|
|
#include "nsThreadUtils.h"
|
2010-04-07 08:43:09 +00:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This class is a partial implementation of nsIHttpChannel. It contains code
|
|
|
|
* shared by nsHttpChannel and HttpChannelChild.
|
|
|
|
* - Note that this class has nothing to do with nsBaseChannel, which is an
|
|
|
|
* earlier effort at a base class for channels that somehow never made it all
|
|
|
|
* the way to the HTTP channel.
|
|
|
|
*/
|
|
|
|
class HttpBaseChannel : public nsHashPropertyBag
|
2010-09-15 22:55:08 +00:00
|
|
|
, public nsIEncodedChannel
|
2010-04-07 08:43:09 +00:00
|
|
|
, public nsIHttpChannel
|
|
|
|
, public nsIHttpChannelInternal
|
2010-05-30 22:30:28 +00:00
|
|
|
, public nsIUploadChannel
|
|
|
|
, public nsIUploadChannel2
|
2010-04-11 04:53:35 +00:00
|
|
|
, public nsISupportsPriority
|
2010-08-11 03:07:09 +00:00
|
|
|
, public nsIResumableChannel
|
2011-05-24 09:32:26 +00:00
|
|
|
, public nsITraceableChannel
|
2010-04-07 08:43:09 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS_INHERITED
|
2010-05-30 22:30:28 +00:00
|
|
|
NS_DECL_NSIUPLOADCHANNEL
|
|
|
|
NS_DECL_NSIUPLOADCHANNEL2
|
2011-05-24 09:32:26 +00:00
|
|
|
NS_DECL_NSITRACEABLECHANNEL
|
2010-04-07 08:43:09 +00:00
|
|
|
|
|
|
|
HttpBaseChannel();
|
|
|
|
virtual ~HttpBaseChannel();
|
|
|
|
|
2012-09-17 15:54:09 +00:00
|
|
|
virtual nsresult Init(nsIURI *aURI, uint8_t aCaps, nsProxyInfo *aProxyInfo);
|
2010-04-07 08:43:09 +00:00
|
|
|
|
|
|
|
// nsIRequest
|
|
|
|
NS_IMETHOD GetName(nsACString& aName);
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD IsPending(bool *aIsPending);
|
2010-04-07 08:43:09 +00:00
|
|
|
NS_IMETHOD GetStatus(nsresult *aStatus);
|
|
|
|
NS_IMETHOD GetLoadGroup(nsILoadGroup **aLoadGroup);
|
|
|
|
NS_IMETHOD SetLoadGroup(nsILoadGroup *aLoadGroup);
|
|
|
|
NS_IMETHOD GetLoadFlags(nsLoadFlags *aLoadFlags);
|
|
|
|
NS_IMETHOD SetLoadFlags(nsLoadFlags aLoadFlags);
|
|
|
|
|
|
|
|
// nsIChannel
|
|
|
|
NS_IMETHOD GetOriginalURI(nsIURI **aOriginalURI);
|
|
|
|
NS_IMETHOD SetOriginalURI(nsIURI *aOriginalURI);
|
|
|
|
NS_IMETHOD GetURI(nsIURI **aURI);
|
2010-04-21 09:02:05 +00:00
|
|
|
NS_IMETHOD GetOwner(nsISupports **aOwner);
|
|
|
|
NS_IMETHOD SetOwner(nsISupports *aOwner);
|
2010-04-07 08:43:09 +00:00
|
|
|
NS_IMETHOD GetNotificationCallbacks(nsIInterfaceRequestor **aCallbacks);
|
|
|
|
NS_IMETHOD SetNotificationCallbacks(nsIInterfaceRequestor *aCallbacks);
|
|
|
|
NS_IMETHOD GetContentType(nsACString& aContentType);
|
|
|
|
NS_IMETHOD SetContentType(const nsACString& aContentType);
|
|
|
|
NS_IMETHOD GetContentCharset(nsACString& aContentCharset);
|
|
|
|
NS_IMETHOD SetContentCharset(const nsACString& aContentCharset);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetContentDisposition(uint32_t *aContentDisposition);
|
2011-09-09 22:41:04 +00:00
|
|
|
NS_IMETHOD GetContentDispositionFilename(nsAString& aContentDispositionFilename);
|
|
|
|
NS_IMETHOD GetContentDispositionHeader(nsACString& aContentDispositionHeader);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetContentLength(int32_t *aContentLength);
|
|
|
|
NS_IMETHOD SetContentLength(int32_t aContentLength);
|
2010-04-07 08:43:09 +00:00
|
|
|
NS_IMETHOD Open(nsIInputStream **aResult);
|
|
|
|
|
2010-09-15 22:55:08 +00:00
|
|
|
// nsIEncodedChannel
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD GetApplyConversion(bool *value);
|
|
|
|
NS_IMETHOD SetApplyConversion(bool value);
|
2010-09-15 22:55:08 +00:00
|
|
|
NS_IMETHOD GetContentEncodings(nsIUTF8StringEnumerator** aEncodings);
|
|
|
|
|
2010-04-07 08:43:09 +00:00
|
|
|
// HttpBaseChannel::nsIHttpChannel
|
|
|
|
NS_IMETHOD GetRequestMethod(nsACString& aMethod);
|
|
|
|
NS_IMETHOD SetRequestMethod(const nsACString& aMethod);
|
|
|
|
NS_IMETHOD GetReferrer(nsIURI **referrer);
|
|
|
|
NS_IMETHOD SetReferrer(nsIURI *referrer);
|
|
|
|
NS_IMETHOD GetRequestHeader(const nsACString& aHeader, nsACString& aValue);
|
|
|
|
NS_IMETHOD SetRequestHeader(const nsACString& aHeader,
|
2011-09-29 06:19:26 +00:00
|
|
|
const nsACString& aValue, bool aMerge);
|
2010-04-07 08:43:09 +00:00
|
|
|
NS_IMETHOD VisitRequestHeaders(nsIHttpHeaderVisitor *visitor);
|
|
|
|
NS_IMETHOD GetResponseHeader(const nsACString &header, nsACString &value);
|
|
|
|
NS_IMETHOD SetResponseHeader(const nsACString& header,
|
2011-09-29 06:19:26 +00:00
|
|
|
const nsACString& value, bool merge);
|
2010-04-07 08:43:09 +00:00
|
|
|
NS_IMETHOD VisitResponseHeaders(nsIHttpHeaderVisitor *visitor);
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD GetAllowPipelining(bool *value);
|
|
|
|
NS_IMETHOD SetAllowPipelining(bool value);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetRedirectionLimit(uint32_t *value);
|
|
|
|
NS_IMETHOD SetRedirectionLimit(uint32_t value);
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD IsNoStoreResponse(bool *value);
|
|
|
|
NS_IMETHOD IsNoCacheResponse(bool *value);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetResponseStatus(uint32_t *aValue);
|
2010-04-07 08:43:09 +00:00
|
|
|
NS_IMETHOD GetResponseStatusText(nsACString& aValue);
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD GetRequestSucceeded(bool *aValue);
|
2010-04-07 08:43:09 +00:00
|
|
|
|
|
|
|
// nsIHttpChannelInternal
|
|
|
|
NS_IMETHOD GetDocumentURI(nsIURI **aDocumentURI);
|
|
|
|
NS_IMETHOD SetDocumentURI(nsIURI *aDocumentURI);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetRequestVersion(uint32_t *major, uint32_t *minor);
|
|
|
|
NS_IMETHOD GetResponseVersion(uint32_t *major, uint32_t *minor);
|
2010-04-07 08:43:09 +00:00
|
|
|
NS_IMETHOD SetCookie(const char *aCookieHeader);
|
2011-09-29 06:19:26 +00:00
|
|
|
NS_IMETHOD GetForceAllowThirdPartyCookie(bool *aForce);
|
|
|
|
NS_IMETHOD SetForceAllowThirdPartyCookie(bool aForce);
|
|
|
|
NS_IMETHOD GetCanceled(bool *aCanceled);
|
|
|
|
NS_IMETHOD GetChannelIsForDownload(bool *aChannelIsForDownload);
|
|
|
|
NS_IMETHOD SetChannelIsForDownload(bool aChannelIsForDownload);
|
2011-03-24 03:36:53 +00:00
|
|
|
NS_IMETHOD SetCacheKeysRedirectChain(nsTArray<nsCString> *cacheKeys);
|
2011-05-05 15:45:59 +00:00
|
|
|
NS_IMETHOD GetLocalAddress(nsACString& addr);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetLocalPort(int32_t* port);
|
2011-05-05 15:45:59 +00:00
|
|
|
NS_IMETHOD GetRemoteAddress(nsACString& addr);
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetRemotePort(int32_t* port);
|
2011-12-13 15:55:50 +00:00
|
|
|
NS_IMETHOD GetAllowSpdy(bool *aAllowSpdy);
|
|
|
|
NS_IMETHOD SetAllowSpdy(bool aAllowSpdy);
|
|
|
|
|
2011-03-24 03:36:53 +00:00
|
|
|
inline void CleanRedirectCacheChainIfNecessary()
|
|
|
|
{
|
2012-07-30 14:20:58 +00:00
|
|
|
mRedirectedCachekeys = nullptr;
|
2011-03-24 03:36:53 +00:00
|
|
|
}
|
2011-05-19 23:43:37 +00:00
|
|
|
NS_IMETHOD HTTPUpgrade(const nsACString & aProtocolName,
|
|
|
|
nsIHttpUpgradeListener *aListener);
|
2010-04-07 08:43:09 +00:00
|
|
|
|
2010-04-11 04:53:35 +00:00
|
|
|
// nsISupportsPriority
|
2012-08-22 15:56:38 +00:00
|
|
|
NS_IMETHOD GetPriority(int32_t *value);
|
|
|
|
NS_IMETHOD AdjustPriority(int32_t delta);
|
2010-04-11 04:53:35 +00:00
|
|
|
|
2010-08-11 03:07:09 +00:00
|
|
|
// nsIResumableChannel
|
|
|
|
NS_IMETHOD GetEntityID(nsACString& aEntityID);
|
|
|
|
|
2010-09-15 22:55:08 +00:00
|
|
|
class nsContentEncodings : public nsIUTF8StringEnumerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIUTF8STRINGENUMERATOR
|
|
|
|
|
|
|
|
nsContentEncodings(nsIHttpChannel* aChannel, const char* aEncodingHeader);
|
|
|
|
virtual ~nsContentEncodings();
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsresult PrepareForNext(void);
|
|
|
|
|
|
|
|
// We do not own the buffer. The channel owns it.
|
|
|
|
const char* mEncodingHeader;
|
|
|
|
const char* mCurStart; // points to start of current header
|
|
|
|
const char* mCurEnd; // points to end of current header
|
|
|
|
|
|
|
|
// Hold a ref to our channel so that it can't go away and take the
|
|
|
|
// header with it.
|
|
|
|
nsCOMPtr<nsIHttpChannel> mChannel;
|
|
|
|
|
2011-09-29 06:19:26 +00:00
|
|
|
bool mReady;
|
2010-09-15 22:55:08 +00:00
|
|
|
};
|
|
|
|
|
2011-01-24 22:58:20 +00:00
|
|
|
nsHttpResponseHead * GetResponseHead() const { return mResponseHead; }
|
|
|
|
nsHttpRequestHead * GetRequestHead() { return &mRequestHead; }
|
2010-10-02 04:17:23 +00:00
|
|
|
|
2011-05-05 15:45:59 +00:00
|
|
|
const PRNetAddr& GetSelfAddr() { return mSelfAddr; }
|
|
|
|
const PRNetAddr& GetPeerAddr() { return mPeerAddr; }
|
|
|
|
|
2011-06-12 01:37:03 +00:00
|
|
|
public: /* Necko internal use only... */
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
bool ShouldRewriteRedirectToGET(uint32_t httpStatus, nsHttpAtom method);
|
2011-10-14 15:46:33 +00:00
|
|
|
bool IsSafeMethod(nsHttpAtom method);
|
2012-07-22 22:35:33 +00:00
|
|
|
|
2010-04-07 08:43:09 +00:00
|
|
|
protected:
|
2011-06-12 01:37:03 +00:00
|
|
|
|
|
|
|
// Handle notifying listener, removing from loadgroup if request failed.
|
|
|
|
void DoNotifyListener();
|
|
|
|
virtual void DoNotifyListenerCleanup() = 0;
|
|
|
|
|
2010-09-15 22:55:08 +00:00
|
|
|
nsresult ApplyContentConversions();
|
|
|
|
|
2010-06-15 23:07:10 +00:00
|
|
|
void AddCookiesToRequest();
|
2010-08-11 03:11:57 +00:00
|
|
|
virtual nsresult SetupReplacementChannel(nsIURI *,
|
|
|
|
nsIChannel *,
|
2012-07-25 02:40:34 +00:00
|
|
|
bool preserveMethod);
|
2010-06-15 23:07:10 +00:00
|
|
|
|
2010-05-13 17:28:51 +00:00
|
|
|
// Helper function to simplify getting notification callbacks.
|
|
|
|
template <class T>
|
|
|
|
void GetCallback(nsCOMPtr<T> &aResult)
|
|
|
|
{
|
|
|
|
NS_QueryNotificationCallbacks(mCallbacks, mLoadGroup,
|
|
|
|
NS_GET_TEMPLATE_IID(T),
|
|
|
|
getter_AddRefs(aResult));
|
|
|
|
}
|
|
|
|
|
2010-04-07 08:43:09 +00:00
|
|
|
nsCOMPtr<nsIURI> mURI;
|
|
|
|
nsCOMPtr<nsIURI> mOriginalURI;
|
|
|
|
nsCOMPtr<nsIURI> mDocumentURI;
|
|
|
|
nsCOMPtr<nsIStreamListener> mListener;
|
|
|
|
nsCOMPtr<nsISupports> mListenerContext;
|
|
|
|
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
2010-04-21 09:02:05 +00:00
|
|
|
nsCOMPtr<nsISupports> mOwner;
|
2010-04-07 08:43:09 +00:00
|
|
|
nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
|
|
|
|
nsCOMPtr<nsIProgressEventSink> mProgressSink;
|
|
|
|
nsCOMPtr<nsIURI> mReferrer;
|
2010-08-11 03:11:57 +00:00
|
|
|
nsCOMPtr<nsIApplicationCache> mApplicationCache;
|
2010-04-07 08:43:09 +00:00
|
|
|
|
|
|
|
nsHttpRequestHead mRequestHead;
|
2010-05-30 22:30:28 +00:00
|
|
|
nsCOMPtr<nsIInputStream> mUploadStream;
|
2010-04-07 08:43:09 +00:00
|
|
|
nsAutoPtr<nsHttpResponseHead> mResponseHead;
|
|
|
|
nsRefPtr<nsHttpConnectionInfo> mConnectionInfo;
|
|
|
|
|
|
|
|
nsCString mSpec; // ASCII encoded URL spec
|
|
|
|
nsCString mContentTypeHint;
|
|
|
|
nsCString mContentCharsetHint;
|
2010-06-15 23:07:10 +00:00
|
|
|
nsCString mUserSetCookieHeader;
|
2010-04-07 08:43:09 +00:00
|
|
|
|
2011-05-05 15:45:59 +00:00
|
|
|
PRNetAddr mSelfAddr;
|
|
|
|
PRNetAddr mPeerAddr;
|
|
|
|
|
2011-05-19 23:43:37 +00:00
|
|
|
// HTTP Upgrade Data
|
|
|
|
nsCString mUpgradeProtocol;
|
|
|
|
nsCOMPtr<nsIHttpUpgradeListener> mUpgradeProtocolCallback;
|
|
|
|
|
2010-08-11 03:07:09 +00:00
|
|
|
// Resumable channel specific data
|
|
|
|
nsCString mEntityID;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t mStartPos;
|
2010-08-11 03:07:09 +00:00
|
|
|
|
2010-04-07 08:43:09 +00:00
|
|
|
nsresult mStatus;
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mLoadFlags;
|
|
|
|
int16_t mPriority;
|
|
|
|
uint8_t mCaps;
|
|
|
|
uint8_t mRedirectionLimit;
|
|
|
|
|
|
|
|
uint32_t mApplyConversion : 1;
|
|
|
|
uint32_t mCanceled : 1;
|
|
|
|
uint32_t mIsPending : 1;
|
|
|
|
uint32_t mWasOpened : 1;
|
|
|
|
uint32_t mResponseHeadersModified : 1;
|
|
|
|
uint32_t mAllowPipelining : 1;
|
|
|
|
uint32_t mForceAllowThirdPartyCookie : 1;
|
|
|
|
uint32_t mUploadStreamHasHeaders : 1;
|
|
|
|
uint32_t mInheritApplicationCache : 1;
|
|
|
|
uint32_t mChooseApplicationCache : 1;
|
|
|
|
uint32_t mLoadedFromApplicationCache : 1;
|
|
|
|
uint32_t mChannelIsForDownload : 1;
|
|
|
|
uint32_t mTracingEnabled : 1;
|
2011-05-21 10:03:36 +00:00
|
|
|
// True if timing collection is enabled
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mTimingEnabled : 1;
|
|
|
|
uint32_t mAllowSpdy : 1;
|
|
|
|
uint32_t mPrivateBrowsing : 1;
|
2011-03-24 03:36:53 +00:00
|
|
|
|
2011-06-12 01:37:03 +00:00
|
|
|
// Current suspension depth for this channel object
|
2012-08-22 15:56:38 +00:00
|
|
|
uint32_t mSuspendCount;
|
2011-06-12 01:37:03 +00:00
|
|
|
|
2012-05-31 22:20:05 +00:00
|
|
|
nsAutoPtr<nsTArray<nsCString> > mRedirectedCachekeys;
|
2010-04-07 08:43:09 +00:00
|
|
|
};
|
|
|
|
|
2011-06-12 01:37:03 +00:00
|
|
|
// Share some code while working around C++'s absurd inability to handle casting
|
|
|
|
// of member functions between base/derived types.
|
|
|
|
// - We want to store member function pointer to call at resume time, but one
|
|
|
|
// such function--HandleAsyncAbort--we want to share between the
|
|
|
|
// nsHttpChannel/HttpChannelChild. Can't define it in base class, because
|
|
|
|
// then we'd have to cast member function ptr between base/derived class
|
|
|
|
// types. Sigh...
|
|
|
|
template <class T>
|
|
|
|
class HttpAsyncAborter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HttpAsyncAborter(T *derived) : mThis(derived), mCallOnResume(0) {}
|
|
|
|
|
|
|
|
// Aborts channel: calls OnStart/Stop with provided status, removes channel
|
|
|
|
// from loadGroup.
|
|
|
|
nsresult AsyncAbort(nsresult status);
|
|
|
|
|
|
|
|
// Does most the actual work.
|
|
|
|
void HandleAsyncAbort();
|
|
|
|
|
|
|
|
// AsyncCall calls a member function asynchronously (via an event).
|
|
|
|
// retval isn't refcounted and is set only when event was successfully
|
|
|
|
// posted, the event is returned for the purpose of cancelling when needed
|
|
|
|
nsresult AsyncCall(void (T::*funcPtr)(),
|
2012-07-30 14:20:58 +00:00
|
|
|
nsRunnableMethod<T> **retval = nullptr);
|
2011-06-12 01:37:03 +00:00
|
|
|
private:
|
|
|
|
T *mThis;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Function to be called at resume time
|
|
|
|
void (T::* mCallOnResume)(void);
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
nsresult HttpAsyncAborter<T>::AsyncAbort(nsresult status)
|
|
|
|
{
|
|
|
|
LOG(("HttpAsyncAborter::AsyncAbort [this=%p status=%x]\n", mThis, status));
|
|
|
|
|
|
|
|
mThis->mStatus = status;
|
2011-10-17 14:59:28 +00:00
|
|
|
mThis->mIsPending = false;
|
2011-06-12 01:37:03 +00:00
|
|
|
|
|
|
|
// if this fails? Callers ignore our return value anyway....
|
|
|
|
return AsyncCall(&T::HandleAsyncAbort);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Each subclass needs to define its own version of this (which just calls this
|
|
|
|
// base version), else we wind up casting base/derived member function ptrs
|
|
|
|
template <class T>
|
|
|
|
inline void HttpAsyncAborter<T>::HandleAsyncAbort()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(!mCallOnResume, "How did that happen?");
|
|
|
|
|
|
|
|
if (mThis->mSuspendCount) {
|
|
|
|
LOG(("Waiting until resume to do async notification [this=%p]\n",
|
|
|
|
mThis));
|
|
|
|
mCallOnResume = &T::HandleAsyncAbort;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mThis->DoNotifyListener();
|
|
|
|
|
|
|
|
// finally remove ourselves from the load group.
|
|
|
|
if (mThis->mLoadGroup)
|
2012-07-30 14:20:58 +00:00
|
|
|
mThis->mLoadGroup->RemoveRequest(mThis, nullptr, mThis->mStatus);
|
2011-06-12 01:37:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
nsresult HttpAsyncAborter<T>::AsyncCall(void (T::*funcPtr)(),
|
|
|
|
nsRunnableMethod<T> **retval)
|
|
|
|
{
|
|
|
|
nsresult rv;
|
|
|
|
|
|
|
|
nsRefPtr<nsRunnableMethod<T> > event = NS_NewRunnableMethod(mThis, funcPtr);
|
|
|
|
rv = NS_DispatchToCurrentThread(event);
|
|
|
|
if (NS_SUCCEEDED(rv) && retval) {
|
|
|
|
*retval = event;
|
|
|
|
}
|
|
|
|
|
|
|
|
return rv;
|
|
|
|
}
|
2010-04-07 08:43:09 +00:00
|
|
|
|
|
|
|
} // namespace net
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_net_HttpBaseChannel_h
|