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()
21 WindowIdentifier::WindowIdentifier(nsPIDOMWindowInner
* window
)
25 mID
.AppendElement(GetWindowID());
28 WindowIdentifier::WindowIdentifier(const InfallibleTArray
<uint64_t> &id
,
29 nsPIDOMWindowInner
* window
)
34 mID
.AppendElement(GetWindowID());
37 WindowIdentifier::WindowIdentifier(const WindowIdentifier
&other
)
39 , mWindow(other
.mWindow
)
40 , mIsEmpty(other
.mIsEmpty
)
44 const InfallibleTArray
<uint64_t>&
45 WindowIdentifier::AsArray() const
47 MOZ_ASSERT(!mIsEmpty
);
52 WindowIdentifier::HasTraveledThroughIPC() const
54 MOZ_ASSERT(!mIsEmpty
);
55 return mID
.Length() >= 2;
59 WindowIdentifier::AppendProcessID()
61 MOZ_ASSERT(!mIsEmpty
);
62 mID
.AppendElement(dom::ContentChild::GetSingleton()->GetID());
66 WindowIdentifier::GetWindowID() const
68 MOZ_ASSERT(!mIsEmpty
);
69 return mWindow
? mWindow
->WindowID() : UINT64_MAX
;
73 WindowIdentifier::GetWindow() const
75 MOZ_ASSERT(!mIsEmpty
);
80 } // namespace mozilla