Bumping manifests a=b2g-bump
[gecko.git] / hal / WindowIdentifier.cpp
blobef262400314bc92f703eed733c083e7cd5268f73
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"
11 namespace mozilla {
12 namespace hal {
14 WindowIdentifier::WindowIdentifier()
15 : mWindow(nullptr)
16 , mIsEmpty(true)
20 WindowIdentifier::WindowIdentifier(nsIDOMWindow *window)
21 : mWindow(window)
22 , mIsEmpty(false)
24 mID.AppendElement(GetWindowID());
27 WindowIdentifier::WindowIdentifier(const InfallibleTArray<uint64_t> &id, nsIDOMWindow *window)
28 : mID(id)
29 , mWindow(window)
30 , mIsEmpty(false)
32 mID.AppendElement(GetWindowID());
35 WindowIdentifier::WindowIdentifier(const WindowIdentifier &other)
36 : mID(other.mID)
37 , mWindow(other.mWindow)
38 , mIsEmpty(other.mIsEmpty)
42 const InfallibleTArray<uint64_t>&
43 WindowIdentifier::AsArray() const
45 MOZ_ASSERT(!mIsEmpty);
46 return mID;
49 bool
50 WindowIdentifier::HasTraveledThroughIPC() const
52 MOZ_ASSERT(!mIsEmpty);
53 return mID.Length() >= 2;
56 void
57 WindowIdentifier::AppendProcessID()
59 MOZ_ASSERT(!mIsEmpty);
60 mID.AppendElement(dom::ContentChild::GetSingleton()->GetID());
63 uint64_t
64 WindowIdentifier::GetWindowID() const
66 MOZ_ASSERT(!mIsEmpty);
67 nsCOMPtr<nsPIDOMWindow> pidomWindow = do_QueryInterface(mWindow);
68 if (!pidomWindow) {
69 return UINT64_MAX;
71 return pidomWindow->WindowID();
74 nsIDOMWindow*
75 WindowIdentifier::GetWindow() const
77 MOZ_ASSERT(!mIsEmpty);
78 return mWindow;
81 } // namespace hal
82 } // namespace mozilla