Bug 1839315: part 4) Link from `SheetLoadData::mWasAlternate` to spec. r=emilio DONTBUILD
[gecko.git] / layout / style / StreamLoader.h
blobc941444eb19da283a20c18a864edc7ad2e7ae2e2
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"
11 #include "nsIThreadRetargetableStreamListener.h"
12 #include "nsString.h"
13 #include "mozilla/css/SheetLoadData.h"
14 #include "mozilla/Assertions.h"
16 class nsIInputStream;
18 namespace mozilla::css {
20 class StreamLoader : public nsIStreamListener,
21 public nsIThreadRetargetableStreamListener {
22 public:
23 NS_DECL_THREADSAFE_ISUPPORTS
24 NS_DECL_NSIREQUESTOBSERVER
25 NS_DECL_NSISTREAMLISTENER
26 NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
28 explicit StreamLoader(SheetLoadData&);
30 void ChannelOpenFailed(nsresult rv) {
31 #ifdef NIGHTLY_BUILD
32 mChannelOpenFailed = true;
33 #endif
36 private:
37 virtual ~StreamLoader();
39 /**
40 * callback method used for ReadSegments
42 static nsresult WriteSegmentFun(nsIInputStream*, void*, const char*, uint32_t,
43 uint32_t, uint32_t*);
45 void HandleBOM();
47 RefPtr<SheetLoadData> mSheetLoadData;
48 nsresult mStatus;
49 Maybe<const Encoding*> mEncodingFromBOM;
51 // We store the initial three bytes of the stream into mBOMBytes, and then
52 // use that buffer to detect a BOM. We then shift any non-BOM bytes into
53 // mBytes, and store all subsequent data in that buffer.
54 nsCString mBytes;
55 nsAutoCStringN<3> mBOMBytes;
57 #ifdef NIGHTLY_BUILD
58 bool mChannelOpenFailed = false;
59 bool mOnStopRequestCalled = false;
60 #endif
63 } // namespace mozilla::css
65 #endif // mozilla_css_StreamLoader_h