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 "mozilla/dom/ContentChild.h"
8 #include "WindowIdentifier.h"
9 #include "nsPIDOMWindow.h"
14 WindowIdentifier::WindowIdentifier()
20 WindowIdentifier::WindowIdentifier(nsIDOMWindow
*window
)
24 mID
.AppendElement(GetWindowID());
27 WindowIdentifier::WindowIdentifier(const InfallibleTArray
<uint64_t> &id
, nsIDOMWindow
*window
)
32 mID
.AppendElement(GetWindowID());
35 WindowIdentifier::WindowIdentifier(const WindowIdentifier
&other
)
37 , mWindow(other
.mWindow
)
38 , mIsEmpty(other
.mIsEmpty
)
42 const InfallibleTArray
<uint64_t>&
43 WindowIdentifier::AsArray() const
45 MOZ_ASSERT(!mIsEmpty
);
50 WindowIdentifier::HasTraveledThroughIPC() const
52 MOZ_ASSERT(!mIsEmpty
);
53 return mID
.Length() >= 2;
57 WindowIdentifier::AppendProcessID()
59 MOZ_ASSERT(!mIsEmpty
);
60 mID
.AppendElement(dom::ContentChild::GetSingleton()->GetID());
64 WindowIdentifier::GetWindowID() const
66 MOZ_ASSERT(!mIsEmpty
);
67 nsCOMPtr
<nsPIDOMWindow
> pidomWindow
= do_QueryInterface(mWindow
);
71 return pidomWindow
->WindowID();
75 WindowIdentifier::GetWindow() const
77 MOZ_ASSERT(!mIsEmpty
);
82 } // namespace mozilla