Bug 1684463 - [devtools] Part 1: Shorten the _createAttribute function by refactoring...
[gecko.git] / layout / style / StreamLoader.h
blob96c1588d17c56ff46ebad0d984947293d73f6406
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 "nsString.h"
12 #include "mozilla/css/SheetLoadData.h"
13 #include "mozilla/Assertions.h"
15 class nsIInputStream;
17 namespace mozilla {
18 namespace css {
20 class StreamLoader : public nsIStreamListener {
21 public:
22 NS_DECL_ISUPPORTS
23 NS_DECL_NSIREQUESTOBSERVER
24 NS_DECL_NSISTREAMLISTENER
26 explicit StreamLoader(SheetLoadData&);
28 void ChannelOpenFailed(nsresult rv) {
29 #ifdef NIGHTLY_BUILD
30 mChannelOpenFailed = true;
31 #endif
34 private:
35 virtual ~StreamLoader();
37 /**
38 * callback method used for ReadSegments
40 static nsresult WriteSegmentFun(nsIInputStream*, void*, const char*, uint32_t,
41 uint32_t, uint32_t*);
43 void HandleBOM();
45 RefPtr<SheetLoadData> mSheetLoadData;
46 nsresult mStatus;
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.
52 nsCString mBytes;
53 nsAutoCStringN<3> mBOMBytes;
55 #ifdef NIGHTLY_BUILD
56 bool mChannelOpenFailed = false;
57 bool mOnStopRequestCalled = false;
58 #endif
61 } // namespace css
62 } // namespace mozilla
64 #endif // mozilla_css_StreamLoader_h