Commit 88221a5c authored by erg's avatar erg Committed by Commit bot

core_services: Run different services in different processes.

When mandoline is run with --enable-multiprocess, we should run some
services in different processes. This reuses |qualifier| in
Identity (which is already used for content handlers that need to run in
different contexts) to be a process name in contexts where there is a
package alias. This places mojo:network_services in its own process, and
everything else in a different process.

When run without --enable-multiprocess, this change is a noop.

BUG=477435

Review URL: https://codereview.chromium.org/1126393006

Cr-Commit-Position: refs/heads/master@{#329421}
parent 0a5200b8
......@@ -13,17 +13,17 @@ void InitCoreServicesForContext(mojo::runner::Context* context) {
// autogenerated from package manifests.
mojo::shell::ApplicationManager* manager = context->application_manager();
manager->RegisterApplicationPackageAlias(GURL("mojo:clipboard"),
GURL("mojo:core_services"));
GURL("mojo:core_services"), "Core");
#if !defined(OS_ANDROID)
manager->RegisterApplicationPackageAlias(GURL("mojo:network_service"),
GURL("mojo:core_services"));
manager->RegisterApplicationPackageAlias(
GURL("mojo:network_service"), GURL("mojo:core_services"), "Network");
#endif
manager->RegisterApplicationPackageAlias(GURL("mojo:tracing"),
GURL("mojo:core_services"));
GURL("mojo:core_services"), "Core");
manager->RegisterApplicationPackageAlias(GURL("mojo:view_manager"),
GURL("mojo:core_services"));
GURL("mojo:core_services"), "Core");
manager->RegisterApplicationPackageAlias(GURL("mojo:window_manager"),
GURL("mojo:core_services"));
GURL("mojo:core_services"), "Core");
}
} // namespace mandoline
......@@ -32,6 +32,7 @@
#include "mojo/services/tracing/tracing.mojom.h"
#include "mojo/shell/application_loader.h"
#include "mojo/shell/application_manager.h"
#include "mojo/shell/switches.h"
#include "mojo/util/filename_util.h"
#include "url/gurl.h"
......
......@@ -24,11 +24,6 @@ const char kContentHandlers[] = "content-handlers";
// instructions.
const char kDisableCache[] = "disable-cache";
// Load apps in separate processes.
// TODO(vtl): Work in progress; doesn't work. Flip this to "disable" (or maybe
// change it to "single-process") when it works.
const char kEnableMultiprocess[] = "enable-multiprocess";
// In multiprocess mode, force these apps to be loaded in the main process.
// Comma-separate list of URLs. Example:
// --force-in-process=mojo:native_viewport_service,mojo:network_service
......
......@@ -16,7 +16,6 @@ extern const char kApp[];
extern const char kChildProcess[];
extern const char kContentHandlers[];
extern const char kDisableCache[];
extern const char kEnableMultiprocess[];
extern const char kForceInProcess[];
extern const char kHelp[];
extern const char kMapOrigin[];
......
This diff is collapsed.
......@@ -91,9 +91,13 @@ class ApplicationManager {
// Registers a package alias. When attempting to load |alias|, it will
// instead redirect to |content_handler_package|, which is a content handler
// which will be passed the |alias| as the URLResponse::url.
// which will be passed the |alias| as the URLResponse::url. Different values
// of |alias| with the same |qualifier| that are in the same
// |content_handler_package| will run in the same process in multi-process
// mode.
void RegisterApplicationPackageAlias(const GURL& alias,
const GURL& content_handler_package);
const GURL& content_handler_package,
const std::string& qualifier);
// Sets the default Loader to be used if not overridden by SetLoaderForURL()
// or SetLoaderForScheme().
......@@ -134,16 +138,18 @@ class ApplicationManager {
private:
class ContentHandlerConnection;
using ApplicationPackagedAlias = std::map<GURL, GURL>;
using ApplicationPackagedAlias = std::map<GURL, std::pair<GURL, std::string>>;
using IdentityToShellImplMap = std::map<Identity, ShellImpl*>;
using MimeTypeToURLMap = std::map<std::string, GURL>;
using SchemeToLoaderMap = std::map<std::string, ApplicationLoader*>;
using URLToContentHandlerMap = std::map<GURL, ContentHandlerConnection*>;
using URLToContentHandlerMap =
std::map<std::pair<GURL, std::string>, ContentHandlerConnection*>;
using URLToLoaderMap = std::map<GURL, ApplicationLoader*>;
using URLToNativeOptionsMap = std::map<GURL, NativeRunnerFactory::Options>;
void ConnectToApplicationWithParameters(
const GURL& application_url,
const std::string& qualifier,
const GURL& requestor_url,
InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services,
......@@ -151,12 +157,14 @@ class ApplicationManager {
const std::vector<std::string>& pre_redirect_parameters);
bool ConnectToRunningApplication(const GURL& resolved_url,
const std::string& qualifier,
const GURL& requestor_url,
InterfaceRequest<ServiceProvider>* services,
ServiceProviderPtr* exposed_services);
bool ConnectToApplicationWithLoader(
const GURL& requested_url,
const std::string& qualifier,
const GURL& resolved_url,
const GURL& requestor_url,
InterfaceRequest<ServiceProvider>* services,
......@@ -167,13 +175,14 @@ class ApplicationManager {
InterfaceRequest<Application> RegisterShell(
const GURL& app_url,
const std::string& qualifier,
const GURL& requestor_url,
InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services,
const base::Closure& on_application_end,
const std::vector<std::string>& parameters);
ShellImpl* GetShellImpl(const GURL& url);
ShellImpl* GetShellImpl(const GURL& url, const std::string& qualifier);
void ConnectToClient(ShellImpl* shell_impl,
const GURL& resolved_url,
......@@ -184,6 +193,7 @@ class ApplicationManager {
// Called once |fetcher| has found app. |requested_url| is the url of the
// requested application before any mappings/resolution have been applied.
void HandleFetchCallback(const GURL& requested_url,
const std::string& qualifier,
const GURL& requestor_url,
InterfaceRequest<ServiceProvider> services,
ServiceProviderPtr exposed_services,
......@@ -200,6 +210,7 @@ class ApplicationManager {
bool path_exists);
void LoadWithContentHandler(const GURL& content_handler_url,
const std::string& qualifier,
InterfaceRequest<Application> application_request,
URLResponsePtr url_response);
......
......@@ -10,7 +10,8 @@ namespace mojo {
namespace shell {
Identity::Identity(const GURL& url, const std::string& qualifier)
: url(GetBaseURLAndQuery(url, nullptr)), qualifier(qualifier) {
: url(GetBaseURLAndQuery(url, nullptr)),
qualifier(qualifier.empty() ? url.spec() : qualifier) {
}
// explicit
......
......@@ -11,6 +11,11 @@ namespace switches {
// If set apps downloaded are not deleted.
const char kDontDeleteOnDownload[] = "dont-delete-on-download";
// Load apps in separate processes.
// TODO(vtl): Work in progress; doesn't work. Flip this to "disable" (or maybe
// change it to "single-process") when it works.
const char kEnableMultiprocess[] = "enable-multiprocess";
// If set apps downloaded are saved in with a predictable filename, to help
// remote debugging: when gdb is used through gdbserver, it needs to be able to
// find locally any loaded library. For this, gdb use the filename of the
......
......@@ -13,6 +13,7 @@ namespace switches {
// All switches in alphabetical order. The switches should be documented
// alongside the definition of their values in the .cc file.
extern const char kDontDeleteOnDownload[];
extern const char kEnableMultiprocess[];
extern const char kPredictableAppFilenames[];
} // namespace switches
......
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