mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 12:20:56 +00:00
Bug 1749385 - Generate CrashManager.jsm from template r=gsvelto,nalexander
Differential Revision: https://phabricator.services.mozilla.com/D136109
This commit is contained in:
parent
f65bde9a02
commit
f1d6617d61
@ -221,8 +221,5 @@ tools/update-packaging/**/*refs.js
|
||||
# Ignore backgroundtasks preferences files.
|
||||
toolkit/components/backgroundtasks/defaults
|
||||
|
||||
# Uses preprocessing
|
||||
toolkit/components/crashes/CrashManager.jsm
|
||||
|
||||
# Ignore pre-generated webpack and typescript transpiled files for translations
|
||||
browser/extensions/translations/extension/
|
||||
|
@ -167,7 +167,8 @@ var CrashManager = function(options) {
|
||||
};
|
||||
|
||||
CrashManager.prototype = Object.freeze({
|
||||
#includesubst @OBJDIR@/GeckoProcessTypes_CrashManager_map.js
|
||||
// gen_CrashManager.py will input the proper process map informations.
|
||||
/* SUBST: CRASH_MANAGER_PROCESS_MAP */
|
||||
|
||||
// A real crash.
|
||||
CRASH_TYPE_CRASH: "crash",
|
||||
@ -506,7 +507,9 @@ CrashManager.prototype = Object.freeze({
|
||||
* @return boolean True or False depending on whether ping is allowed
|
||||
**/
|
||||
isPingAllowed(processType) {
|
||||
#includesubst @OBJDIR@/GeckoProcessTypes_CrashManager_pings.js
|
||||
// gen_CrashManager.py will input the proper process pings informations.
|
||||
|
||||
/* SUBST: CRASH_MANAGER_PROCESS_PINGS */
|
||||
|
||||
// Should not even reach this because of isValidProcessType() but just in
|
||||
// case we try to be cautious
|
57
toolkit/components/crashes/gen_CrashManager.py
Normal file
57
toolkit/components/crashes/gen_CrashManager.py
Normal file
@ -0,0 +1,57 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from geckoprocesstypes import process_types
|
||||
|
||||
|
||||
def process_name(string_name):
|
||||
if string_name == "default":
|
||||
string_name = "main"
|
||||
if string_name == "tab":
|
||||
string_name = "content"
|
||||
return string_name
|
||||
|
||||
|
||||
def gen_process_map():
|
||||
kIdentifier = "/* SUBST: CRASH_MANAGER_PROCESS_MAP */"
|
||||
crashManagerMap = """
|
||||
processTypes: {"""
|
||||
|
||||
for p in process_types:
|
||||
crashManagerMap += """
|
||||
// A crash in the %(procname)s process.
|
||||
%(proctype)d: "%(procname)s",""" % {
|
||||
"proctype": p.enum_value,
|
||||
"procname": process_name(p.string_name),
|
||||
}
|
||||
crashManagerMap += """
|
||||
},"""
|
||||
|
||||
return (kIdentifier, crashManagerMap)
|
||||
|
||||
|
||||
def gen_process_pings():
|
||||
kIdentifier = "/* SUBST: CRASH_MANAGER_PROCESS_PINGS */"
|
||||
crashManagerPing = """let processPings = {"""
|
||||
|
||||
for p in process_types:
|
||||
crashManagerPing += """
|
||||
"%(proctype)s": %(crashping)s,""" % {
|
||||
"proctype": process_name(p.string_name),
|
||||
"crashping": "true" if p.crash_ping else "false",
|
||||
}
|
||||
crashManagerPing += """
|
||||
};"""
|
||||
|
||||
return (kIdentifier, crashManagerPing)
|
||||
|
||||
|
||||
def main(o, crashManager):
|
||||
subst = [gen_process_map(), gen_process_pings()]
|
||||
with open(crashManager, "r") as src:
|
||||
for l in src.readlines():
|
||||
for (id, value) in subst:
|
||||
if id in l:
|
||||
l = l.replace(id, value)
|
||||
o.write(l)
|
@ -1,32 +0,0 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from geckoprocesstypes import process_types
|
||||
|
||||
|
||||
def main(output):
|
||||
output.write(
|
||||
"""
|
||||
processTypes: {"""
|
||||
)
|
||||
|
||||
for p in process_types:
|
||||
string_name = p.string_name
|
||||
if p.string_name == "default":
|
||||
string_name = "main"
|
||||
if p.string_name == "tab":
|
||||
string_name = "content"
|
||||
output.write(
|
||||
"""
|
||||
// A crash in the %(procname)s process.
|
||||
%(proctype)d: "%(procname)s","""
|
||||
% {
|
||||
"proctype": p.enum_value,
|
||||
"procname": string_name,
|
||||
}
|
||||
)
|
||||
output.write(
|
||||
"""
|
||||
},"""
|
||||
)
|
@ -1,29 +0,0 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from geckoprocesstypes import process_types
|
||||
|
||||
|
||||
def main(output):
|
||||
output.write(""" let processPings = {""")
|
||||
|
||||
for p in process_types:
|
||||
string_name = p.string_name
|
||||
if p.string_name == "default":
|
||||
string_name = "main"
|
||||
if p.string_name == "tab":
|
||||
string_name = "content"
|
||||
output.write(
|
||||
"""
|
||||
"%(proctype)s": %(crashping)s,"""
|
||||
% {
|
||||
"proctype": string_name,
|
||||
"crashping": "true" if p.crash_ping else "false",
|
||||
}
|
||||
)
|
||||
output.write(
|
||||
"""
|
||||
};
|
||||
"""
|
||||
)
|
@ -19,21 +19,14 @@ XPIDL_SOURCES += [
|
||||
|
||||
if CONFIG["MOZ_CRASHREPORTER"]:
|
||||
GeneratedFile(
|
||||
"GeckoProcessTypes_CrashManager_map.js",
|
||||
script="gen_process_map.py",
|
||||
entry_point="main",
|
||||
)
|
||||
GeneratedFile(
|
||||
"GeckoProcessTypes_CrashManager_pings.js",
|
||||
script="gen_process_pings.py",
|
||||
entry_point="main",
|
||||
)
|
||||
|
||||
EXTRA_PP_JS_MODULES += [
|
||||
"CrashManager.jsm",
|
||||
]
|
||||
script="gen_CrashManager.py",
|
||||
entry_point="main",
|
||||
inputs=["CrashManager.jsm.in"],
|
||||
)
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
"!CrashManager.jsm",
|
||||
"CrashService.jsm",
|
||||
]
|
||||
|
||||
|
@ -344,7 +344,7 @@ avoid-blacklist-and-whitelist:
|
||||
- toolkit/components/antitracking/test/browser/browser_siteSpecificWorkArounds.js
|
||||
- toolkit/components/antitracking/test/browser/browser_socialtracking_save_image.js
|
||||
- toolkit/components/antitracking/test/xpcshell/test_rejectForeignAllowList.js
|
||||
- toolkit/components/crashes/CrashManager.jsm
|
||||
- toolkit/components/crashes/CrashManager.jsm.in
|
||||
- toolkit/components/crashes/tests/xpcshell/test_crash_manager.js
|
||||
- toolkit/components/extensions/Extension.jsm
|
||||
- toolkit/components/extensions/test/xpcshell/test_WebExtensionPolicy.js
|
||||
|
Loading…
x
Reference in New Issue
Block a user