tor-browser

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

FetchChild.h (3149B)


      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 
      5 #ifndef mozilla_dom_fetchChild_h__
      6 #define mozilla_dom_fetchChild_h__
      7 
      8 #include "mozilla/dom/AbortFollower.h"
      9 #include "mozilla/dom/AbortSignal.h"
     10 #include "mozilla/dom/FlippedOnce.h"
     11 #include "mozilla/dom/PFetchChild.h"
     12 #include "mozilla/dom/SerializedStackHolder.h"
     13 #include "nsIConsoleReportCollector.h"
     14 #include "nsISupports.h"
     15 #include "nsIWorkerChannelInfo.h"
     16 
     17 namespace mozilla::dom {
     18 
     19 class FetchObserver;
     20 class ThreadSafeWorkerRef;
     21 class Promise;
     22 class WorkerPrivate;
     23 
     24 class FetchChild final : public PFetchChild, public AbortFollower {
     25  friend class PFetchChild;
     26 
     27 public:
     28  NS_DECL_THREADSAFE_ISUPPORTS
     29 
     30  mozilla::ipc::IPCResult Recv__delete__(const nsresult&& aResult);
     31 
     32  mozilla::ipc::IPCResult RecvOnResponseAvailableInternal(
     33      ParentToChildInternalResponse&& aResponse);
     34 
     35  mozilla::ipc::IPCResult RecvOnResponseEnd(ResponseEndArgs&& aArgs);
     36 
     37  mozilla::ipc::IPCResult RecvOnDataAvailable();
     38 
     39  mozilla::ipc::IPCResult RecvOnFlushConsoleReport(
     40      nsTArray<net::ConsoleReportCollected>&& aReports);
     41 
     42  mozilla::ipc::IPCResult RecvOnCSPViolationEvent(const nsAString& aJSon);
     43 
     44  mozilla::ipc::IPCResult RecvOnReportPerformanceTiming(
     45      ResponseTiming&& aTiming);
     46 
     47  mozilla::ipc::IPCResult RecvOnNotifyNetworkMonitorAlternateStack(
     48      uint64_t aChannelID);
     49 
     50  void SetCSPEventListener(nsICSPEventListener* aListener);
     51 
     52  // Creates the actor for worker fetch requests
     53  static RefPtr<FetchChild> CreateForWorker(WorkerPrivate* aWorkerPrivate,
     54                                            RefPtr<Promise> aPromise,
     55                                            RefPtr<AbortSignalImpl> aSignalImpl,
     56                                            RefPtr<FetchObserver> aObserver);
     57 
     58  // Creates the actor for main thread fetch requests
     59  static RefPtr<FetchChild> CreateForMainThread(
     60      RefPtr<Promise> aPromise, RefPtr<AbortSignalImpl> aSignalImpl,
     61      RefPtr<FetchObserver> aObserver);
     62 
     63  FetchChild(RefPtr<Promise>&& aPromise, RefPtr<AbortSignalImpl>&& aSignalImpl,
     64             RefPtr<FetchObserver>&& aObserver);
     65 
     66  // AbortFollower
     67  void RunAbortAlgorithm() override;
     68 
     69  void DoFetchOp(const FetchOpArgs& aArgs);
     70 
     71  void SetOriginStack(UniquePtr<SerializedStackHolder>&& aStack) {
     72    MOZ_ASSERT(!mOriginStack);
     73    mOriginStack = std::move(aStack);
     74  }
     75 
     76 private:
     77  ~FetchChild() = default;
     78 
     79  // WorkerPrivate shutdown callback.
     80  void Shutdown();
     81  void ActorDestroy(ActorDestroyReason aReason) override;
     82 
     83  RefPtr<ThreadSafeWorkerRef> mWorkerRef;
     84  bool mIsKeepAliveRequest{false};
     85  uint64_t mKeepaliveRequestSize{0};
     86  RefPtr<Promise> mPromise;
     87  RefPtr<AbortSignalImpl> mSignalImpl;
     88  RefPtr<FetchObserver> mFetchObserver;
     89  UniquePtr<SerializedStackHolder> mOriginStack;
     90  nsCOMPtr<nsICSPEventListener> mCSPEventListener;
     91  nsCOMPtr<nsIConsoleReportCollector> mReporter;
     92  FlippedOnce<false> mIsShutdown;
     93  nsCOMPtr<nsIWorkerChannelInfo> mWorkerChannelInfo;
     94 };
     95 
     96 }  // namespace mozilla::dom
     97 
     98 #endif