2011-12-18 01:04:26 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set sw=2 ts=8 et ft=cpp : */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
2011-12-18 01:04:26 +04:00
|
|
|
|
|
|
|
#include "WindowIdentifier.h"
|
2016-02-15 09:33:00 +03:00
|
|
|
|
|
|
|
#include "mozilla/dom/ContentChild.h"
|
2011-12-18 01:04:26 +04:00
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace hal {
|
|
|
|
|
2020-05-05 13:14:24 +03:00
|
|
|
WindowIdentifier::WindowIdentifier()
|
|
|
|
: mWindow(nullptr)
|
|
|
|
#ifdef DEBUG
|
|
|
|
,
|
|
|
|
mIsEmpty(true)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
}
|
2011-12-18 01:04:26 +04:00
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
WindowIdentifier::WindowIdentifier(nsPIDOMWindowInner* window)
|
2020-05-05 13:14:24 +03:00
|
|
|
: mWindow(window) {
|
2011-12-18 01:04:26 +04:00
|
|
|
mID.AppendElement(GetWindowID());
|
|
|
|
}
|
|
|
|
|
2020-05-05 13:14:24 +03:00
|
|
|
WindowIdentifier::WindowIdentifier(nsTArray<uint64_t>&& id,
|
2016-01-30 20:05:36 +03:00
|
|
|
nsPIDOMWindowInner* window)
|
2020-05-05 13:14:24 +03:00
|
|
|
: mID(std::move(id)), mWindow(window) {
|
2011-12-18 01:04:26 +04:00
|
|
|
mID.AppendElement(GetWindowID());
|
|
|
|
}
|
|
|
|
|
2019-07-10 06:30:52 +03:00
|
|
|
const nsTArray<uint64_t>& WindowIdentifier::AsArray() const {
|
2011-12-18 01:04:26 +04:00
|
|
|
MOZ_ASSERT(!mIsEmpty);
|
|
|
|
return mID;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WindowIdentifier::HasTraveledThroughIPC() const {
|
|
|
|
MOZ_ASSERT(!mIsEmpty);
|
|
|
|
return mID.Length() >= 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowIdentifier::AppendProcessID() {
|
|
|
|
MOZ_ASSERT(!mIsEmpty);
|
|
|
|
mID.AppendElement(dom::ContentChild::GetSingleton()->GetID());
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t WindowIdentifier::GetWindowID() const {
|
|
|
|
MOZ_ASSERT(!mIsEmpty);
|
2016-01-30 20:05:36 +03:00
|
|
|
return mWindow ? mWindow->WindowID() : UINT64_MAX;
|
2011-12-18 01:04:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsPIDOMWindowInner* WindowIdentifier::GetWindow() const {
|
|
|
|
MOZ_ASSERT(!mIsEmpty);
|
|
|
|
return mWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace hal
|
|
|
|
} // namespace mozilla
|