Bug 1521243 - Show a warning for invalid declarations and filter icon for overridden...
[gecko.git] / hal / WindowIdentifier.cpp
blob83c170508de52c5c3211d1a280abb216ac2b2c19
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"
12 namespace mozilla {
13 namespace hal {
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);
33 return mID;
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);
53 return mWindow;
56 } // namespace hal
57 } // namespace mozilla