/work/obj-fuzz/dist/include/mozilla/dom/ClientState.h
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 ts=8 sts=2 et sw=2 tw=80: */ |
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 | | #ifndef _mozilla_dom_ClientState_h |
8 | | #define _mozilla_dom_ClientState_h |
9 | | |
10 | | #include "mozilla/dom/DocumentBinding.h" |
11 | | #include "mozilla/Maybe.h" |
12 | | #include "mozilla/TimeStamp.h" |
13 | | #include "mozilla/UniquePtr.h" |
14 | | #include "nsContentUtils.h" |
15 | | |
16 | | namespace mozilla { |
17 | | namespace dom { |
18 | | |
19 | | class IPCClientState; |
20 | | class IPCClientWindowState; |
21 | | class IPCClientWorkerState; |
22 | | |
23 | | // This class defines the mutable nsGlobalWindow state we support querying |
24 | | // through the ClientManagerService. It is a snapshot of the state and |
25 | | // is not live updated. |
26 | | class ClientWindowState final |
27 | | { |
28 | | UniquePtr<IPCClientWindowState> mData; |
29 | | |
30 | | public: |
31 | | ClientWindowState(mozilla::dom::VisibilityState aVisibilityState, |
32 | | const TimeStamp& aLastFocusTime, |
33 | | nsContentUtils::StorageAccess aStorageAccess, |
34 | | bool aFocused); |
35 | | |
36 | | explicit ClientWindowState(const IPCClientWindowState& aData); |
37 | | |
38 | | ClientWindowState(const ClientWindowState& aRight); |
39 | | ClientWindowState(ClientWindowState&& aRight); |
40 | | |
41 | | ClientWindowState& |
42 | | operator=(const ClientWindowState& aRight); |
43 | | |
44 | | ClientWindowState& |
45 | | operator=(ClientWindowState&& aRight); |
46 | | |
47 | | ~ClientWindowState(); |
48 | | |
49 | | mozilla::dom::VisibilityState |
50 | | VisibilityState() const; |
51 | | |
52 | | const TimeStamp& |
53 | | LastFocusTime() const; |
54 | | |
55 | | bool |
56 | | Focused() const; |
57 | | |
58 | | nsContentUtils::StorageAccess |
59 | | GetStorageAccess() const; |
60 | | |
61 | | const IPCClientWindowState& |
62 | | ToIPC() const; |
63 | | }; |
64 | | |
65 | | // This class defines the mutable worker state we support querying |
66 | | // through the ClientManagerService. It is a snapshot of the state and |
67 | | // is not live updated. Right now, we don't actually providate any |
68 | | // worker specific state values, but we may in the future. This |
69 | | // class also services as a placeholder that the state is referring |
70 | | // to a worker in ClientState. |
71 | | class ClientWorkerState final |
72 | | { |
73 | | UniquePtr<IPCClientWorkerState> mData; |
74 | | |
75 | | public: |
76 | | explicit ClientWorkerState(nsContentUtils::StorageAccess aStorageAccess); |
77 | | |
78 | | explicit ClientWorkerState(const IPCClientWorkerState& aData); |
79 | | |
80 | | ClientWorkerState(const ClientWorkerState& aRight); |
81 | | ClientWorkerState(ClientWorkerState&& aRight); |
82 | | |
83 | | ClientWorkerState& |
84 | | operator=(const ClientWorkerState& aRight); |
85 | | |
86 | | ClientWorkerState& |
87 | | operator=(ClientWorkerState&& aRight); |
88 | | |
89 | | ~ClientWorkerState(); |
90 | | |
91 | | nsContentUtils::StorageAccess |
92 | | GetStorageAccess() const; |
93 | | |
94 | | const IPCClientWorkerState& |
95 | | ToIPC() const; |
96 | | }; |
97 | | |
98 | | // This is a union of the various types of mutable state we support |
99 | | // querying in ClientManagerService. Right now it can contain either |
100 | | // window or worker states. |
101 | | class ClientState final |
102 | | { |
103 | | Maybe<Variant<ClientWindowState, ClientWorkerState>> mData; |
104 | | |
105 | | public: |
106 | | ClientState(); |
107 | | |
108 | | explicit ClientState(const ClientWindowState& aWindowState); |
109 | | explicit ClientState(const ClientWorkerState& aWorkerState); |
110 | | explicit ClientState(const IPCClientWindowState& aData); |
111 | | explicit ClientState(const IPCClientWorkerState& aData); |
112 | | |
113 | 0 | ClientState(const ClientState& aRight) = default; |
114 | | ClientState(ClientState&& aRight); |
115 | | |
116 | | ClientState& |
117 | | operator=(const ClientState& aRight) = default; |
118 | | |
119 | | ClientState& |
120 | | operator=(ClientState&& aRight); |
121 | | |
122 | | ~ClientState(); |
123 | | |
124 | | static ClientState |
125 | | FromIPC(const IPCClientState& aData); |
126 | | |
127 | | bool |
128 | | IsWindowState() const; |
129 | | |
130 | | const ClientWindowState& |
131 | | AsWindowState() const; |
132 | | |
133 | | bool |
134 | | IsWorkerState() const; |
135 | | |
136 | | const ClientWorkerState& |
137 | | AsWorkerState() const; |
138 | | |
139 | | nsContentUtils::StorageAccess |
140 | | GetStorageAccess() const; |
141 | | |
142 | | const IPCClientState |
143 | | ToIPC() const; |
144 | | }; |
145 | | |
146 | | } // namespace dom |
147 | | } // namespace mozilla |
148 | | |
149 | | #endif // _mozilla_dom_ClientState_h |