WyciwygChannelChild.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. #ifndef mozilla_net_WyciwygChannelChild_h
  5. #define mozilla_net_WyciwygChannelChild_h
  6. #include "mozilla/net/PWyciwygChannelChild.h"
  7. #include "nsIWyciwygChannel.h"
  8. #include "nsIChannel.h"
  9. #include "nsILoadInfo.h"
  10. #include "PrivateBrowsingChannel.h"
  11. class nsIProgressEventSink;
  12. namespace mozilla {
  13. namespace net {
  14. class ChannelEventQueue;
  15. // TODO: replace with IPDL states
  16. enum WyciwygChannelChildState {
  17. WCC_NEW,
  18. WCC_INIT,
  19. // States when reading from the channel
  20. WCC_OPENED,
  21. WCC_ONSTART,
  22. WCC_ONDATA,
  23. WCC_ONSTOP,
  24. // States when writing to the cache
  25. WCC_ONWRITE,
  26. WCC_ONCLOSED
  27. };
  28. // Header file contents
  29. class WyciwygChannelChild final : public PWyciwygChannelChild
  30. , public nsIWyciwygChannel
  31. , public PrivateBrowsingChannel<WyciwygChannelChild>
  32. {
  33. public:
  34. NS_DECL_ISUPPORTS
  35. NS_DECL_NSIREQUEST
  36. NS_DECL_NSICHANNEL
  37. NS_DECL_NSIWYCIWYGCHANNEL
  38. WyciwygChannelChild();
  39. void AddIPDLReference();
  40. void ReleaseIPDLReference();
  41. nsresult Init(nsIURI *uri);
  42. bool IsSuspended();
  43. protected:
  44. virtual ~WyciwygChannelChild();
  45. bool RecvOnStartRequest(const nsresult& statusCode,
  46. const int64_t& contentLength,
  47. const int32_t& source,
  48. const nsCString& charset,
  49. const nsCString& securityInfo) override;
  50. bool RecvOnDataAvailable(const nsCString& data,
  51. const uint64_t& offset) override;
  52. bool RecvOnStopRequest(const nsresult& statusCode) override;
  53. bool RecvCancelEarly(const nsresult& statusCode) override;
  54. void OnStartRequest(const nsresult& statusCode,
  55. const int64_t& contentLength,
  56. const int32_t& source,
  57. const nsCString& charset,
  58. const nsCString& securityInfo);
  59. void OnDataAvailable(const nsCString& data,
  60. const uint64_t& offset);
  61. void OnStopRequest(const nsresult& statusCode);
  62. void CancelEarly(const nsresult& statusCode);
  63. friend class PrivateBrowsingChannel<WyciwygChannelChild>;
  64. private:
  65. nsresult mStatus;
  66. bool mIsPending;
  67. bool mCanceled;
  68. uint32_t mLoadFlags;
  69. int64_t mContentLength;
  70. int32_t mCharsetSource;
  71. nsCString mCharset;
  72. nsCOMPtr<nsIURI> mURI;
  73. nsCOMPtr<nsIURI> mOriginalURI;
  74. nsCOMPtr<nsISupports> mOwner;
  75. nsCOMPtr<nsILoadInfo> mLoadInfo;
  76. nsCOMPtr<nsIInterfaceRequestor> mCallbacks;
  77. nsCOMPtr<nsIProgressEventSink> mProgressSink;
  78. nsCOMPtr<nsILoadGroup> mLoadGroup;
  79. nsCOMPtr<nsIStreamListener> mListener;
  80. nsCOMPtr<nsISupports> mListenerContext;
  81. nsCOMPtr<nsISupports> mSecurityInfo;
  82. // FIXME: replace with IPDL states (bug 536319)
  83. enum WyciwygChannelChildState mState;
  84. bool mIPCOpen;
  85. bool mSentAppData;
  86. RefPtr<ChannelEventQueue> mEventQ;
  87. friend class WyciwygStartRequestEvent;
  88. friend class WyciwygDataAvailableEvent;
  89. friend class WyciwygStopRequestEvent;
  90. friend class WyciwygCancelEvent;
  91. };
  92. inline bool
  93. WyciwygChannelChild::IsSuspended()
  94. {
  95. return false;
  96. }
  97. } // namespace net
  98. } // namespace mozilla
  99. #endif // mozilla_net_WyciwygChannelChild_h