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()
24 WindowIdentifier::WindowIdentifier(nsPIDOMWindowInner
* window
)
26 mID
.AppendElement(GetWindowID());
29 WindowIdentifier::WindowIdentifier(nsTArray
<uint64_t>&& id
,
30 nsPIDOMWindowInner
* window
)
31 : mID(std::move(id
)), mWindow(window
) {
32 mID
.AppendElement(GetWindowID());
35 const nsTArray
<uint64_t>& WindowIdentifier::AsArray() const {
36 MOZ_ASSERT(!mIsEmpty
);
40 bool WindowIdentifier::HasTraveledThroughIPC() const {
41 MOZ_ASSERT(!mIsEmpty
);
42 return mID
.Length() >= 2;
45 void WindowIdentifier::AppendProcessID() {
46 MOZ_ASSERT(!mIsEmpty
);
47 mID
.AppendElement(dom::ContentChild::GetSingleton()->GetID());
50 uint64_t WindowIdentifier::GetWindowID() const {
51 MOZ_ASSERT(!mIsEmpty
);
52 return mWindow
? mWindow
->WindowID() : UINT64_MAX
;
55 nsPIDOMWindowInner
* WindowIdentifier::GetWindow() const {
56 MOZ_ASSERT(!mIsEmpty
);
61 } // namespace mozilla