/src/mozilla-central/hal/WindowIdentifier.cpp
Line | Count | Source (jump to first uncovered line) |
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/. */ |
6 | | |
7 | | #include "WindowIdentifier.h" |
8 | | |
9 | | #include "mozilla/dom/ContentChild.h" |
10 | | #include "nsPIDOMWindow.h" |
11 | | |
12 | | namespace mozilla { |
13 | | namespace hal { |
14 | | |
15 | | WindowIdentifier::WindowIdentifier() |
16 | | : mWindow(nullptr) |
17 | | , mIsEmpty(true) |
18 | 0 | { |
19 | 0 | } |
20 | | |
21 | | WindowIdentifier::WindowIdentifier(nsPIDOMWindowInner* window) |
22 | | : mWindow(window) |
23 | | , mIsEmpty(false) |
24 | 0 | { |
25 | 0 | mID.AppendElement(GetWindowID()); |
26 | 0 | } |
27 | | |
28 | | WindowIdentifier::WindowIdentifier(const InfallibleTArray<uint64_t> &id, |
29 | | nsPIDOMWindowInner* window) |
30 | | : mID(id) |
31 | | , mWindow(window) |
32 | | , mIsEmpty(false) |
33 | 0 | { |
34 | 0 | mID.AppendElement(GetWindowID()); |
35 | 0 | } |
36 | | |
37 | | WindowIdentifier::WindowIdentifier(const WindowIdentifier &other) |
38 | | : mID(other.mID) |
39 | | , mWindow(other.mWindow) |
40 | | , mIsEmpty(other.mIsEmpty) |
41 | 0 | { |
42 | 0 | } |
43 | | |
44 | | const InfallibleTArray<uint64_t>& |
45 | | WindowIdentifier::AsArray() const |
46 | 0 | { |
47 | 0 | MOZ_ASSERT(!mIsEmpty); |
48 | 0 | return mID; |
49 | 0 | } |
50 | | |
51 | | bool |
52 | | WindowIdentifier::HasTraveledThroughIPC() const |
53 | 0 | { |
54 | 0 | MOZ_ASSERT(!mIsEmpty); |
55 | 0 | return mID.Length() >= 2; |
56 | 0 | } |
57 | | |
58 | | void |
59 | | WindowIdentifier::AppendProcessID() |
60 | 0 | { |
61 | 0 | MOZ_ASSERT(!mIsEmpty); |
62 | 0 | mID.AppendElement(dom::ContentChild::GetSingleton()->GetID()); |
63 | 0 | } |
64 | | |
65 | | uint64_t |
66 | | WindowIdentifier::GetWindowID() const |
67 | 0 | { |
68 | 0 | MOZ_ASSERT(!mIsEmpty); |
69 | 0 | return mWindow ? mWindow->WindowID() : UINT64_MAX; |
70 | 0 | } |
71 | | |
72 | | nsPIDOMWindowInner* |
73 | | WindowIdentifier::GetWindow() const |
74 | 0 | { |
75 | 0 | MOZ_ASSERT(!mIsEmpty); |
76 | 0 | return mWindow; |
77 | 0 | } |
78 | | |
79 | | } // namespace hal |
80 | | } // namespace mozilla |