Commit 9da5790e authored by Krzysztof Olczyk's avatar Krzysztof Olczyk Committed by Commit Bot

Fix a DCHECK when starting single-process with mojo core lib.

When Chromium is started with dynamic more core lib
(--mojo-core-library-path=path_to_lib), the given library
is used for core mojo functionality instead of the mojo core
embedded in the Chromium.

This switch is propagated to child processes (such as gpu process)
in order for them to use the same mojo core library.
Due to sandboxes, the library is loaded early for child processes
and initialized in a separate step.

However, if single process mode is used (--single-process)
the ChildProcess class is instantiated in a thread of browser process.

This results in a library being loaded twice and an adequate DCHECK.

Don't attempt to load the mojo core library if ChildProcess instance
is run embedded in the browser process.

Change-Id: Ic22d612481b62ccc6b1d07fa245b56bde55e42d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2517460Reviewed-by: default avatarKen Rockot <rockot@google.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Krzysztof Olczyk <kolczyk@vewd.com>
Cr-Commit-Position: refs/heads/master@{#823602}
parent 1923eb91
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "content/child/child_thread_impl.h" #include "content/child/child_thread_impl.h"
#include "content/common/android/cpu_time_metrics.h" #include "content/common/android/cpu_time_metrics.h"
#include "content/common/mojo_core_library_support.h" #include "content/common/mojo_core_library_support.h"
#include "content/public/common/content_switches.h"
#include "mojo/public/cpp/system/dynamic_library_support.h" #include "mojo/public/cpp/system/dynamic_library_support.h"
#include "sandbox/policy/sandbox_type.h" #include "sandbox/policy/sandbox_type.h"
#include "services/tracing/public/cpp/trace_startup.h" #include "services/tracing/public/cpp/trace_startup.h"
...@@ -54,7 +55,9 @@ ChildProcess::ChildProcess(base::ThreadPriority io_thread_priority, ...@@ -54,7 +55,9 @@ ChildProcess::ChildProcess(base::ThreadPriority io_thread_priority,
#if defined(OS_LINUX) || defined(OS_CHROMEOS) #if defined(OS_LINUX) || defined(OS_CHROMEOS)
const base::CommandLine& command_line = const base::CommandLine& command_line =
*base::CommandLine::ForCurrentProcess(); *base::CommandLine::ForCurrentProcess();
if (IsMojoCoreSharedLibraryEnabled()) { const bool is_embedded_in_browser_process =
!command_line.HasSwitch(switches::kProcessType);
if (IsMojoCoreSharedLibraryEnabled() && !is_embedded_in_browser_process) {
// If we're in a child process on Linux and dynamic Mojo Core is in use, we // If we're in a child process on Linux and dynamic Mojo Core is in use, we
// expect early process startup code (see ContentMainRunnerImpl::Run()) to // expect early process startup code (see ContentMainRunnerImpl::Run()) to
// have already loaded the library via |mojo::LoadCoreLibrary()|, rendering // have already loaded the library via |mojo::LoadCoreLibrary()|, rendering
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment