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 {
|
|
|
|
|
|
|
|
WindowIdentifier::WindowIdentifier() : mWindow(nullptr), mIsEmpty(true) {}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
WindowIdentifier::WindowIdentifier(nsPIDOMWindowInner* window)
|
2011-12-18 01:04:26 +04:00
|
|
|
: mWindow(window), mIsEmpty(false) {
|
|
|
|
mID.AppendElement(GetWindowID());
|
|
|
|
}
|
|
|
|
|
2016-01-30 20:05:36 +03:00
|
|
|
WindowIdentifier::WindowIdentifier(const InfallibleTArray<uint64_t>& id,
|
|
|
|
nsPIDOMWindowInner* window)
|
2011-12-18 01:04:26 +04:00
|
|
|
: mID(id), mWindow(window), mIsEmpty(false) {
|
|
|
|
mID.AppendElement(GetWindowID());
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowIdentifier::WindowIdentifier(const WindowIdentifier& other)
|
|
|
|
: mID(other.mID), mWindow(other.mWindow), mIsEmpty(other.mIsEmpty) {}
|
|
|
|
|
|
|
|
const InfallibleTArray<uint64_t>& WindowIdentifier::AsArray() const {
|
|
|
|
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
|