nsFileChannel.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* vim:set ts=2 sw=2 sts=2 et cin: */
  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/. */
  6. #ifndef nsFileChannel_h__
  7. #define nsFileChannel_h__
  8. #include "nsBaseChannel.h"
  9. #include "nsIFileChannel.h"
  10. #include "nsIUploadChannel.h"
  11. class nsFileChannel : public nsBaseChannel
  12. , public nsIFileChannel
  13. , public nsIUploadChannel
  14. {
  15. public:
  16. NS_DECL_ISUPPORTS_INHERITED
  17. NS_DECL_NSIFILECHANNEL
  18. NS_DECL_NSIUPLOADCHANNEL
  19. explicit nsFileChannel(nsIURI *uri);
  20. protected:
  21. ~nsFileChannel();
  22. // Called to construct a blocking file input stream for the given file. This
  23. // method also returns a best guess at the content-type for the data stream.
  24. // NOTE: If the channel has a type hint set, contentType will be left
  25. // untouched. The caller should not use it in that case.
  26. MOZ_MUST_USE nsresult MakeFileInputStream(nsIFile *file,
  27. nsCOMPtr<nsIInputStream> &stream,
  28. nsCString &contentType, bool async);
  29. virtual MOZ_MUST_USE nsresult OpenContentStream(bool async,
  30. nsIInputStream **result,
  31. nsIChannel** channel) override;
  32. private:
  33. nsCOMPtr<nsIInputStream> mUploadStream;
  34. int64_t mUploadLength;
  35. };
  36. #endif // !nsFileChannel_h__