1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_css_StreamLoader_h
8 #define mozilla_css_StreamLoader_h
10 #include "nsIStreamListener.h"
12 #include "mozilla/css/SheetLoadData.h"
13 #include "mozilla/Assertions.h"
20 class StreamLoader
: public nsIStreamListener
{
23 NS_DECL_NSIREQUESTOBSERVER
24 NS_DECL_NSISTREAMLISTENER
26 explicit StreamLoader(SheetLoadData
&);
28 void ChannelOpenFailed(nsresult rv
) {
30 mChannelOpenFailed
= true;
35 virtual ~StreamLoader();
38 * callback method used for ReadSegments
40 static nsresult
WriteSegmentFun(nsIInputStream
*, void*, const char*, uint32_t,
45 RefPtr
<SheetLoadData
> mSheetLoadData
;
47 Maybe
<const Encoding
*> mEncodingFromBOM
;
49 // We store the initial three bytes of the stream into mBOMBytes, and then
50 // use that buffer to detect a BOM. We then shift any non-BOM bytes into
51 // mBytes, and store all subsequent data in that buffer.
53 nsAutoCStringN
<3> mBOMBytes
;
56 bool mChannelOpenFailed
= false;
57 bool mOnStopRequestCalled
= false;
62 } // namespace mozilla
64 #endif // mozilla_css_StreamLoader_h