2013-05-28 21:07:03 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
// SPDY Server Push as defined by
|
|
|
|
// http://dev.chromium.org/spdy/spdy-protocol/spdy-protocol-draft3
|
|
|
|
|
|
|
|
#ifndef mozilla_net_SpdyPush3_Internal_h
|
|
|
|
#define mozilla_net_SpdyPush3_Internal_h
|
|
|
|
|
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
#include "mozilla/TimeStamp.h"
|
|
|
|
#include "nsILoadGroup.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "SpdyStream3.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace net {
|
|
|
|
|
2013-09-22 20:35:52 -07:00
|
|
|
class SpdySession3;
|
|
|
|
|
2013-05-28 21:07:03 -07:00
|
|
|
class SpdyPush3TransactionBuffer;
|
|
|
|
|
|
|
|
class SpdyPushedStream3 MOZ_FINAL : public SpdyStream3
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
SpdyPushedStream3(SpdyPush3TransactionBuffer *aTransaction,
|
|
|
|
SpdySession3 *aSession,
|
|
|
|
SpdyStream3 *aAssociatedStream,
|
|
|
|
uint32_t aID);
|
|
|
|
virtual ~SpdyPushedStream3() {}
|
|
|
|
|
|
|
|
bool GetPushComplete();
|
|
|
|
SpdyStream3 *GetConsumerStream() { return mConsumerStream; };
|
|
|
|
void SetConsumerStream(SpdyStream3 *aStream) { mConsumerStream = aStream; }
|
|
|
|
bool GetHashKey(nsCString &key);
|
|
|
|
|
|
|
|
// override of SpdyStream3
|
|
|
|
nsresult ReadSegments(nsAHttpSegmentReader *, uint32_t, uint32_t *);
|
|
|
|
nsresult WriteSegments(nsAHttpSegmentWriter *, uint32_t, uint32_t *);
|
|
|
|
|
|
|
|
nsILoadGroupConnectionInfo *LoadGroupConnectionInfo() { return mLoadGroupCI; };
|
|
|
|
void ConnectPushedStream(SpdyStream3 *consumer);
|
|
|
|
|
|
|
|
bool DeferCleanupOnSuccess() { return mDeferCleanupOnSuccess; }
|
|
|
|
void SetDeferCleanupOnSuccess(bool val) { mDeferCleanupOnSuccess = val; }
|
|
|
|
|
|
|
|
bool IsOrphaned(TimeStamp now);
|
|
|
|
|
|
|
|
nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
|
|
|
|
|
|
|
|
// overload of SpdyStream3
|
|
|
|
virtual bool HasSink() { return !!mConsumerStream; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
SpdyStream3 *mConsumerStream; // paired request stream that consumes from
|
|
|
|
// real spdy one.. null until a match is made.
|
|
|
|
|
|
|
|
nsCOMPtr<nsILoadGroupConnectionInfo> mLoadGroupCI;
|
|
|
|
|
|
|
|
SpdyPush3TransactionBuffer *mBufferedPush;
|
2014-01-07 14:05:56 -08:00
|
|
|
TimeStamp mLastRead;
|
2013-05-28 21:07:03 -07:00
|
|
|
|
|
|
|
nsCString mHashKey;
|
|
|
|
nsresult mStatus;
|
|
|
|
bool mPushCompleted; // server push FIN received
|
|
|
|
bool mDeferCleanupOnSuccess;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SpdyPush3TransactionBuffer MOZ_FINAL : public nsAHttpTransaction
|
|
|
|
{
|
|
|
|
public:
|
2013-07-18 19:24:13 -07:00
|
|
|
NS_DECL_THREADSAFE_ISUPPORTS
|
2013-05-28 21:07:03 -07:00
|
|
|
NS_DECL_NSAHTTPTRANSACTION
|
|
|
|
|
|
|
|
SpdyPush3TransactionBuffer();
|
|
|
|
virtual ~SpdyPush3TransactionBuffer();
|
|
|
|
|
|
|
|
nsresult GetBufferedData(char *buf, uint32_t count, uint32_t *countWritten);
|
|
|
|
void SetPushStream(SpdyPushedStream3 *stream) { mPushStream = stream; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
const static uint32_t kDefaultBufferSize = 4096;
|
|
|
|
|
|
|
|
nsresult mStatus;
|
|
|
|
nsHttpRequestHead *mRequestHead;
|
|
|
|
SpdyPushedStream3 *mPushStream;
|
|
|
|
bool mIsDone;
|
|
|
|
|
|
|
|
nsAutoArrayPtr<char> mBufferedHTTP1;
|
|
|
|
uint32_t mBufferedHTTP1Size;
|
|
|
|
uint32_t mBufferedHTTP1Used;
|
|
|
|
uint32_t mBufferedHTTP1Consumed;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla::net
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // mozilla_net_SpdyPush3_Internal_h
|