tor-browser

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

FetchEventOpProxyParent.h (2650B)


      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/. */
      6 
      7 #ifndef mozilla_dom_fetcheventopproxyparent_h__
      8 #define mozilla_dom_fetcheventopproxyparent_h__
      9 
     10 #include "mozilla/RefPtr.h"
     11 #include "mozilla/dom/PFetchEventOpProxyParent.h"
     12 #include "mozilla/dom/ServiceWorkerOpPromise.h"
     13 
     14 namespace mozilla::dom {
     15 
     16 class FetchEventOpParent;
     17 class PRemoteWorkerParent;
     18 class ParentToParentServiceWorkerFetchEventOpArgs;
     19 
     20 /**
     21 * FetchEventOpProxyParent owns a FetchEventOpParent in order to propagate
     22 * the respondWith() value by directly calling SendRespondWith on the
     23 * FetchEventOpParent, but the call to Send__delete__ is handled via MozPromise.
     24 * This is done because this actor may only be created after its managing
     25 * PRemoteWorker is created, which is asynchronous and may fail.  We take on
     26 * responsibility for the promise once we are created, but we may not be created
     27 * if the RemoteWorker is never successfully launched.
     28 */
     29 class FetchEventOpProxyParent final : public PFetchEventOpProxyParent {
     30  friend class PFetchEventOpProxyParent;
     31 
     32 public:
     33  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(FetchEventOpProxyParent, override);
     34 
     35  static void Create(
     36      PRemoteWorkerParent* aManager,
     37      RefPtr<ServiceWorkerFetchEventOpPromise::Private>&& aPromise,
     38      const ParentToParentServiceWorkerFetchEventOpArgs& aArgs,
     39      RefPtr<FetchEventOpParent> aReal, nsCOMPtr<nsIInputStream> aBodyStream);
     40 
     41 private:
     42  FetchEventOpProxyParent(
     43      RefPtr<FetchEventOpParent>&& aReal,
     44      RefPtr<ServiceWorkerFetchEventOpPromise::Private>&& aPromise);
     45 
     46  ~FetchEventOpProxyParent();
     47 
     48  mozilla::ipc::IPCResult RecvAsyncLog(const nsCString& aScriptSpec,
     49                                       const uint32_t& aLineNumber,
     50                                       const uint32_t& aColumnNumber,
     51                                       const nsCString& aMessageName,
     52                                       nsTArray<nsString>&& aParams);
     53 
     54  mozilla::ipc::IPCResult RecvRespondWith(
     55      const ChildToParentFetchEventRespondWithResult& aResult);
     56 
     57  mozilla::ipc::IPCResult Recv__delete__(
     58      const ServiceWorkerFetchEventOpResult& aResult);
     59 
     60  void ActorDestroy(ActorDestroyReason) override;
     61 
     62  RefPtr<FetchEventOpParent> mReal;
     63  RefPtr<ServiceWorkerFetchEventOpPromise::Private> mLifetimePromise;
     64 };
     65 
     66 }  // namespace mozilla::dom
     67 
     68 #endif  // mozilla_dom_fetcheventopproxyparent_h__