dom/worklet/WorkletGlobalScope.h
author Siddhant085 <dpsrkp.sid@gmail.com>
Wed, 28 Nov 2018 15:21:11 +0000
changeset 507746 74d97073c54b19e742b084ea9f03b7ba40233000
parent 503073 10d4bab0bccbc6faf6f909a537a9780db7c4edf9
child 507901 32d5c8f3ca7f0eabefabd489d50d47e084d98f2a
permissions -rw-r--r--
Bug 1453264 - Dropping nsIBrowserSearchService::currentEngine in favour of defaultEngine. r=Standard8 All instances of nsIBrowserSearchService::currentEngine have been replaced by nsIBrowserSearchService::defaultEngine. Dropping this variable now. Differential Revision: https://phabricator.services.mozilla.com/D12223

/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_dom_WorkletGlobalScope_h
#define mozilla_dom_WorkletGlobalScope_h

#include "mozilla/Attributes.h"
#include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h"
#include "nsIGlobalObject.h"
#include "nsWrapperCache.h"

#define WORKLET_IID \
  { 0x1b3f62e7, 0xe357, 0x44be, \
    { 0xbf, 0xe0, 0xdf, 0x85, 0xe6, 0x56, 0x85, 0xac } }

namespace mozilla {

class WorkletImpl;

namespace dom {

class Console;

class WorkletGlobalScope : public nsIGlobalObject
                         , public nsWrapperCache
{
public:
  NS_DECLARE_STATIC_IID_ACCESSOR(WORKLET_IID)

  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(WorkletGlobalScope)

  WorkletGlobalScope();

  nsIGlobalObject* GetParentObject() const
  {
    return nullptr;
  }

  virtual JSObject*
  WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;

  virtual bool
  WrapGlobalObject(JSContext* aCx, JS::MutableHandle<JSObject*> aReflector) = 0;

  virtual JSObject*
  GetGlobalJSObject() override
  {
    return GetWrapper();
  }

  already_AddRefed<Console>
  GetConsole(JSContext* aCx, ErrorResult& aRv);

  virtual WorkletImpl* Impl() const = 0;

  void
  Dump(const Optional<nsAString>& aString) const;

protected:
  ~WorkletGlobalScope();;

private:
  RefPtr<Console> mConsole;
};

NS_DEFINE_STATIC_IID_ACCESSOR(WorkletGlobalScope, WORKLET_IID)

} // namespace dom
} // namespace mozilla

#endif // mozilla_dom_WorkletGlobalScope_h