tor-browser

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

PrecompiledScript.h (1868B)


      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 mozilla_dom_PrecompiledScript_h
      7 #define mozilla_dom_PrecompiledScript_h
      8 
      9 #include "mozilla/dom/BindingDeclarations.h"
     10 #include "mozilla/dom/PrecompiledScriptBinding.h"
     11 #include "mozilla/RefPtr.h"
     12 
     13 #include "js/experimental/JSStencil.h"
     14 #include "js/TypeDecls.h"
     15 
     16 #include "nsCOMPtr.h"
     17 #include "nsCycleCollectionParticipant.h"
     18 #include "nsISupports.h"
     19 #include "nsWrapperCache.h"
     20 
     21 namespace JS {
     22 class ReadOnlyCompileOptions;
     23 }
     24 
     25 namespace mozilla {
     26 namespace dom {
     27 class PrecompiledScript : public nsISupports, public nsWrapperCache {
     28  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     29  NS_DECL_CYCLE_COLLECTION_SKIPPABLE_WRAPPERCACHE_CLASS(PrecompiledScript)
     30 
     31  explicit PrecompiledScript(nsISupports* aParent, RefPtr<JS::Stencil> aStencil,
     32                             JS::ReadOnlyCompileOptions& aOptions);
     33 
     34  void ExecuteInGlobal(JSContext* aCx, JS::Handle<JSObject*> aGlobal,
     35                       const ExecuteInGlobalOptions& aOptions,
     36                       JS::MutableHandle<JS::Value> aRval, ErrorResult& aRv);
     37 
     38  void GetUrl(nsAString& aUrl);
     39 
     40  bool HasReturnValue();
     41 
     42  nsISupports* GetParentObject() const { return mParent; }
     43 
     44  virtual JSObject* WrapObject(JSContext* aCx,
     45                               JS::Handle<JSObject*> aGivenProto) override;
     46 
     47 protected:
     48  virtual ~PrecompiledScript() = default;
     49 
     50 private:
     51  bool IsBlackForCC(bool aTracingNeeded);
     52 
     53  nsCOMPtr<nsISupports> mParent;
     54 
     55  RefPtr<JS::Stencil> mStencil;
     56  nsCString mPublicURL;
     57  const bool mHasReturnValue;
     58 };
     59 
     60 }  // namespace dom
     61 }  // namespace mozilla
     62 
     63 #endif  // mozilla_dom_PrecompiledScript_h