1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et ft=cpp : */
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/. */
7 #include "WindowIdentifier.h"
9 #include "mozilla/dom/ContentChild.h"
10 #include "nsPIDOMWindow.h"
15 WindowIdentifier::WindowIdentifier() : mWindow(nullptr), mIsEmpty(true) {}
17 WindowIdentifier::WindowIdentifier(nsPIDOMWindowInner
* window
)
18 : mWindow(window
), mIsEmpty(false) {
19 mID
.AppendElement(GetWindowID());
22 WindowIdentifier::WindowIdentifier(const InfallibleTArray
<uint64_t>& id
,
23 nsPIDOMWindowInner
* window
)
24 : mID(id
), mWindow(window
), mIsEmpty(false) {
25 mID
.AppendElement(GetWindowID());
28 WindowIdentifier::WindowIdentifier(const WindowIdentifier
& other
)
29 : mID(other
.mID
), mWindow(other
.mWindow
), mIsEmpty(other
.mIsEmpty
) {}
31 const InfallibleTArray
<uint64_t>& WindowIdentifier::AsArray() const {
32 MOZ_ASSERT(!mIsEmpty
);
36 bool WindowIdentifier::HasTraveledThroughIPC() const {
37 MOZ_ASSERT(!mIsEmpty
);
38 return mID
.Length() >= 2;
41 void WindowIdentifier::AppendProcessID() {
42 MOZ_ASSERT(!mIsEmpty
);
43 mID
.AppendElement(dom::ContentChild::GetSingleton()->GetID());
46 uint64_t WindowIdentifier::GetWindowID() const {
47 MOZ_ASSERT(!mIsEmpty
);
48 return mWindow
? mWindow
->WindowID() : UINT64_MAX
;
51 nsPIDOMWindowInner
* WindowIdentifier::GetWindow() const {
52 MOZ_ASSERT(!mIsEmpty
);
57 } // namespace mozilla