Skip to content

Commit

Permalink
Bug 1773770: Part 9 - Migrate widget component content proxies to sta…
Browse files Browse the repository at this point in the history
…tic registration. r=mccr8

Several widget contracts use different implementations in the parent and
content processes. Since the static registration system builds its hashtable
at compile time rather than runtime, it doesn't support different contract IDs
per process. It could make the decision at lookup time, but given how rarely
it's needed, I don't think it would be worth the complexity.

This patch updates the widget components that need different implementations
in the parent and content process to register separate contracts for each
implementation, and a third stub contract which forwards to the appropriate
implementation depending on which process it's used in. The implementation
entries restrict their usage to the process they are meant to be used in.

Differential Revision: https://phabricator.services.mozilla.com/D149436
  • Loading branch information
kmaglione committed Jun 30, 2022
1 parent e3537d8 commit fb6a60d
Show file tree
Hide file tree
Showing 12 changed files with 211 additions and 126 deletions.
3 changes: 0 additions & 3 deletions mobile/android/components/geckoview/ColorPickerDelegate.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ class ColorPickerDelegate {
}
}

ColorPickerDelegate.prototype.classID = Components.ID(
"{aa0dd6fc-73dd-4621-8385-c0b377e02cee}"
);
ColorPickerDelegate.prototype.QueryInterface = ChromeUtils.generateQI([
"nsIColorPicker",
]);
8 changes: 4 additions & 4 deletions mobile/android/components/geckoview/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ Classes = [
'constructor': 'PushService',
},
{
'cid': '{aa0dd6fc-73dd-4621-8385-c0b377e02cee}',
'contract_ids': ['@mozilla.org/colorpicker;1'],
'cid': '{fc4bec74-ddd0-4ea8-9a66-9a5081258e32}',
'contract_ids': ['@mozilla.org/parent/colorpicker;1'],
'jsm': 'resource://gre/modules/ColorPickerDelegate.jsm',
'constructor': 'ColorPickerDelegate',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
{
'cid': '{e4565e36-f101-4bf5-950b-4be0887785a9}',
'contract_ids': ['@mozilla.org/filepicker;1'],
'cid': '{25fdbae6-f684-4bf0-b773-ff2b7a6273c8}',
'contract_ids': ['@mozilla.org/parent/filepicker;1'],
'jsm': 'resource://gre/modules/FilePickerDelegate.jsm',
'constructor': 'FilePickerDelegate',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ const backgroundtaskPhases = {
name: "@mozilla.org/gfx/screenmanager;1",
condition: WIN,
},
{
name: "@mozilla.org/gfx/parent/screenmanager;1",
condition: WIN,
},
],
},
},
Expand Down
10 changes: 4 additions & 6 deletions widget/android/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Classes = [
'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS,
},
{
'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}',
'contract_ids': ['@mozilla.org/gfx/screenmanager;1'],
'cid': '{d594094c-28b6-466b-97d7-66c039c3dea9}',
'contract_ids': ['@mozilla.org/gfx/parent/screenmanager;1'],
'singleton': True,
'type': 'mozilla::widget::ScreenManager',
'headers': ['mozilla/widget/ScreenManager.h'],
Expand All @@ -43,14 +43,12 @@ Classes = [
'headers': ['/widget/nsTransferable.h'],
},
{
'js_name': 'clipboard',
'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/clipboard;1'],
'cid': '{9d5adbb9-1da4-4162-acba-b373fe3ae837}',
'contract_ids': ['@mozilla.org/widget/parent/clipboard;1'],
'interfaces': ['nsIClipboard'],
'type': 'nsClipboard',
'headers': ['/widget/android/nsClipboard.h'],
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
'overridable': True,
},
{
'cid': '{77221d5a-1dd2-11b2-8c69-c710f15d2ed5}',
Expand Down
26 changes: 12 additions & 14 deletions widget/cocoa/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ UnloadFunc = 'nsWidgetCocoaModuleDtor'

Classes = [
{
'js_name': 'clipboard',
'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/clipboard;1'],
'cid': '{49f428e8-baf9-4ba3-b1b0-7d2fd3abbcea}',
'contract_ids': ['@mozilla.org/widget/parent/clipboard;1'],
'interfaces': ['nsIClipboard'],
'type': 'nsIClipboard',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
'overridable': True,
},
{
'name': 'GfxInfo',
Expand All @@ -28,14 +26,14 @@ Classes = [
'init_method': 'Init',
},
{
'cid': '{bd57cee8-1dd1-11b2-9fe7-95cf4709aea3}',
'contract_ids': ['@mozilla.org/filepicker;1'],
'cid': '{e5170091-c16b-492d-bf00-f45d72470553}',
'contract_ids': ['@mozilla.org/parent/filepicker;1'],
'type': 'nsFilePicker',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
{
'cid': '{0f872c8c-3ee6-46bd-92a2-69652c6b474e}',
'contract_ids': ['@mozilla.org/colorpicker;1'],
'cid': '{b90f5fdd-c23e-4ad6-a10e-1da8ffe07799}',
'contract_ids': ['@mozilla.org/parent/colorpicker;1'],
'type': 'nsColorPicker',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
Expand All @@ -46,8 +44,8 @@ Classes = [
'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS,
},
{
'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}',
'contract_ids': ['@mozilla.org/sound;1'],
'cid': '{15cc80a9-5329-4fcb-9a0b-c6cf1440ae51}',
'contract_ids': ['@mozilla.org/parent/sound;1'],
'type': 'nsSound',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
Expand All @@ -70,14 +68,14 @@ Classes = [
'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS,
},
{
'cid': '{8b5314bb-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/dragservice;1'],
'cid': '{9a155bb2-2b67-45de-83e3-13a9dacf8336}',
'contract_ids': ['@mozilla.org/widget/parent/dragservice;1'],
'type': 'nsDragService',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
{
'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}',
'contract_ids': ['@mozilla.org/gfx/screenmanager;1'],
'cid': '{f0ddedd7-e8d5-4f95-a5b4-0f48f1741b36}',
'contract_ids': ['@mozilla.org/gfx/parent/screenmanager;1'],
'type': 'mozilla::widget::ScreenManager',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
'singleton': True,
Expand Down
98 changes: 98 additions & 0 deletions widget/components.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# vim: set filetype=python:
# 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/.

Classes = [
{
'js_name': 'clipboard',
'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/clipboard;1'],
'constructor': 'nsClipboardSelector',
'headers': ['/widget/nsContentProcessWidgetFactory.h'],
'interfaces': ['nsIClipboard'],
'overridable': True,
},
{
'cid': '{c0ed2a75-96f8-4166-91d4-2fe8774448dc}',
'type': 'nsClipboardProxy',
'headers': ['/widget/nsClipboardProxy.h'],
'contract_ids': ['@mozilla.org/widget/content/clipboard;1'],
'processes': ProcessSelector.CONTENT_PROCESS_ONLY,
},

{
'cid': '{0f872c8c-3ee6-46bd-92a2-69652c6b474e}',
'contract_ids': ['@mozilla.org/colorpicker;1'],
'constructor': 'nsColorPickerSelector',
'headers': ['/widget/nsContentProcessWidgetFactory.h'],
},
{
'cid': '{11a77259-9d16-4386-8ac8-94338ee22f78}',
'type': 'nsColorPickerProxy',
'headers': ['/widget/nsColorPickerProxy.h'],
'contract_ids': ['@mozilla.org/content/colorpicker;1'],
'processes': ProcessSelector.CONTENT_PROCESS_ONLY,
},

{
'cid': '{8b5314bb-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/dragservice;1'],
'constructor': 'nsDragServiceSelector',
'headers': ['/widget/nsContentProcessWidgetFactory.h'],
},
{
'cid': '{28be18ae-73ee-494f-8c6d-5d14b7c998c7}',
'type': 'nsDragServiceProxy',
'headers': ['/widget/nsDragServiceProxy.h'],
'contract_ids': ['@mozilla.org/widget/content/dragservice;1'],
'processes': ProcessSelector.CONTENT_PROCESS_ONLY,
},

{
'cid': '{bd57cee8-1dd1-11b2-9fe7-95cf4709aea3}',
'contract_ids': ['@mozilla.org/filepicker;1'],
'constructor': 'nsFilePickerSelector',
'headers': ['/widget/nsContentProcessWidgetFactory.h'],
},
{
'cid': '{40fd47f2-463a-4e4a-a33f-27eb148bfee4}',
'type': 'nsFilePickerProxy',
'headers': ['/widget/nsFilePickerProxy.h'],
'contract_ids': ['@mozilla.org/content/filepicker;1'],
'processes': ProcessSelector.CONTENT_PROCESS_ONLY,
},

{
'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}',
'contract_ids': ['@mozilla.org/sound;1'],
'singleton': True,
'constructor': 'nsSoundSelector',
'headers': ['/widget/nsContentProcessWidgetFactory.h'],
},
{
'cid': '{b02c2470-6e5a-4865-a202-8b5ebae52632}',
'type': 'nsSoundProxy',
'headers': ['/widget/nsSoundProxy.h'],
'contract_ids': ['@mozilla.org/content/sound;1'],
'processes': ProcessSelector.CONTENT_PROCESS_ONLY,
},

{
'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}',
'contract_ids': ['@mozilla.org/gfx/screenmanager;1'],
'singleton': True,
'constructor': 'nsScreenManagerSelector',
'headers': ['/widget/nsContentProcessWidgetFactory.h'],
},
{
'cid': '{b2cdd51c-4277-417b-a931-08306c7814c3}',
'type': 'mozilla::widget::ScreenManager',
'constructor': 'mozilla::widget::ScreenManager::GetAddRefedSingleton',
'headers': ['mozilla/widget/ScreenManager.h'],
'contract_ids': ['@mozilla.org/gfx/content/screenmanager;1'],
'singleton': True,
'processes': ProcessSelector.CONTENT_PROCESS_ONLY,
},
]
26 changes: 12 additions & 14 deletions widget/gtk/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Classes = [
'processes': ProcessSelector.ALLOW_IN_GPU_RDD_VR_SOCKET_AND_UTILITY_PROCESS,
},
{
'cid': '{c401eb80-f9ea-11d3-bb6f-e732b73ebe7c}',
'contract_ids': ['@mozilla.org/gfx/screenmanager;1'],
'cid': '{e9537f8f-c07e-4435-8ab3-83f1ad6e3bbf}',
'contract_ids': ['@mozilla.org/gfx/parent/screenmanager;1'],
'singleton': True,
'type': 'mozilla::widget::ScreenManager',
'headers': ['mozilla/StaticPtr.h', 'mozilla/widget/ScreenManager.h'],
Expand All @@ -35,15 +35,15 @@ Classes = [
'headers': ['/widget/gtk/TaskbarProgress.h'],
},
{
'cid': '{0f872c8c-3ee6-46bd-92a2-69652c6b474e}',
'contract_ids': ['@mozilla.org/colorpicker;1'],
'cid': '{4364de1a-798e-419c-a6f5-ca28866b6d5f}',
'contract_ids': ['@mozilla.org/parent/colorpicker;1'],
'type': 'nsColorPicker',
'headers': ['/widget/gtk/nsColorPicker.h'],
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
{
'cid': '{bd57cee8-1dd1-11b2-9fe7-95cf4709aea3}',
'contract_ids': ['@mozilla.org/filepicker;1'],
'cid': '{1940fed5-7d02-4122-8acf-7abaac698983}',
'contract_ids': ['@mozilla.org/parent/filepicker;1'],
'type': 'nsFilePicker',
'headers': ['/widget/gtk/nsFilePicker.h'],
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
Expand All @@ -55,8 +55,8 @@ Classes = [
'headers': ['/widget/nsHTMLFormatConverter.h'],
},
{
'cid': '{b148eed2-236d-11d3-b35c-00a0cc3c1cde}',
'contract_ids': ['@mozilla.org/sound;1'],
'cid': '{e711c28b-c1f1-4b87-8448-e1e0da0a7b7d}',
'contract_ids': ['@mozilla.org/parent/sound;1'],
'singleton': True,
'type': 'nsISound',
'constructor': 'nsSound::GetInstance',
Expand All @@ -77,13 +77,11 @@ Classes = [
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
},
{
'js_name': 'clipboard',
'cid': '{8b5314ba-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/clipboard;1'],
'cid': '{f55f5d31-dbb7-4d0d-9f6f-a4f4cd8e8ef1}',
'contract_ids': ['@mozilla.org/widget/parent/clipboard;1'],
'interfaces': ['nsIClipboard'],
'type': 'nsIClipboard',
'processes': ProcessSelector.MAIN_PROCESS_ONLY,
'overridable': True,
},
{
'cid': '{77221d5a-1dd2-11b2-8c69-c710f15d2ed5}',
Expand All @@ -92,8 +90,8 @@ Classes = [
'headers': ['/widget/nsClipboardHelper.h'],
},
{
'cid': '{8b5314bb-db01-11d2-96ce-0060b0fb9956}',
'contract_ids': ['@mozilla.org/widget/dragservice;1'],
'cid': '{0ba77e04-2adb-422f-af01-5a57b8013100}',
'contract_ids': ['@mozilla.org/widget/parent/dragservice;1'],
'singleton': True,
'type': 'nsDragService',
'headers': ['/widget/gtk/nsDragService.h'],
Expand Down
5 changes: 4 additions & 1 deletion widget/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ with Files("*NativeKeyBindings*"):

toolkit = CONFIG["MOZ_WIDGET_TOOLKIT"]

XPCOM_MANIFESTS += [
"components.conf",
]

if toolkit in ("android", "cocoa", "gtk", "uikit", "windows"):
DIRS += [toolkit]

Expand Down Expand Up @@ -221,7 +225,6 @@ UNIFIED_SOURCES += [
"nsClipboardHelper.cpp",
"nsClipboardProxy.cpp",
"nsColorPickerProxy.cpp",
"nsContentProcessWidgetFactory.cpp",
"nsDragServiceProxy.cpp",
"nsFilePickerProxy.cpp",
"nsHTMLFormatConverter.cpp",
Expand Down
65 changes: 0 additions & 65 deletions widget/nsContentProcessWidgetFactory.cpp

This file was deleted.

Loading

0 comments on commit fb6a60d

Please sign in to comment.