From ebfb6860457a2e76d6f1290a3f4831577aa4bdd7 Mon Sep 17 00:00:00 2001 From: erg Date: Fri, 16 Oct 2015 13:45:02 -0700 Subject: mandoline: Actually use mojo:tracing from core_services. We previously made an application connection to tracing.mojo so we never connected to the tracing app bundled into mojo:core_services. This changes the timing so that we call a user supplied function to make customizations to the package manager so that we can set a redirect for mojo:tracing before invoking it, but still performing this after we initialize the EDK. BUG=534895 Review URL: https://codereview.chromium.org/1404353002 Cr-Commit-Position: refs/heads/master@{#354586} --- components/web_view/test_runner/BUILD.gn | 2 + .../web_view/test_runner/register_local_aliases.cc | 14 +++++++ mandoline/app/android/BUILD.gn | 3 +- mandoline/app/android/mandoline_context_init.cc | 2 - mandoline/app/core_services_initialization.cc | 49 ---------------------- mandoline/app/core_services_initialization.h | 21 ---------- mandoline/app/desktop/BUILD.gn | 3 +- mandoline/app/desktop/launcher_process.cc | 2 - mandoline/app/register_local_aliases.cc | 48 +++++++++++++++++++++ mojo/runner/BUILD.gn | 17 ++++++++ mojo/runner/context.cc | 3 ++ mojo/runner/register_local_aliases.cc | 13 ++++++ mojo/runner/register_local_aliases.h | 20 +++++++++ 13 files changed, 121 insertions(+), 76 deletions(-) create mode 100644 components/web_view/test_runner/register_local_aliases.cc delete mode 100644 mandoline/app/core_services_initialization.cc delete mode 100644 mandoline/app/core_services_initialization.h create mode 100644 mandoline/app/register_local_aliases.cc create mode 100644 mojo/runner/register_local_aliases.cc create mode 100644 mojo/runner/register_local_aliases.h diff --git a/components/web_view/test_runner/BUILD.gn b/components/web_view/test_runner/BUILD.gn index 6ae3da7..96434bf 100644 --- a/components/web_view/test_runner/BUILD.gn +++ b/components/web_view/test_runner/BUILD.gn @@ -13,6 +13,7 @@ executable("test_runner") { "launcher.cc", "launcher.h", "main.cc", + "register_local_aliases.cc", ] deps = [ @@ -21,6 +22,7 @@ executable("test_runner") { "//mojo/common", "//mojo/environment:chromium", "//mojo/runner:lib", + "//mojo/runner:register_local_aliases_fwd", "//url", ] diff --git a/components/web_view/test_runner/register_local_aliases.cc b/components/web_view/test_runner/register_local_aliases.cc new file mode 100644 index 0000000..add0a51 --- /dev/null +++ b/components/web_view/test_runner/register_local_aliases.cc @@ -0,0 +1,14 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/runner/register_local_aliases.h" + +namespace mojo { +namespace runner { + +void RegisterLocalAliases(mojo::package_manager::PackageManagerImpl* manager) { +} + +} // namespace runner +} // namespace mojo diff --git a/mandoline/app/android/BUILD.gn b/mandoline/app/android/BUILD.gn index 3823c04..d986ec3 100644 --- a/mandoline/app/android/BUILD.gn +++ b/mandoline/app/android/BUILD.gn @@ -27,11 +27,12 @@ executable("mandoline_runner") { "//mojo/package_manager", "//mojo/runner:lib", "//mojo/runner:mojo_runner_lib", + "//mojo/runner:register_local_aliases_fwd", "//mojo/shell", ] sources = [ - "../core_services_initialization.cc", + "../register_local_aliases.cc", "mandoline_activity.cc", "mandoline_context_init.cc", ] diff --git a/mandoline/app/android/mandoline_context_init.cc b/mandoline/app/android/mandoline_context_init.cc index bdbdb83..fa60c9ce 100644 --- a/mandoline/app/android/mandoline_context_init.cc +++ b/mandoline/app/android/mandoline_context_init.cc @@ -5,14 +5,12 @@ #include "base/bind.h" #include "base/logging.h" #include "base/message_loop/message_loop.h" -#include "mandoline/app/core_services_initialization.h" #include "mojo/runner/context.h" namespace mojo { namespace runner { void InitContext(Context* context) { - mandoline::InitCoreServicesForContext(context); base::MessageLoopForUI::current()->PostTask( FROM_HERE, base::Bind(&Context::Run, diff --git a/mandoline/app/core_services_initialization.cc b/mandoline/app/core_services_initialization.cc deleted file mode 100644 index b56343d..0000000 --- a/mandoline/app/core_services_initialization.cc +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "mandoline/app/core_services_initialization.h" - -#include "mojo/package_manager/package_manager_impl.h" -#include "mojo/runner/context.h" - -namespace mandoline { - -void InitCoreServicesForContext(mojo::runner::Context* context) { - // TODO(erg): We should probably handle this differently; these could be - // autogenerated from package manifests. - mojo::package_manager::PackageManagerImpl* manager = - context->package_manager(); - manager->RegisterApplicationPackageAlias( - GURL("mojo:clipboard"), GURL("mojo:core_services"), "Core"); - manager->RegisterApplicationPackageAlias(GURL("mojo:filesystem"), - GURL("mojo:core_services"), "Files"); -#if defined(OS_LINUX) && !defined(OS_ANDROID) - manager->RegisterApplicationPackageAlias(GURL("mojo:font_service"), - GURL("mojo:core_services"), "Files"); -#endif -#if !defined(OS_ANDROID) - // On Android, these are Java apps which are loaded in the shell process. - manager->RegisterApplicationPackageAlias(GURL("mojo:mus"), - GURL("mojo:core_services"), - "Surfaces"); - manager->RegisterApplicationPackageAlias( - GURL("mojo:network_service"), GURL("mojo:core_services"), "Network"); - manager->RegisterApplicationPackageAlias( - GURL("mojo:resource_provider"), GURL("mojo:core_services"), "Files"); -#endif - -#if defined(USE_AURA) - manager->RegisterApplicationPackageAlias(GURL("mojo:desktop_ui"), - GURL("mojo:core_services"), - "Core"); - manager->RegisterApplicationPackageAlias( - GURL("mojo:omnibox"), GURL("mojo:core_services"), "Core"); -#endif - manager->RegisterApplicationPackageAlias( - GURL("mojo:web_view"), GURL("mojo:core_services"), "Core"); - manager->RegisterApplicationPackageAlias( - GURL("mojo:tracing"), GURL("mojo:core_services"), "Core"); -} - -} // namespace mandoline diff --git a/mandoline/app/core_services_initialization.h b/mandoline/app/core_services_initialization.h deleted file mode 100644 index e8601de..0000000 --- a/mandoline/app/core_services_initialization.h +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef MANDOLINE_APP_CORE_SERVICES_INITIALIZATION_H_ -#define MANDOLINE_APP_CORE_SERVICES_INITIALIZATION_H_ - -namespace mojo { -namespace runner { -class Context; -} -} - -namespace mandoline { - -// Sets up the aliases that forward applications to core_services. -void InitCoreServicesForContext(mojo::runner::Context* context); - -} // namespace mandoline - -#endif // MANDOLINE_APP_CORE_SERVICES_INITIALIZATION_H_ diff --git a/mandoline/app/desktop/BUILD.gn b/mandoline/app/desktop/BUILD.gn index 6860a0d..d72fb60 100644 --- a/mandoline/app/desktop/BUILD.gn +++ b/mandoline/app/desktop/BUILD.gn @@ -10,7 +10,7 @@ group("desktop") { executable("mandoline") { sources = [ - "../core_services_initialization.cc", + "../register_local_aliases.cc", "launcher_process.cc", "launcher_process.h", "main.cc", @@ -24,6 +24,7 @@ executable("mandoline") { "//mojo/environment:chromium", "//mojo/package_manager", "//mojo/runner:lib", + "//mojo/runner:register_local_aliases_fwd", ] data_deps = [ diff --git a/mandoline/app/desktop/launcher_process.cc b/mandoline/app/desktop/launcher_process.cc index 34e4435..2424045 100644 --- a/mandoline/app/desktop/launcher_process.cc +++ b/mandoline/app/desktop/launcher_process.cc @@ -18,7 +18,6 @@ #include "base/trace_event/trace_event.h" #include "components/tracing/trace_config_file.h" #include "components/tracing/tracing_switches.h" -#include "mandoline/app/core_services_initialization.h" #include "mandoline/app/desktop/launcher_process.h" #include "mojo/runner/context.h" #include "mojo/runner/switches.h" @@ -108,7 +107,6 @@ int LauncherProcessMain(int argc, char** argv) { if (!shell_context.Init()) { return 0; } - InitCoreServicesForContext(&shell_context); if (g_tracing) { message_loop.PostDelayedTask(FROM_HERE, base::Bind(StopTracingAndFlushToDisk), diff --git a/mandoline/app/register_local_aliases.cc b/mandoline/app/register_local_aliases.cc new file mode 100644 index 0000000..f71abfa --- /dev/null +++ b/mandoline/app/register_local_aliases.cc @@ -0,0 +1,48 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/runner/register_local_aliases.h" + +#include "mojo/package_manager/package_manager_impl.h" + +namespace mojo { +namespace runner { + +void RegisterLocalAliases(mojo::package_manager::PackageManagerImpl* manager) { + // TODO(erg): We should probably handle this differently; these could be + // autogenerated from package manifests. + manager->RegisterApplicationPackageAlias( + GURL("mojo:clipboard"), GURL("mojo:core_services"), "Core"); + manager->RegisterApplicationPackageAlias(GURL("mojo:filesystem"), + GURL("mojo:core_services"), "Files"); +#if defined(OS_LINUX) && !defined(OS_ANDROID) + manager->RegisterApplicationPackageAlias(GURL("mojo:font_service"), + GURL("mojo:core_services"), "Files"); +#endif +#if !defined(OS_ANDROID) + // On Android, these are Java apps which are loaded in the shell process. + manager->RegisterApplicationPackageAlias(GURL("mojo:mus"), + GURL("mojo:core_services"), + "Surfaces"); + manager->RegisterApplicationPackageAlias( + GURL("mojo:network_service"), GURL("mojo:core_services"), "Network"); + manager->RegisterApplicationPackageAlias( + GURL("mojo:resource_provider"), GURL("mojo:core_services"), "Files"); +#endif + +#if defined(USE_AURA) + manager->RegisterApplicationPackageAlias(GURL("mojo:desktop_ui"), + GURL("mojo:core_services"), + "Core"); + manager->RegisterApplicationPackageAlias( + GURL("mojo:omnibox"), GURL("mojo:core_services"), "Core"); +#endif + manager->RegisterApplicationPackageAlias( + GURL("mojo:web_view"), GURL("mojo:core_services"), "Core"); + manager->RegisterApplicationPackageAlias( + GURL("mojo:tracing"), GURL("mojo:core_services"), "Core"); +} + +} // namespace runner +} // namespace mojo diff --git a/mojo/runner/BUILD.gn b/mojo/runner/BUILD.gn index dc61e16..0bb4986 100644 --- a/mojo/runner/BUILD.gn +++ b/mojo/runner/BUILD.gn @@ -24,6 +24,12 @@ if (is_android) { import("//build/config/android/rules.gni") } +source_set("register_local_aliases_fwd") { + sources = [ + "register_local_aliases.h", + ] +} + source_set("mojo_runner_lib") { sources = [] @@ -41,6 +47,8 @@ source_set("mojo_runner_lib") { "desktop/launcher_process.cc", "desktop/launcher_process.h", "desktop/main.cc", + "register_local_aliases.cc", + "register_local_aliases.h", ] deps += [ "//components/tracing:startup_tracing" ] } else { @@ -71,6 +79,13 @@ executable("mojo_runner") { if (is_android) { sources = [ "android/context_init.cc", + "register_local_aliases.cc", + ] + + deps += [ + ":lib", + ":register_local_aliases_fwd", + "//third_party/mojo/src/mojo/edk/system", ] # On android, the executable is also the native library used by the apk. @@ -425,6 +440,8 @@ test("mojo_runner_unittests") { "data_pipe_peek_unittest.cc", "in_process_native_runner_unittest.cc", "native_runner_unittest.cc", + "register_local_aliases.cc", + "register_local_aliases.h", "shell_test_base.cc", "shell_test_base.h", "shell_test_base_android.cc", diff --git a/mojo/runner/context.cc b/mojo/runner/context.cc index 462ed84..9858789 100644 --- a/mojo/runner/context.cc +++ b/mojo/runner/context.cc @@ -30,6 +30,7 @@ #include "mojo/package_manager/package_manager_impl.h" #include "mojo/runner/in_process_native_runner.h" #include "mojo/runner/out_of_process_native_runner.h" +#include "mojo/runner/register_local_aliases.h" #include "mojo/runner/switches.h" #include "mojo/services/tracing/public/cpp/switches.h" #include "mojo/services/tracing/public/interfaces/tracing.mojom.h" @@ -199,6 +200,8 @@ bool Context::Init() { shell_file_root_, task_runners_->blocking_pool()); InitContentHandlers(package_manager_, command_line); + RegisterLocalAliases(package_manager_); + scoped_ptr runner_factory; if (command_line.HasSwitch(switches::kEnableMultiprocess)) runner_factory.reset(new OutOfProcessNativeRunnerFactory(this)); diff --git a/mojo/runner/register_local_aliases.cc b/mojo/runner/register_local_aliases.cc new file mode 100644 index 0000000..7411453 --- /dev/null +++ b/mojo/runner/register_local_aliases.cc @@ -0,0 +1,13 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "mojo/runner/register_local_aliases.h" + +namespace mojo { +namespace runner { + +void RegisterLocalAliases(mojo::package_manager::PackageManagerImpl* manager) {} + +} // namespace runner +} // namespace mojo diff --git a/mojo/runner/register_local_aliases.h b/mojo/runner/register_local_aliases.h new file mode 100644 index 0000000..1969f60 --- /dev/null +++ b/mojo/runner/register_local_aliases.h @@ -0,0 +1,20 @@ +// Copyright 2015 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef MOJO_RUNNER_REGISTER_LOCAL_ALIASES_H_ +#define MOJO_RUNNER_REGISTER_LOCAL_ALIASES_H_ + +namespace mojo { +namespace package_manager { +class PackageManagerImpl; +} + +namespace runner { + +void RegisterLocalAliases(mojo::package_manager::PackageManagerImpl* manager); + +} // namespace runner +} // namespace mojo + +#endif // MOJO_RUNNER_REGISTER_LOCAL_ALIASES_H_ -- cgit v1.1