tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

nsStreamLoader.h (1654B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this
      4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef nsStreamLoader_h__
      7 #define nsStreamLoader_h__
      8 
      9 #include "nsIThreadRetargetableStreamListener.h"
     10 #include "nsIStreamLoader.h"
     11 #include "nsCOMPtr.h"
     12 #include "mozilla/Atomics.h"
     13 #include "mozilla/Vector.h"
     14 
     15 class nsIRequest;
     16 
     17 namespace mozilla {
     18 namespace net {
     19 
     20 class nsStreamLoader final : public nsIStreamLoader {
     21 public:
     22  NS_DECL_THREADSAFE_ISUPPORTS
     23  NS_DECL_NSISTREAMLOADER
     24  NS_DECL_NSIREQUESTOBSERVER
     25  NS_DECL_NSISTREAMLISTENER
     26  NS_DECL_NSITHREADRETARGETABLESTREAMLISTENER
     27 
     28  nsStreamLoader();
     29 
     30  static nsresult Create(REFNSIID aIID, void** aResult);
     31 
     32 protected:
     33  ~nsStreamLoader() = default;
     34 
     35  static nsresult WriteSegmentFun(nsIInputStream*, void*, const char*, uint32_t,
     36                                  uint32_t, uint32_t*);
     37 
     38  // Utility method to free mData, if present, and update other state to
     39  // reflect that no data has been allocated.
     40  void ReleaseData();
     41 
     42  nsCOMPtr<nsIStreamLoaderObserver> mObserver;
     43  nsCOMPtr<nsISupports> mContext;  // the observer's context
     44  nsCOMPtr<nsIRequest> mRequest;
     45  nsCOMPtr<nsIRequestObserver> mRequestObserver;
     46 
     47  mozilla::Atomic<uint32_t, mozilla::MemoryOrdering::Relaxed> mBytesRead;
     48 
     49  // Buffer to accumulate incoming data. We preallocate if contentSize is
     50  // available.
     51  mozilla::Vector<uint8_t, 0> mData;
     52 };
     53 
     54 }  // namespace net
     55 }  // namespace mozilla
     56 
     57 #endif  // nsStreamLoader_h__