2018-08-30 01:21:25 +03:00
|
|
|
/* -*- 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 http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
#ifndef mozilla_dom_WindowGlobalChild_h
|
|
|
|
#define mozilla_dom_WindowGlobalChild_h
|
|
|
|
|
|
|
|
#include "mozilla/RefPtr.h"
|
|
|
|
#include "mozilla/dom/PWindowGlobalChild.h"
|
2018-10-20 02:02:56 +03:00
|
|
|
#include "nsWrapperCache.h"
|
2018-08-30 01:21:25 +03:00
|
|
|
|
|
|
|
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.
|
|
|
|
*/
|
2018-10-20 02:02:56 +03:00
|
|
|
class WindowGlobalChild : public nsWrapperCache, public PWindowGlobalChild {
|
2018-08-30 01:21:25 +03:00
|
|
|
public:
|
|
|
|
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalChild)
|
2018-10-20 02:02:56 +03:00
|
|
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WindowGlobalChild)
|
2018-08-30 01:21:25 +03:00
|
|
|
|
2018-10-20 23:04:00 +03:00
|
|
|
static already_AddRefed<WindowGlobalChild> GetByInnerWindowId(
|
|
|
|
uint64_t aInnerWindowId);
|
|
|
|
|
|
|
|
static already_AddRefed<WindowGlobalChild> GetByInnerWindowId(
|
|
|
|
const GlobalObject& aGlobal, uint64_t aInnerWindowId) {
|
|
|
|
return GetByInnerWindowId(aInnerWindowId);
|
|
|
|
}
|
|
|
|
|
2018-08-30 01:21:25 +03:00
|
|
|
dom::BrowsingContext* BrowsingContext() { return mBrowsingContext; }
|
|
|
|
nsGlobalWindowInner* WindowGlobal() { return mWindowGlobal; }
|
|
|
|
|
|
|
|
// Has this actor been shut down
|
|
|
|
bool IsClosed() { return mIPCClosed; }
|
2019-01-28 21:09:13 +03:00
|
|
|
void Destroy();
|
2018-08-30 01:21:25 +03:00
|
|
|
|
|
|
|
// Check if this actor is managed by PInProcess, as-in the document is loaded
|
|
|
|
// in the chrome process.
|
|
|
|
bool IsInProcess() { return XRE_IsParentProcess(); }
|
|
|
|
|
2018-10-20 23:04:00 +03:00
|
|
|
// The Window ID for this WindowGlobal
|
|
|
|
uint64_t InnerWindowId() { return mInnerWindowId; }
|
|
|
|
uint64_t OuterWindowId() { return mOuterWindowId; }
|
|
|
|
|
2018-11-27 23:03:05 +03:00
|
|
|
bool IsCurrentGlobal();
|
|
|
|
|
2018-08-30 01:21:25 +03:00
|
|
|
// 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.
|
2018-10-20 02:02:56 +03:00
|
|
|
already_AddRefed<WindowGlobalParent> GetParentActor();
|
2018-08-30 01:21:25 +03:00
|
|
|
|
2019-01-28 21:09:13 +03:00
|
|
|
// Get this actor's manager if it is not an in-process actor. Returns
|
|
|
|
// |nullptr| if the actor has been torn down, or is in-process.
|
|
|
|
already_AddRefed<TabChild> GetTabChild();
|
|
|
|
|
2018-08-30 01:21:25 +03:00
|
|
|
// Create and initialize the WindowGlobalChild object.
|
|
|
|
static already_AddRefed<WindowGlobalChild> Create(
|
|
|
|
nsGlobalWindowInner* aWindow);
|
|
|
|
|
2018-10-20 02:02:56 +03:00
|
|
|
nsISupports* GetParentObject();
|
|
|
|
JSObject* WrapObject(JSContext* aCx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) override;
|
|
|
|
|
2018-08-30 01:21:25 +03:00
|
|
|
protected:
|
|
|
|
virtual void ActorDestroy(ActorDestroyReason aWhy) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
WindowGlobalChild(nsGlobalWindowInner* aWindow, dom::BrowsingContext* aBc);
|
|
|
|
~WindowGlobalChild();
|
|
|
|
|
|
|
|
RefPtr<nsGlobalWindowInner> mWindowGlobal;
|
|
|
|
RefPtr<dom::BrowsingContext> mBrowsingContext;
|
2018-10-20 23:04:00 +03:00
|
|
|
uint64_t mInnerWindowId;
|
|
|
|
uint64_t mOuterWindowId;
|
2018-08-30 01:21:25 +03:00
|
|
|
bool mIPCClosed;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|
|
|
|
|
|
|
|
#endif // !defined(mozilla_dom_WindowGlobalChild_h)
|