Reland "Remove legacy Mojo Core from most build configs"
This is a reland of commit 13b1733de755bdc6b324c6888bdcebffde6d5ece
The original change was reverted because Windows builds were
still configured to package mojo_core.dll with the browser
even though we were no longer building it.
There are no longer any plans to use this DLL, so patchset 2
here removes all packaging of it.
Original change's description:
> Remove legacy Mojo Core from most build configs
>
> Other than Chrome OS and fuzzer builds, we don't need to support this
> anymore. Add a new buildflag (mojo_support_legacy_core) which defaults
> to false except in those cases, and don't build any of that code
> unless it's true.
>
> Bug: 359926651
> Change-Id: I1c207f2ee55ee28c9920ab6db3e3c2f447eccab2
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5789371
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Commit-Queue: Ken Rockot <rockot@google.com>
> Cr-Commit-Position: refs/heads/main@{#1342426}
Bug: 359926651
Change-Id: I6624315f3cdd230a51290bc487d33bb6324ca1a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5792219
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Commit-Queue: Ken Rockot <rockot@google.com>
Reviewed-by: Ben Pastene <bpastene@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1342674}
diff --git a/chrome/BUILD.gn b/chrome/BUILD.gn
index 4eebaff..0b3cce9 100644
--- a/chrome/BUILD.gn
+++ b/chrome/BUILD.gn
@@ -24,6 +24,7 @@
import("//components/optimization_guide/features.gni")
import("//extensions/buildflags/buildflags.gni")
import("//media/media_options.gni")
+import("//mojo/features.gni")
import("//ppapi/buildflags/buildflags.gni")
import("//third_party/blink/public/public_features.gni")
import("//third_party/widevine/cdm/widevine.gni")
@@ -369,7 +370,7 @@
}
}
- if (is_chromeos_ash || is_win) {
+ if ((is_chromeos_ash || is_win) && mojo_support_legacy_core) {
data_deps += [ "//mojo/core:shared_library" ]
}
diff --git a/chrome/installer/mini_installer/BUILD.gn b/chrome/installer/mini_installer/BUILD.gn
index adcf8e9..4d0ac06 100644
--- a/chrome/installer/mini_installer/BUILD.gn
+++ b/chrome/installer/mini_installer/BUILD.gn
@@ -8,6 +8,7 @@
import("//build/config/ui.gni")
import("//build/timestamp.gni")
import("//chrome/process_version_rc_template.gni")
+import("//mojo/features.gni")
import("//third_party/dawn/scripts/dawn_features.gni")
import("//third_party/ffmpeg/ffmpeg_options.gni")
import("//third_party/icu/config.gni")
@@ -194,7 +195,6 @@
"//chrome/browser/extensions/default_extensions",
"//chrome/common/win:eventlog_provider",
"//chrome/installer/setup",
- "//mojo/core:shared_library",
"//third_party/icu:icudata",
]
@@ -243,6 +243,10 @@
args += [ "--include_dxc=1" ]
}
+ if (mojo_support_legacy_core) {
+ deps += [ "//mojo/core:shared_library" ]
+ }
+
depfile = "$target_gen_dir/archive.d"
args += [
"--depfile",
diff --git a/chrome/installer/mini_installer/chrome.release b/chrome/installer/mini_installer/chrome.release
index 28eb7e78..e5de735 100644
--- a/chrome/installer/mini_installer/chrome.release
+++ b/chrome/installer/mini_installer/chrome.release
@@ -29,7 +29,6 @@
icudtl.dat: %(VersionDir)s\
libEGL.dll: %(VersionDir)s\
libGLESv2.dll: %(VersionDir)s\
-mojo_core.dll: %(VersionDir)s\
notification_helper.exe: %(VersionDir)s\
optimization_guide_internal.dll: %(VersionDir)s\
resources.pak: %(VersionDir)s\
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
index 081c5956..5f79469 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -12382,6 +12382,7 @@
"//chrome",
"//chrome/install_static:install_static_util",
"//chrome/install_static/test:test_support",
+ "//mojo:buildflags",
"//testing/gtest",
]
diff --git a/chrome/test/delayload/delayloads_unittest.cc b/chrome/test/delayload/delayloads_unittest.cc
index 1cd12dc..1132a79 100644
--- a/chrome/test/delayload/delayloads_unittest.cc
+++ b/chrome/test/delayload/delayloads_unittest.cc
@@ -27,6 +27,7 @@
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "chrome/install_static/test/scoped_install_details.h"
+#include "mojo/buildflags.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest-spi.h"
@@ -476,18 +477,12 @@
TEST_F(MinimumWindowsSupportTest, ChromeExtraDlls) {
std::vector<std::wstring> extra_dlls = {
- L"d3dcompiler_47.dll",
+ L"d3dcompiler_47.dll",
#if !defined(ARCH_CPU_ARM64)
- // These are not yet supported for Arm64.
- L"dxcompiler.dll",
- L"dxil.dll",
+ // These are not yet supported for Arm64.
+ L"dxcompiler.dll", L"dxil.dll",
#endif // !defined(ARCH_CPU_ARM64
- L"libEGL.dll",
- L"libGLESv2.dll",
- L"mojo_core.dll",
- L"vk_swiftshader.dll",
- L"vulkan-1.dll"
- };
+ L"libEGL.dll", L"libGLESv2.dll", L"vk_swiftshader.dll", L"vulkan-1.dll"};
for (const auto& dll : extra_dlls) {
Validate(dll);
}
diff --git a/chrome/tools/build/win/FILES.cfg b/chrome/tools/build/win/FILES.cfg
index cdb9aee..f0f616e 100644
--- a/chrome/tools/build/win/FILES.cfg
+++ b/chrome/tools/build/win/FILES.cfg
@@ -107,12 +107,6 @@
'optional': ['official'],
},
{
- 'filename': 'mojo_core.dll',
- 'buildtype': ['official'],
- 'optional': ['official'],
- 'filegroup': ['default', 'symsrc'],
- },
- {
'filename': 'v8_context_snapshot.bin',
'buildtype': ['official'],
'optional': ['official'],
@@ -667,11 +661,6 @@
'archive': 'chrome-win32-syms.zip',
},
{
- 'filename': 'mojo_core.dll.pdb',
- 'buildtype': ['official'],
- 'archive': 'chrome-win32-syms.zip',
- },
- {
'filename': 'vk_swiftshader.dll.pdb',
'buildtype': ['official'],
'archive': 'chrome-win32-syms.zip',
diff --git a/content/test/BUILD.gn b/content/test/BUILD.gn
index ee31836..1b93c4b 100644
--- a/content/test/BUILD.gn
+++ b/content/test/BUILD.gn
@@ -13,6 +13,7 @@
import("//content/common/features.gni")
import("//device/vr/buildflags/buildflags.gni")
import("//media/media_options.gni")
+import("//mojo/features.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//net/features.gni")
import("//ppapi/buildflags/buildflags.gni")
@@ -2212,7 +2213,8 @@
deps += [ "//device/vr:vr_fakes" ]
}
- if ((is_win || is_chromeos || is_linux) && !is_tsan) {
+ if ((is_win || is_chromeos || is_linux) && !is_tsan &&
+ mojo_support_legacy_core) {
# NOTE: We don't bother to build these tests when TSan is enabled, because
# they can't properly launch a child content_shell in that environment.
sources += [ "../browser/launch_as_mojo_client_browsertest.cc" ]
diff --git a/infra/archive_config/win-archive-rel.json b/infra/archive_config/win-archive-rel.json
index 65de38e..119cb99 100644
--- a/infra/archive_config/win-archive-rel.json
+++ b/infra/archive_config/win-archive-rel.json
@@ -22,7 +22,6 @@
"libGLESv2.dll",
"MEIPreload\\manifest.json",
"MEIPreload\\preloaded_data.pb",
- "mojo_core.dll",
"notification_helper.exe",
"PrivacySandboxAttestationsPreloaded\\manifest.json",
"PrivacySandboxAttestationsPreloaded\\privacy-sandbox-attestations.dat",
@@ -67,7 +66,6 @@
"libEGL.dll.pdb",
"libGLESv2.dll.pdb",
"mini_installer.exe.pdb",
- "mojo_core.dll.pdb",
"notification_helper.exe.pdb",
"setup.exe.pdb",
"vk_swiftshader.dll.pdb",
diff --git a/infra/archive_config/win-arm64-archive-rel.json b/infra/archive_config/win-arm64-archive-rel.json
index 848d9e5..f1d84005 100644
--- a/infra/archive_config/win-arm64-archive-rel.json
+++ b/infra/archive_config/win-arm64-archive-rel.json
@@ -22,7 +22,6 @@
"libGLESv2.dll",
"MEIPreload\\manifest.json",
"MEIPreload\\preloaded_data.pb",
- "mojo_core.dll",
"notification_helper.exe",
"PrivacySandboxAttestationsPreloaded\\manifest.json",
"PrivacySandboxAttestationsPreloaded\\privacy-sandbox-attestations.dat",
@@ -67,7 +66,6 @@
"libEGL.dll.pdb",
"libGLESv2.dll.pdb",
"mini_installer.exe.pdb",
- "mojo_core.dll.pdb",
"notification_helper.exe.pdb",
"setup.exe.pdb",
"vk_swiftshader.dll.pdb",
diff --git a/infra/archive_config/win32-archive-rel.json b/infra/archive_config/win32-archive-rel.json
index 6478c7f8..2af8ac40 100644
--- a/infra/archive_config/win32-archive-rel.json
+++ b/infra/archive_config/win32-archive-rel.json
@@ -22,7 +22,6 @@
"libGLESv2.dll",
"MEIPreload\\manifest.json",
"MEIPreload\\preloaded_data.pb",
- "mojo_core.dll",
"notification_helper.exe",
"PrivacySandboxAttestationsPreloaded\\manifest.json",
"PrivacySandboxAttestationsPreloaded\\privacy-sandbox-attestations.dat",
@@ -67,7 +66,6 @@
"libEGL.dll.pdb",
"libGLESv2.dll.pdb",
"mini_installer.exe.pdb",
- "mojo_core.dll.pdb",
"notification_helper.exe.pdb",
"setup.exe.pdb",
"vk_swiftshader.dll.pdb",
diff --git a/mojo/BUILD.gn b/mojo/BUILD.gn
index fe5562c0..f306502 100644
--- a/mojo/BUILD.gn
+++ b/mojo/BUILD.gn
@@ -25,7 +25,10 @@
buildflag_header("buildflags") {
header = "buildflags.h"
- flags = [ "MOJO_USE_APPLE_CHANNEL=$mojo_use_apple_channel" ]
+ flags = [
+ "MOJO_USE_APPLE_CHANNEL=$mojo_use_apple_channel",
+ "MOJO_SUPPORT_LEGACY_CORE=$mojo_support_legacy_core",
+ ]
}
group("tests") {
@@ -56,13 +59,16 @@
"//mojo/public/js/ts/bindings/tests",
]
- if (is_linux) {
+ if (is_linux && mojo_support_legacy_core) {
deps += [ "//mojo/proxy:tests" ]
}
}
test("mojo_perftests") {
- sources = [ "//mojo/core/handle_table_perftest.cc" ]
+ sources = []
+ if (mojo_support_legacy_core) {
+ sources += [ "//mojo/core/handle_table_perftest.cc" ]
+ }
deps = [
"//mojo/core/test:run_all_perftests",
"//mojo/core/test:test_support",
diff --git a/mojo/core/BUILD.gn b/mojo/core/BUILD.gn
index de039bc..a738b2e6 100644
--- a/mojo/core/BUILD.gn
+++ b/mojo/core/BUILD.gn
@@ -50,18 +50,10 @@
"channel.h",
"configuration.h",
"connection_params.h",
- "core.h",
"core_ipcz.h",
- "data_pipe_consumer_dispatcher.h",
- "data_pipe_control_message.h",
- "data_pipe_producer_dispatcher.h",
- "dispatcher.h",
"embedder/configuration.h",
"embedder/process_error_callback.h",
- "entrypoints.h",
"handle_signals_state.h",
- "handle_table.h",
- "invitation_dispatcher.h",
"ipcz_api.h",
"ipcz_driver/base_shared_memory_service.h",
"ipcz_driver/driver.h",
@@ -74,35 +66,16 @@
"ipcz_driver/transmissible_platform_handle.h",
"ipcz_driver/transport.h",
"ipcz_driver/wrapped_platform_handle.h",
- "message_pipe_dispatcher.h",
- "node_channel.h",
- "node_controller.h",
- "options_validation.h",
- "platform_handle_dispatcher.h",
"platform_handle_utils.h",
- "platform_shared_memory_mapping.h",
- "request_context.h",
"scoped_ipcz_handle.h",
- "shared_buffer_dispatcher.h",
- "user_message_impl.h",
]
sources = [
- "atomic_flag.cc",
- "atomic_flag.h",
"broker.h",
"channel.cc",
"configuration.cc",
"connection_params.cc",
- "core.cc",
"core_ipcz.cc",
- "data_pipe_consumer_dispatcher.cc",
- "data_pipe_control_message.cc",
- "data_pipe_producer_dispatcher.cc",
- "dispatcher.cc",
- "entrypoints.cc",
- "handle_table.cc",
- "invitation_dispatcher.cc",
"ipcz_api.cc",
"ipcz_driver/base_shared_memory_service.cc",
"ipcz_driver/data_pipe.cc",
@@ -119,31 +92,16 @@
"ipcz_driver/transmissible_platform_handle.cc",
"ipcz_driver/transport.cc",
"ipcz_driver/wrapped_platform_handle.cc",
- "message_pipe_dispatcher.cc",
- "node_channel.cc",
- "node_controller.cc",
- "platform_handle_dispatcher.cc",
"platform_handle_in_transit.cc",
"platform_handle_in_transit.h",
"platform_handle_utils.cc",
- "platform_shared_memory_mapping.cc",
- "request_context.cc",
"scoped_ipcz_handle.cc",
- "shared_buffer_dispatcher.cc",
- "user_message_impl.cc",
- "watch.cc",
- "watch.h",
- "watcher_dispatcher.cc",
- "watcher_dispatcher.h",
- "watcher_set.cc",
- "watcher_set.h",
]
public_deps = [
"//base",
"//mojo:buildflags",
"//mojo/core/embedder:features",
- "//mojo/core/ports",
"//mojo/public/c/system:headers",
"//mojo/public/cpp/bindings:mojo_buildflags",
"//mojo/public/cpp/platform",
@@ -151,6 +109,55 @@
"//third_party/ipcz/src:ipcz_chromium",
]
+ if (mojo_support_legacy_core) {
+ public += [
+ "core.h",
+ "data_pipe_consumer_dispatcher.h",
+ "data_pipe_control_message.h",
+ "data_pipe_producer_dispatcher.h",
+ "dispatcher.h",
+ "entrypoints.h",
+ "handle_table.h",
+ "invitation_dispatcher.h",
+ "message_pipe_dispatcher.h",
+ "node_channel.h",
+ "node_controller.h",
+ "options_validation.h",
+ "platform_handle_dispatcher.h",
+ "platform_shared_memory_mapping.h",
+ "request_context.h",
+ "shared_buffer_dispatcher.h",
+ "user_message_impl.h",
+ ]
+ sources += [
+ "atomic_flag.cc",
+ "atomic_flag.h",
+ "core.cc",
+ "data_pipe_consumer_dispatcher.cc",
+ "data_pipe_control_message.cc",
+ "data_pipe_producer_dispatcher.cc",
+ "dispatcher.cc",
+ "entrypoints.cc",
+ "handle_table.cc",
+ "invitation_dispatcher.cc",
+ "message_pipe_dispatcher.cc",
+ "node_channel.cc",
+ "node_controller.cc",
+ "platform_handle_dispatcher.cc",
+ "platform_shared_memory_mapping.cc",
+ "request_context.cc",
+ "shared_buffer_dispatcher.cc",
+ "user_message_impl.cc",
+ "watch.cc",
+ "watch.h",
+ "watcher_dispatcher.cc",
+ "watcher_dispatcher.h",
+ "watcher_set.cc",
+ "watcher_set.h",
+ ]
+ public_deps += [ "//mojo/core/ports" ]
+ }
+
if (is_fuchsia) {
sources += [ "channel_fuchsia.cc" ]
@@ -251,7 +258,8 @@
}
}
-if (is_chromeos || is_linux || is_android || is_win || is_fuchsia) {
+if ((is_chromeos || is_linux || is_android || is_win || is_fuchsia) &&
+ mojo_support_legacy_core) {
core_impl_source_set("impl_for_shared_library") {
for_shared_library = true
}
@@ -308,19 +316,10 @@
sources = [
"channel_unittest.cc",
"core_ipcz_test.cc",
- "core_test_base.cc",
- "core_test_base.h",
- "core_unittest.cc",
"embedder_unittest.cc",
- "handle_table_unittest.cc",
"message_pipe_unittest.cc",
"message_unittest.cc",
- "node_channel_unittest.cc",
- "options_validation_unittest.cc",
- "platform_handle_dispatcher_unittest.cc",
"platform_wrapper_unittest.cc",
- "quota_unittest.cc",
- "shared_buffer_dispatcher_unittest.cc",
"shared_buffer_unittest.cc",
"signals_unittest.cc",
"trap_unittest.cc",
@@ -333,7 +332,6 @@
"ipcz_driver/ring_buffer_test.cc",
"ipcz_driver/transport_test.cc",
"multiprocess_message_pipe_unittest.cc",
- "node_controller_unittest.cc",
]
}
@@ -344,7 +342,6 @@
"//mojo:buildflags",
"//mojo/core:embedder_internal",
"//mojo/core/embedder",
- "//mojo/core/ports:tests",
"//mojo/core/test:run_all_unittests",
"//mojo/core/test:test_support",
"//mojo/public/cpp/system",
@@ -352,21 +349,31 @@
"//testing/gtest",
"//third_party/ipcz/src:ipcz_chromium",
]
+
+ if (mojo_support_legacy_core) {
+ sources += [
+ "core_test_base.cc",
+ "core_test_base.h",
+ "core_unittest.cc",
+ "node_channel_unittest.cc",
+ "options_validation_unittest.cc",
+ "platform_handle_dispatcher_unittest.cc",
+ "quota_unittest.cc",
+ "shared_buffer_dispatcher_unittest.cc",
+ ]
+
+ if (use_blink) {
+ sources += [ "node_controller_unittest.cc" ]
+ }
+
+ deps += [ "//mojo/core/ports:tests" ]
+ }
}
group("core_impl_for_fuzzers") {
public_deps = [ ":impl_for_embedder" ]
}
-fuzzer_test("mojo_core_channel_fuzzer") {
- sources = [ "channel_fuzzer.cc" ]
- deps = [
- ":core_impl_for_fuzzers",
- "//base",
- "//mojo/public/cpp/platform",
- ]
-}
-
if (is_mac) {
protoc_convert("mojo_core_channel_mac_fuzzer_convert_corpus") {
sources = [
@@ -398,44 +405,57 @@
"mojo/core/test/data/channel_mac/channel_mac.proto",
]
}
+}
- fuzzer_test("mojo_core_channel_mac_fuzzer") {
- sources = [ "channel_mac_fuzzer.cc" ]
- seed_corpus = "$target_gen_dir/mojo_core_channel_mac_corpus"
- seed_corpus_deps = [ ":mojo_core_channel_mac_fuzzer_convert_corpus" ]
+if (mojo_support_legacy_core) {
+ fuzzer_test("mojo_core_channel_fuzzer") {
+ sources = [ "channel_fuzzer.cc" ]
deps = [
":core_impl_for_fuzzers",
- "test:channel_mac_proto",
"//base",
- "//base/test:test_support",
- "//testing/libfuzzer/fuzzers/mach:converter",
- "//third_party/libprotobuf-mutator",
+ "//mojo/public/cpp/platform",
]
}
-}
-fuzzer_test("mojo_core_node_channel_fuzzer") {
- sources = [ "node_channel_fuzzer.cc" ]
- deps = [
- ":core_impl_for_fuzzers",
- "//base",
- "//mojo/core/test:test_support",
- "//mojo/public/cpp/platform",
- ]
-}
+ fuzzer_test("mojo_core_node_channel_fuzzer") {
+ sources = [ "node_channel_fuzzer.cc" ]
+ deps = [
+ ":core_impl_for_fuzzers",
+ "//base",
+ "//mojo/core/test:test_support",
+ "//mojo/public/cpp/platform",
+ ]
+ }
-fuzzer_test("mojo_core_port_event_fuzzer") {
- sources = [ "port_event_fuzzer.cc" ]
- deps = [
- ":core_impl_for_fuzzers",
- "//base",
- ]
-}
+ fuzzer_test("mojo_core_port_event_fuzzer") {
+ sources = [ "port_event_fuzzer.cc" ]
+ deps = [
+ ":core_impl_for_fuzzers",
+ "//base",
+ ]
+ }
-fuzzer_test("mojo_core_user_message_fuzzer") {
- sources = [ "user_message_fuzzer.cc" ]
- deps = [
- ":core_impl_for_fuzzers",
- "//base",
- ]
+ fuzzer_test("mojo_core_user_message_fuzzer") {
+ sources = [ "user_message_fuzzer.cc" ]
+ deps = [
+ ":core_impl_for_fuzzers",
+ "//base",
+ ]
+ }
+
+ if (is_mac) {
+ fuzzer_test("mojo_core_channel_mac_fuzzer") {
+ sources = [ "channel_mac_fuzzer.cc" ]
+ seed_corpus = "$target_gen_dir/mojo_core_channel_mac_corpus"
+ seed_corpus_deps = [ ":mojo_core_channel_mac_fuzzer_convert_corpus" ]
+ deps = [
+ ":core_impl_for_fuzzers",
+ "test:channel_mac_proto",
+ "//base",
+ "//base/test:test_support",
+ "//testing/libfuzzer/fuzzers/mach:converter",
+ "//third_party/libprotobuf-mutator",
+ ]
+ }
+ }
}
diff --git a/mojo/core/channel.cc b/mojo/core/channel.cc
index eed34c1..2bc8cf5 100644
--- a/mojo/core/channel.cc
+++ b/mojo/core/channel.cc
@@ -31,7 +31,6 @@
#include "base/trace_event/typed_macros.h"
#include "build/build_config.h"
#include "mojo/core/configuration.h"
-#include "mojo/core/core.h"
#include "mojo/core/embedder/features.h"
#if BUILDFLAG(MOJO_USE_APPLE_CHANNEL)
diff --git a/mojo/core/channel_linux.cc b/mojo/core/channel_linux.cc
index 46c7c08d..7131c6a 100644
--- a/mojo/core/channel_linux.cc
+++ b/mojo/core/channel_linux.cc
@@ -43,7 +43,7 @@
#include "base/task/task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
-#include "mojo/core/core.h"
+#include "mojo/buildflags.h"
#include "mojo/core/embedder/features.h"
#if BUILDFLAG(IS_ANDROID)
diff --git a/mojo/core/embedder/embedder.cc b/mojo/core/embedder/embedder.cc
index cb63cd8..41f49bb2 100644
--- a/mojo/core/embedder/embedder.cc
+++ b/mojo/core/embedder/embedder.cc
@@ -6,32 +6,37 @@
#include <stdint.h>
-#include <atomic>
#include <optional>
#include <string>
#include <utility>
#include "base/check.h"
-#include "base/environment.h"
#include "base/feature_list.h"
#include "base/memory/ref_counted.h"
+#include "base/notreached.h"
#include "base/task/single_thread_task_runner.h"
#include "base/task/task_runner.h"
#include "build/build_config.h"
#include "mojo/buildflags.h"
#include "mojo/core/channel.h"
#include "mojo/core/configuration.h"
-#include "mojo/core/core.h"
#include "mojo/core/core_ipcz.h"
#include "mojo/core/embedder/features.h"
-#include "mojo/core/entrypoints.h"
#include "mojo/core/ipcz_api.h"
#include "mojo/core/ipcz_driver/base_shared_memory_service.h"
#include "mojo/core/ipcz_driver/driver.h"
#include "mojo/core/ipcz_driver/transport.h"
-#include "mojo/core/node_controller.h"
#include "mojo/public/c/system/thunks.h"
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
+#include <atomic>
+
+#include "base/environment.h"
+#include "mojo/core/core.h"
+#include "mojo/core/entrypoints.h"
+#include "mojo/core/node_controller.h"
+#endif
+
#if !BUILDFLAG(IS_NACL)
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || BUILDFLAG(IS_ANDROID)
#include "mojo/core/channel_linux.h"
@@ -43,15 +48,15 @@
namespace {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
#if BUILDFLAG(IS_CHROMEOS) && !defined(ENABLE_IPCZ_ON_CHROMEOS)
std::atomic<bool> g_mojo_ipcz_enabled{false};
-#else
+#elif !BUILDFLAG(IS_ANDROID)
// Default to enabled even if InitFeatures() is never called.
std::atomic<bool> g_mojo_ipcz_enabled{true};
#endif
bool g_mojo_ipcz_force_disabled = false;
-bool g_enable_memv2 = false;
std::optional<std::string> GetMojoIpczEnvVar() {
std::string value;
@@ -69,6 +74,9 @@
static bool force_enabled = GetMojoIpczEnvVar() == "1";
return force_enabled;
}
+#endif // BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
+
+bool g_enable_memv2 = false;
} // namespace
@@ -102,27 +110,35 @@
Channel::set_use_trivial_messages(
base::FeatureList::IsEnabled(kMojoInlineMessagePayloads));
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
if (base::FeatureList::IsEnabled(kMojoIpcz)) {
EnableMojoIpcz();
} else {
g_mojo_ipcz_enabled.store(false, std::memory_order_release);
}
+#endif // !BUILDFLAG(IS_ANDROID)
g_enable_memv2 = base::FeatureList::IsEnabled(kMojoIpczMemV2);
}
void EnableMojoIpcz() {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
g_mojo_ipcz_enabled.store(true, std::memory_order_release);
+#endif
}
void Init(const Configuration& configuration) {
internal::g_configuration = configuration;
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
if (configuration.disable_ipcz) {
// Allow the caller to override MojoIpcz even when enabled by Feature or
// environment.
g_mojo_ipcz_force_disabled = true;
}
+#else
+ CHECK(!configuration.disable_ipcz);
+#endif
if (IsMojoIpczEnabled()) {
CHECK(InitializeIpczNodeForProcess({
@@ -134,8 +150,12 @@
}));
MojoEmbedderSetSystemThunks(GetMojoIpczImpl());
} else {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
InitializeCore();
MojoEmbedderSetSystemThunks(&GetSystemThunks());
+#else
+ NOTREACHED_NORETURN();
+#endif
}
}
@@ -147,7 +167,11 @@
if (IsMojoIpczEnabled()) {
DestroyIpczNodeForProcess();
} else {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
ShutDownCore();
+#else
+ NOTREACHED_NORETURN();
+#endif
}
}
@@ -155,11 +179,18 @@
if (IsMojoIpczEnabled()) {
return ipcz_driver::Transport::GetIOTaskRunner();
} else {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
return Core::Get()->GetNodeController()->io_task_runner();
+#else
+ NOTREACHED_NORETURN();
+#endif
}
}
bool IsMojoIpczEnabled() {
+#if !BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
+ return true;
+#else
// Because Mojo and FeatureList are both brought up early in many binaries, it
// can be tricky to ensure there aren't races that would lead to two different
// Mojo implementations being selected at different points throughout the
@@ -173,6 +204,7 @@
static bool enabled_on_first_call = enabled;
DCHECK_EQ(enabled, enabled_on_first_call);
return enabled;
+#endif
}
void InstallMojoIpczBaseSharedMemoryHooks() {
diff --git a/mojo/core/embedder/features.cc b/mojo/core/embedder/features.cc
index b9f25d0..3909ef5 100644
--- a/mojo/core/embedder/features.cc
+++ b/mojo/core/embedder/features.cc
@@ -33,11 +33,13 @@
"MojoInlineMessagePayloads",
base::FEATURE_DISABLED_BY_DEFAULT);
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
#if BUILDFLAG(IS_CHROMEOS)
BASE_FEATURE(kMojoIpcz, "MojoIpcz", base::FEATURE_DISABLED_BY_DEFAULT);
#else
BASE_FEATURE(kMojoIpcz, "MojoIpcz", base::FEATURE_ENABLED_BY_DEFAULT);
#endif
+#endif // BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
BASE_FEATURE(kMojoIpczMemV2,
"MojoIpczMemV2",
diff --git a/mojo/core/embedder/features.h b/mojo/core/embedder/features.h
index ec4b14a5..0677c8a 100644
--- a/mojo/core/embedder/features.h
+++ b/mojo/core/embedder/features.h
@@ -37,7 +37,9 @@
COMPONENT_EXPORT(MOJO_CORE_EMBEDDER_FEATURES)
BASE_DECLARE_FEATURE(kMojoInlineMessagePayloads);
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
COMPONENT_EXPORT(MOJO_CORE_EMBEDDER_FEATURES) BASE_DECLARE_FEATURE(kMojoIpcz);
+#endif
COMPONENT_EXPORT(MOJO_CORE_EMBEDDER_FEATURES)
BASE_DECLARE_FEATURE(kMojoIpczMemV2);
diff --git a/mojo/core/embedder/scoped_ipc_support.cc b/mojo/core/embedder/scoped_ipc_support.cc
index 31266ed8..89a6098 100644
--- a/mojo/core/embedder/scoped_ipc_support.cc
+++ b/mojo/core/embedder/scoped_ipc_support.cc
@@ -6,21 +6,27 @@
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
+#include "base/notreached.h"
#include "base/synchronization/waitable_event.h"
#include "base/task/single_thread_task_runner.h"
#include "base/threading/thread_restrictions.h"
-#include "mojo/core/core.h"
+#include "mojo/buildflags.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/ipcz_driver/transport.h"
-namespace mojo {
-namespace core {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
+#include "mojo/core/core.h"
+#endif
+
+namespace mojo::core {
namespace {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
void ShutdownIPCSupport(base::OnceClosure callback) {
Core::Get()->RequestShutdown(std::move(callback));
}
+#endif
} // namespace
@@ -29,9 +35,11 @@
ShutdownPolicy shutdown_policy)
: shutdown_policy_(shutdown_policy) {
ipcz_driver::Transport::SetIOTaskRunner(io_thread_task_runner);
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
if (!IsMojoIpczEnabled()) {
Core::Get()->SetIOTaskRunner(std::move(io_thread_task_runner));
}
+#endif
}
ScopedIPCSupport::~ScopedIPCSupport() {
@@ -40,6 +48,7 @@
return;
}
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
if (shutdown_policy_ == ShutdownPolicy::FAST) {
ShutdownIPCSupport(base::DoNothing());
return;
@@ -53,7 +62,9 @@
base::ScopedAllowBaseSyncPrimitives allow_io;
shutdown_event.Wait();
+#else
+ NOTREACHED_NORETURN();
+#endif
}
-} // namespace core
-} // namespace mojo
+} // namespace mojo::core
diff --git a/mojo/core/embedder_unittest.cc b/mojo/core/embedder_unittest.cc
index 9834b81..5840e71d 100644
--- a/mojo/core/embedder_unittest.cc
+++ b/mojo/core/embedder_unittest.cc
@@ -23,6 +23,7 @@
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/unsafe_shared_memory_region.h"
#include "base/memory/writable_shared_memory_region.h"
+#include "base/notreached.h"
#include "base/path_service.h"
#include "base/rand_util.h"
#include "base/run_loop.h"
@@ -30,10 +31,9 @@
#include "base/synchronization/waitable_event.h"
#include "base/test/test_timeouts.h"
#include "build/build_config.h"
-#include "mojo/core/core.h"
+#include "mojo/buildflags.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/ipcz_driver/shared_buffer.h"
-#include "mojo/core/shared_buffer_dispatcher.h"
#include "mojo/core/test/mojo_test_base.h"
#include "mojo/public/c/system/core.h"
#include "mojo/public/cpp/system/handle.h"
@@ -42,8 +42,12 @@
#include "mojo/public/cpp/system/wait.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace mojo {
-namespace core {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
+#include "mojo/core/core.h"
+#include "mojo/core/shared_buffer_dispatcher.h"
+#endif
+
+namespace mojo::core {
namespace {
template <typename T>
@@ -54,6 +58,7 @@
return MOJO_RESULT_OK;
}
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
scoped_refptr<SharedBufferDispatcher> buffer;
MojoResult result =
SharedBufferDispatcher::CreateFromPlatformSharedMemoryRegion(
@@ -63,6 +68,9 @@
*handle = Core::Get()->AddDispatcher(std::move(buffer));
return MOJO_RESULT_OK;
+#else
+ NOTREACHED_NORETURN();
+#endif
}
template <typename T>
@@ -72,6 +80,7 @@
platform_region =
std::move(ipcz_driver::SharedBuffer::Unbox(handle)->region());
} else {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
scoped_refptr<Dispatcher> dispatcher =
Core::Get()->GetAndRemoveDispatcher(handle);
if (!dispatcher || dispatcher->GetType() != Dispatcher::Type::SHARED_BUFFER)
@@ -79,6 +88,9 @@
auto* buffer = static_cast<SharedBufferDispatcher*>(dispatcher.get());
platform_region = buffer->PassPlatformSharedMemoryRegion();
+#else
+ NOTREACHED_NORETURN();
+#endif
}
*region = T::Deserialize(std::move(platform_region));
@@ -446,5 +458,4 @@
#endif // !BUILDFLAG(IS_IOS)
} // namespace
-} // namespace core
-} // namespace mojo
+} // namespace mojo::core
diff --git a/mojo/core/invitation_unittest.cc b/mojo/core/invitation_unittest.cc
index 7a890120..f0952e0 100644
--- a/mojo/core/invitation_unittest.cc
+++ b/mojo/core/invitation_unittest.cc
@@ -38,10 +38,8 @@
#include "base/test/task_environment.h"
#include "build/build_config.h"
#include "mojo/buildflags.h"
-#include "mojo/core/core.h"
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/ipcz_api.h"
-#include "mojo/core/node_controller.h"
#include "mojo/core/test/mojo_test_base.h"
#include "mojo/core/test/test_switches.h"
#include "mojo/public/cpp/platform/named_platform_channel.h"
@@ -50,6 +48,11 @@
#include "mojo/public/cpp/system/message_pipe.h"
#include "mojo/public/cpp/system/platform_handle.h"
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
+#include "mojo/core/core.h"
+#include "mojo/core/node_controller.h"
+#endif
+
#if BUILDFLAG(MOJO_USE_APPLE_CHANNEL)
#include "base/mac/mach_port_rendezvous.h"
#endif
@@ -656,6 +659,7 @@
EXPECT_EQ(MOJO_RESULT_OK, MojoClose(pipe));
}
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
// Temporary removed support for reinvitation for non-isolated connections.
TEST_F(MAYBE_InvitationTest, DISABLED_Reinvitation) {
// The gist of this test is that a process should be able to accept an
@@ -705,6 +709,7 @@
WaitForProcessToTerminate(child_process);
}
+#endif // BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
DEFINE_TEST_CLIENT(ReinvitationClient) {
MojoHandle invitation = AcceptInvitation(MOJO_ACCEPT_INVITATION_FLAG_NONE);
diff --git a/mojo/core/ipcz_driver/transport.cc b/mojo/core/ipcz_driver/transport.cc
index 1a3882e..d239377f 100644
--- a/mojo/core/ipcz_driver/transport.cc
+++ b/mojo/core/ipcz_driver/transport.cc
@@ -20,7 +20,6 @@
#include "base/process/process.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
-#include "mojo/core/core.h"
#include "mojo/core/ipcz_driver/data_pipe.h"
#include "mojo/core/ipcz_driver/invitation.h"
#include "mojo/core/ipcz_driver/object.h"
diff --git a/mojo/core/message_unittest.cc b/mojo/core/message_unittest.cc
index 2d6639b..e586642f 100644
--- a/mojo/core/message_unittest.cc
+++ b/mojo/core/message_unittest.cc
@@ -23,18 +23,26 @@
#include "mojo/core/embedder/embedder.h"
#include "mojo/core/ipcz_driver/mojo_message.h"
#include "mojo/core/test/mojo_test_base.h"
-#include "mojo/core/user_message_impl.h"
#include "mojo/public/cpp/platform/platform_channel.h"
#include "mojo/public/cpp/system/buffer.h"
#include "mojo/public/cpp/system/message_pipe.h"
#include "mojo/public/cpp/system/platform_handle.h"
-namespace mojo {
-namespace core {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
+#include "mojo/core/user_message_impl.h"
+#endif
+
+namespace mojo::core {
namespace {
using MessageTest = test::MojoTestBase;
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
+constexpr uint32_t kLegacyMinimumPayloadBufferSize = kMinimumPayloadBufferSize;
+#else
+constexpr uint32_t kLegacyMinimumPayloadBufferSize = 0;
+#endif
+
// Helper class which provides a base implementation for an unserialized user
// message context and helpers to go between these objects and opaque message
// handles.
@@ -707,7 +715,7 @@
// `kMinimumBufferSize` bytes of capacity will be allocated).
const size_t kMinimumBufferSize =
IsMojoIpczEnabled() ? ipcz_driver::MojoMessage::kMinBufferSize
- : kMinimumPayloadBufferSize;
+ : kLegacyMinimumPayloadBufferSize;
const std::string kMsgPart1(kMinimumBufferSize / 2, 'x');
const std::string kMsgPart2(kMinimumBufferSize, 'y');
const std::string kCombined = kMsgPart1 + kMsgPart2;
@@ -775,7 +783,7 @@
// `kMinimumBufferSize` bytes of capacity will be allocated).
const size_t kMinimumBufferSize =
IsMojoIpczEnabled() ? ipcz_driver::MojoMessage::kMinBufferSize
- : kMinimumPayloadBufferSize;
+ : kLegacyMinimumPayloadBufferSize;
const std::string kMsgPart1(kMinimumBufferSize / 2, 'x');
const std::string kMsgPart2(kMinimumBufferSize, 'y');
const std::string kCombined = kMsgPart1 + kMsgPart2;
@@ -985,6 +993,7 @@
EXPECT_EQ(MOJO_RESULT_OK, MojoDestroyMessage(message));
}
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
TEST_F(MessageTest, CommitInvalidMessageContents) {
// Regression test for https://crbug.com/755127. Ensures that we don't crash
// if we attempt to commit the contents of an unserialized message.
@@ -1007,6 +1016,7 @@
EXPECT_EQ(MOJO_RESULT_OK, MojoDestroyMessage(message));
EXPECT_EQ(MOJO_RESULT_OK, MojoClose(b));
}
+#endif // BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
#if BUILDFLAG(USE_BLINK)
@@ -1173,5 +1183,4 @@
}
} // namespace
-} // namespace core
-} // namespace mojo
+} // namespace mojo::core
diff --git a/mojo/core/ports/BUILD.gn b/mojo/core/ports/BUILD.gn
index 40aa1c3..9c459b51 100644
--- a/mojo/core/ports/BUILD.gn
+++ b/mojo/core/ports/BUILD.gn
@@ -3,8 +3,12 @@
# found in the LICENSE file.
import("//build/config/compiler/compiler.gni")
+import("//mojo/features.gni")
import("//testing/test.gni")
+# Only legacy Mojo Core and its tests can depend on targets here.
+assert(mojo_support_legacy_core)
+
component("ports") {
output_name = "mojo_core_ports"
diff --git a/mojo/core/shared_buffer_unittest.cc b/mojo/core/shared_buffer_unittest.cc
index 3f13b3f7..252ae85 100644
--- a/mojo/core/shared_buffer_unittest.cc
+++ b/mojo/core/shared_buffer_unittest.cc
@@ -2,24 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "mojo/core/ipcz_driver/shared_buffer.h"
+
#include <string.h>
#include <string>
#include <utility>
#include "base/memory/platform_shared_memory_region.h"
+#include "base/notreached.h"
#include "build/blink_buildflags.h"
#include "build/build_config.h"
-#include "mojo/core/core.h"
#include "mojo/core/embedder/embedder.h"
-#include "mojo/core/ipcz_driver/shared_buffer.h"
-#include "mojo/core/shared_buffer_dispatcher.h"
#include "mojo/core/test/mojo_test_base.h"
#include "mojo/public/c/system/types.h"
#include "testing/gtest/include/gtest/gtest.h"
-namespace mojo {
-namespace core {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
+#include "mojo/core/core.h"
+#include "mojo/core/shared_buffer_dispatcher.h"
+#endif
+
+namespace mojo::core {
namespace {
using SharedBufferTest = test::MojoTestBase;
@@ -290,6 +294,7 @@
EXPECT_EQ(buffer->region().GetMode(),
base::subtle::PlatformSharedMemoryRegion::Mode::kReadOnly);
} else {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
auto* dispatcher = static_cast<SharedBufferDispatcher*>(
Core::Get()->GetDispatcher(b).get());
base::subtle::PlatformSharedMemoryRegion& region =
@@ -297,6 +302,9 @@
EXPECT_EQ(region.GetMode(),
base::subtle::PlatformSharedMemoryRegion::Mode::kReadOnly);
EXPECT_EQ(MOJO_RESULT_OK, MojoClose(b));
+#else
+ NOTREACHED_NORETURN();
+#endif
}
WriteMessage(h, "ok");
@@ -363,6 +371,7 @@
EXPECT_EQ(buffer->region().GetMode(),
base::subtle::PlatformSharedMemoryRegion::Mode::kReadOnly);
} else {
+#if BUILDFLAG(MOJO_SUPPORT_LEGACY_CORE)
auto* dispatcher = static_cast<SharedBufferDispatcher*>(
Core::Get()->GetDispatcher(b).get());
base::subtle::PlatformSharedMemoryRegion& region =
@@ -370,6 +379,9 @@
EXPECT_EQ(region.GetMode(),
base::subtle::PlatformSharedMemoryRegion::Mode::kReadOnly);
EXPECT_EQ(MOJO_RESULT_OK, MojoClose(b));
+#else
+ NOTREACHED_NORETURN();
+#endif
}
EXPECT_EQ("ok", ReadMessage(h));
@@ -380,5 +392,4 @@
#endif // BUILDFLAG(USE_BLINK)
} // namespace
-} // namespace core
-} // namespace mojo
+} // namespace mojo::core
diff --git a/mojo/core/test/BUILD.gn b/mojo/core/test/BUILD.gn
index 09caedc..9f5915c5 100644
--- a/mojo/core/test/BUILD.gn
+++ b/mojo/core/test/BUILD.gn
@@ -3,13 +3,12 @@
# found in the LICENSE file.
import("//build/config/features.gni")
+import("//mojo/features.gni")
import("//third_party/protobuf/proto_library.gni")
static_library("test_support") {
testonly = true
sources = [
- "mock_node_channel_delegate.cc",
- "mock_node_channel_delegate.h",
"mojo_test_base.cc",
"mojo_test_base.h",
"mojo_test_suite_base.cc",
@@ -21,6 +20,13 @@
"test_utils.h",
]
+ if (mojo_support_legacy_core) {
+ sources += [
+ "mock_node_channel_delegate.cc",
+ "mock_node_channel_delegate.h",
+ ]
+ }
+
if (use_blink) {
sources += [
"multiprocess_test_helper.cc",
diff --git a/mojo/features.gni b/mojo/features.gni
index 8a39caa..ce164c3c 100644
--- a/mojo/features.gni
+++ b/mojo/features.gni
@@ -3,7 +3,20 @@
# found in the LICENSE file.
import("//build/config/features.gni")
+import("//build/config/sanitizers/sanitizers.gni")
declare_args() {
mojo_use_apple_channel = is_mac || (is_ios && use_blink)
+
+ # Builds non-ipcz-based Mojo Core. No longer supported anywhere but Chrome OS.
+ # We check target_os instead of is_chromeos since this also needs to be set
+ # when building NaCl binaries (is_nacl) for Chrome OS.
+ #
+ # When this is true, ipcz-based Mojo Core can be disabled by disabling the
+ # MojoIpcz feature flag; and it's disabled by default on Chrome OS. When this
+ # is false, ipcz-based Mojo Core is used unconditionally.
+ #
+ # We also enable this by default for fuzzer builds, since some active fuzzers
+ # require the legacy implementation.
+ mojo_support_legacy_core = target_os == "chromeos" || use_libfuzzer
}
diff --git a/mojo/proxy/BUILD.gn b/mojo/proxy/BUILD.gn
index e8cd4dec..e0830d5 100644
--- a/mojo/proxy/BUILD.gn
+++ b/mojo/proxy/BUILD.gn
@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
+import("//mojo/features.gni")
import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/test.gni")