tor-browser

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

JSValidatorChild.h (2055B)


      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_JSValidatorChild
      8 #define mozilla_dom_JSValidatorChild
      9 
     10 #include "mozilla/ProcInfo.h"
     11 #include "mozilla/Result.h"
     12 #include "mozilla/dom/JSValidatorUtils.h"
     13 #include "mozilla/dom/PJSValidatorChild.h"
     14 #include "mozilla/net/OpaqueResponseUtils.h"
     15 
     16 template <typename T>
     17 using BufferUniquePtr = mozilla::UniquePtr<T, JS::FreePolicy>;
     18 
     19 namespace mozilla {
     20 class Decoder;
     21 }  // namespace mozilla
     22 
     23 namespace mozilla::dom {
     24 class JSValidatorChild final : public PJSValidatorChild {
     25 public:
     26  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(JSValidatorChild, override);
     27 
     28  mozilla::ipc::IPCResult RecvIsOpaqueResponseAllowed(
     29      IsOpaqueResponseAllowedResolver&& aResolver);
     30 
     31  mozilla::ipc::IPCResult RecvOnDataAvailable(Shmem&& aData);
     32 
     33  mozilla::ipc::IPCResult RecvOnStopRequest(const nsresult& aReason,
     34                                            const nsACString& aContentCharset,
     35                                            const nsAString& aHintCharset,
     36                                            const nsAString& aDocumentCharset);
     37 
     38  void ActorDestroy(ActorDestroyReason aReason) override;
     39 
     40 private:
     41  virtual ~JSValidatorChild() = default;
     42 
     43  using ValidatorResult = net::OpaqueResponseBlocker::ValidatorResult;
     44  void Resolve(ValidatorResult aResult);
     45  ValidatorResult ShouldAllowJS(const mozilla::Span<const char>& aSpan) const;
     46 
     47  mozilla::Result<mozilla::Span<const char>, nsresult> GetUTF8EncodedContent(
     48      const mozilla::Span<const uint8_t>& aData,
     49      BufferUniquePtr<Utf8Unit[]>& aBuffer,
     50      UniquePtr<mozilla::Decoder>& aDecoder);
     51 
     52  nsCString mSourceBytes;
     53  Maybe<IsOpaqueResponseAllowedResolver> mResolver;
     54 };
     55 }  // namespace mozilla::dom
     56 
     57 #endif  // defined(mozilla_dom_JSValidatorChild)