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 "mozilla/dom/ContentChild.h"
|
|
|
|
#include "WindowIdentifier.h"
|
|
|
|
#include "nsPIDOMWindow.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace hal {
|
|
|
|
|
|
|
|
WindowIdentifier::WindowIdentifier()
|
2012-07-30 18:20:58 +04:00
|
|
|
: mWindow(nullptr)
|
2011-12-18 01:04:26 +04:00
|
|
|
, mIsEmpty(true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
WindowIdentifier::WindowIdentifier(nsIDOMWindow *window)
|
|
|
|
: mWindow(window)
|
|
|
|
, mIsEmpty(false)
|
|
|
|
{
|
|
|
|
mID.AppendElement(GetWindowID());
|
|
|
|
}
|
|
|
|
|
2012-11-29 20:14:14 +04:00
|
|
|
WindowIdentifier::WindowIdentifier(const InfallibleTArray<uint64_t> &id, nsIDOMWindow *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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-05-25 11:18:30 +04:00
|
|
|
const InfallibleTArray<uint64_t>&
|
2011-12-18 01:04:26 +04:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
|
2012-05-25 11:18:30 +04:00
|
|
|
uint64_t
|
2011-12-18 01:04:26 +04:00
|
|
|
WindowIdentifier::GetWindowID() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsEmpty);
|
|
|
|
nsCOMPtr<nsPIDOMWindow> pidomWindow = do_QueryInterface(mWindow);
|
|
|
|
if (!pidomWindow) {
|
2012-05-25 11:18:30 +04:00
|
|
|
return UINT64_MAX;
|
2011-12-18 01:04:26 +04:00
|
|
|
}
|
|
|
|
return pidomWindow->WindowID();
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIDOMWindow*
|
|
|
|
WindowIdentifier::GetWindow() const
|
|
|
|
{
|
|
|
|
MOZ_ASSERT(!mIsEmpty);
|
|
|
|
return mWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace hal
|
|
|
|
} // namespace mozilla
|