author Ciure Andrei <>
Sat, 26 Jan 2019 14:58:54 +0200
changeset 515553 7ea32bdfebf13efa1c11d817eb73f7a4d2654c36
parent 515523 1e68675bce75e958c4d6a7f14a021cbd914b2a9c
child 516562 e8f9d3cdb231f0ef1dd9aec131fea1f3193a7a56
permissions -rw-r--r--
Backed out changeset 1e68675bce75 (bug 1521189) for causing browser_dbg_rr_breakpoints-01.js to perma fail a=backout

/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */
/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */
/* 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 */

#ifndef mozilla_dom_WindowGlobalChild_h
#define mozilla_dom_WindowGlobalChild_h

#include "mozilla/RefPtr.h"
#include "mozilla/dom/PWindowGlobalChild.h"
#include "nsWrapperCache.h"

class nsGlobalWindowInner;
class nsDocShell;

namespace mozilla {
namespace dom {

class BrowsingContext;
class WindowGlobalParent;

 * Actor for a single nsGlobalWindowInner. This actor is used to communicate
 * information to the parent process asynchronously.
class WindowGlobalChild : public nsWrapperCache, public PWindowGlobalChild {

  static already_AddRefed<WindowGlobalChild> GetByInnerWindowId(
      uint64_t aInnerWindowId);

  static already_AddRefed<WindowGlobalChild> GetByInnerWindowId(
      const GlobalObject& aGlobal, uint64_t aInnerWindowId) {
    return GetByInnerWindowId(aInnerWindowId);

  dom::BrowsingContext* BrowsingContext() { return mBrowsingContext; }
  nsGlobalWindowInner* WindowGlobal() { return mWindowGlobal; }

  // Has this actor been shut down
  bool IsClosed() { return mIPCClosed; }

  // Check if this actor is managed by PInProcess, as-in the document is loaded
  // in the chrome process.
  bool IsInProcess() { return XRE_IsParentProcess(); }

  // The Window ID for this WindowGlobal
  uint64_t InnerWindowId() { return mInnerWindowId; }
  uint64_t OuterWindowId() { return mOuterWindowId; }

  bool IsCurrentGlobal();

  // Get the other side of this actor if it is an in-process actor. Returns
  // |nullptr| if the actor has been torn down, or is not in-process.
  already_AddRefed<WindowGlobalParent> GetParentActor();

  // Create and initialize the WindowGlobalChild object.
  static already_AddRefed<WindowGlobalChild> Create(
      nsGlobalWindowInner* aWindow);

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

  virtual void ActorDestroy(ActorDestroyReason aWhy) override;

  WindowGlobalChild(nsGlobalWindowInner* aWindow, dom::BrowsingContext* aBc);

  RefPtr<nsGlobalWindowInner> mWindowGlobal;
  RefPtr<dom::BrowsingContext> mBrowsingContext;
  uint64_t mInnerWindowId;
  uint64_t mOuterWindowId;
  bool mIPCClosed;

}  // namespace dom
}  // namespace mozilla

#endif  // !defined(mozilla_dom_WindowGlobalChild_h)