netwerk/base/src/nsPreloadedStream.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /**
michael@0 7 * This class allows you to prefix an existing nsIAsyncInputStream
michael@0 8 * with a preloaded block of data known at construction time by wrapping the
michael@0 9 * two data sources into a new nsIAsyncInputStream. Readers of the new
michael@0 10 * stream initially see the preloaded data and when that has been exhausted
michael@0 11 * they automatically read from the wrapped stream.
michael@0 12 *
michael@0 13 * It is used by nsHttpConnection when it has over buffered while reading from
michael@0 14 * the HTTP input socket and accidentally consumed data that belongs to
michael@0 15 * a different protocol via the HTTP Upgrade mechanism. That over-buffered
michael@0 16 * data is preloaded together with the input socket to form the new input socket
michael@0 17 * given to the new protocol handler.
michael@0 18 */
michael@0 19
michael@0 20 #ifndef nsPreloadedStream_h__
michael@0 21 #define nsPreloadedStream_h__
michael@0 22
michael@0 23 #include "nsIAsyncInputStream.h"
michael@0 24 #include "nsCOMPtr.h"
michael@0 25 #include "mozilla/Attributes.h"
michael@0 26
michael@0 27 namespace mozilla {
michael@0 28 namespace net {
michael@0 29
michael@0 30 class nsPreloadedStream MOZ_FINAL : public nsIAsyncInputStream
michael@0 31 {
michael@0 32 public:
michael@0 33 NS_DECL_THREADSAFE_ISUPPORTS
michael@0 34 NS_DECL_NSIINPUTSTREAM
michael@0 35 NS_DECL_NSIASYNCINPUTSTREAM
michael@0 36
michael@0 37 nsPreloadedStream(nsIAsyncInputStream *aStream,
michael@0 38 const char *data, uint32_t datalen);
michael@0 39 private:
michael@0 40 ~nsPreloadedStream();
michael@0 41
michael@0 42 nsCOMPtr<nsIAsyncInputStream> mStream;
michael@0 43
michael@0 44 char *mBuf;
michael@0 45 uint32_t mOffset;
michael@0 46 uint32_t mLen;
michael@0 47 };
michael@0 48
michael@0 49 } // namespace net
michael@0 50 } // namespace mozilla
michael@0 51
michael@0 52 #endif

mercurial