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 file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_dom_workerinternals_JSSettings_h
8 #define mozilla_dom_workerinternals_JSSettings_h
12 #include "js/ContextOptions.h"
14 #include "js/RealmOptions.h"
15 #include "mozilla/Maybe.h"
19 namespace mozilla::dom::workerinternals
{
21 // Random unique constant to facilitate JSPrincipal debugging
22 const uint32_t kJSPrincipalsDebugToken
= 0x7e2df9d2;
27 // Nothing() represents the default value, the result of calling
28 // JS_ResetGCParameter.
29 Maybe
<uint32_t> value
;
31 // For the IndexOf call below.
32 bool operator==(JSGCParamKey k
) const { return key
== k
; }
35 JS::RealmOptions chromeRealmOptions
;
36 JS::RealmOptions contentRealmOptions
;
37 CopyableTArray
<JSGCSetting
> gcSettings
;
38 JS::ContextOptions contextOptions
;
42 uint32_t gcZealFrequency
= 0;
45 // Returns whether there was a change in the setting.
46 bool ApplyGCSetting(JSGCParamKey aKey
, Maybe
<uint32_t> aValue
) {
47 size_t index
= gcSettings
.IndexOf(aKey
);
48 if (index
== gcSettings
.NoIndex
) {
49 gcSettings
.AppendElement(JSGCSetting
{aKey
, aValue
});
52 if (gcSettings
[index
].value
!= aValue
) {
53 gcSettings
[index
].value
= aValue
;
60 } // namespace mozilla::dom::workerinternals
62 #endif // mozilla_dom_workerinternals_JSSettings_h