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