0

[fuchsia] Append release channel name to CIPD-archived packages.

Adds a GN arg "fuchsia_release_channel" which modifies how some
released packages are named.

This will allow official builders to produce packages named
"web_engine_canary", "web_runner_beta", and so on.,
a necessary step toward running stable and canary releases
on Fuchsia side-by-side.

Adds test function "ConnectContextProvider()" for sourcing the
ContextProvider service directly from a release channel-specific
package.


Bug: 1029184,1046615
Change-Id: I23845e64d909c9e7665ce3df15458c26e1f27ec6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2006189
Commit-Queue: Kevin Marshall <kmarshall@chromium.org>
Reviewed-by: Wez <wez@chromium.org>
Reviewed-by: James Robinson <jamesr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#736500}
This commit is contained in:
Kevin Marshall
2020-01-29 19:47:26 +00:00
committed by Commit Bot
parent 6d424ab23f
commit b11af76b51
14 changed files with 137 additions and 43 deletions

@@ -26,9 +26,12 @@ declare_args() {
# package_name_override: Specifies the name of the generated package, if its # package_name_override: Specifies the name of the generated package, if its
# name is different than the |package| target name. This value must match # name is different than the |package| target name. This value must match
# package_name_override in the |package| target. # package_name_override in the |package| target.
# package_deps: An array of [package, package_name_override] array pairs # archive_name_override: Specifies the filename of the archive file (FAR)
# which specify additional dependency packages to be installed # which contains the package's data.
# prior to execution. # If left unset, defaults to |package_name_override|.
# Defaults to the package's name.
# package_deps: An array of [package, archive_basename] pairs that specify
# additional dependency packages to be installed prior to execution.
# runner_script: The runner script implementation to use, relative to # runner_script: The runner script implementation to use, relative to
# "build/fuchsia". Defaults to "test_runner.py". # "build/fuchsia". Defaults to "test_runner.py".
# install_only: If true, executing the script will only install the package # install_only: If true, executing the script will only install the package
@@ -36,20 +39,29 @@ declare_args() {
template("fuchsia_package_runner") { template("fuchsia_package_runner") {
forward_variables_from(invoker, [ "runner_script" ]) forward_variables_from(invoker, [ "runner_script" ])
# Compute the package name.
if (defined(invoker.package_name_override)) { if (defined(invoker.package_name_override)) {
_pkg_shortname = invoker.package_name_override _package_name = invoker.package_name_override
} else { } else {
_pkg_shortname = get_label_info(invoker.package, "name") _package_name = get_label_info(invoker.package, "name")
}
# Compute the archive (FAR) filename.
if (defined(invoker.archive_name_override)) {
_archive_shortname = invoker.archive_name_override
} else {
_archive_shortname = _package_name
} }
_pkg_dir = "$root_out_dir/gen/" + get_label_info(invoker.package, "dir") + _pkg_dir = "$root_out_dir/gen/" + get_label_info(invoker.package, "dir") +
"/" + _pkg_shortname "/" + _archive_shortname
_manifest_path = "$_pkg_dir/${_pkg_shortname}.archive_manifest" _manifest_path = "$_pkg_dir/${_archive_shortname}.archive_manifest"
_package_path = "$_pkg_dir/${_pkg_shortname}.far" _package_path = "$_pkg_dir/${_archive_shortname}.far"
generated_run_pkg_script_path = "$root_build_dir/bin/run_${_pkg_shortname}" generated_run_pkg_script_path =
"$root_build_dir/bin/run_${_archive_shortname}"
generated_install_pkg_script_path = generated_install_pkg_script_path =
"$root_build_dir/bin/install_$_pkg_shortname" "$root_build_dir/bin/install_${_archive_shortname}"
_generate_runner_target = "${target_name}__generate_runner" _generate_runner_target = "${target_name}__generate_runner"
_generate_installer_target = "${target_name}__generate_installer" _generate_installer_target = "${target_name}__generate_installer"
@@ -143,7 +155,7 @@ template("fuchsia_package_runner") {
"--target-cpu", "--target-cpu",
target_cpu, target_cpu,
"--package-name", "--package-name",
_pkg_shortname, _package_name,
] ]
if (defined(invoker.use_test_server) && invoker.use_test_server) { if (defined(invoker.use_test_server) && invoker.use_test_server) {

@@ -10,6 +10,9 @@ import("//build/config/sysroot.gni")
# Parameters are: # Parameters are:
# package_name_override: Specifies the name of the package to generate, # package_name_override: Specifies the name of the package to generate,
# if different than |target_name|. # if different than |target_name|.
# archive_filename_override: Specifies the filename of the generated FAR.
# If left unset, defaults to |package_name_override|.
# Defaults to the target name.
# binary: The executable target which should be launched. # binary: The executable target which should be launched.
# manifest: A path to the manifest that will be used. # manifest: A path to the manifest that will be used.
# "testonly" targets default to using # "testonly" targets default to using
@@ -33,6 +36,12 @@ template("fuchsia_package") {
package_name = invoker.target_name package_name = invoker.target_name
} }
if (defined(archive_name_override)) {
archive_filename = archive_name_override
} else {
archive_filename = package_name
}
if (!defined(manifest)) { if (!defined(manifest)) {
assert(testonly == true) assert(testonly == true)
@@ -45,13 +54,13 @@ template("fuchsia_package") {
_pm_tool_path = "${fuchsia_sdk}/tools/pm" _pm_tool_path = "${fuchsia_sdk}/tools/pm"
_pkg_out_dir = "${target_gen_dir}/${pkg.package_name}" _pkg_out_dir = "${target_gen_dir}/${pkg.archive_filename}"
_runtime_deps_file = "$_pkg_out_dir/${pkg.package_name}.runtime_deps" _runtime_deps_file = "$_pkg_out_dir/${pkg.archive_filename}.runtime_deps"
_archive_manifest = "$_pkg_out_dir/${pkg.package_name}.archive_manifest" _archive_manifest = "$_pkg_out_dir/${pkg.archive_filename}.archive_manifest"
_build_ids_file = "$_pkg_out_dir/ids.txt" _build_ids_file = "$_pkg_out_dir/ids.txt"
_meta_far_file = "$_pkg_out_dir/meta.far" _meta_far_file = "$_pkg_out_dir/meta.far"
_combined_far_file = "$_pkg_out_dir/${pkg.package_name}-0.far" _combined_far_file = "$_pkg_out_dir/${pkg.package_name}-0.far"
_final_far_file = "$_pkg_out_dir/${pkg.package_name}.far" _final_far_file = "$_pkg_out_dir/${pkg.archive_filename}.far"
_package_info_path = "$_pkg_out_dir/package" _package_info_path = "$_pkg_out_dir/package"
if (defined(pkg.component_name_override)) { if (defined(pkg.component_name_override)) {

@@ -4,7 +4,9 @@
assert(is_fuchsia) assert(is_fuchsia)
import("//build/buildflag_header.gni")
import("//build/config/fuchsia/fidl_library.gni") import("//build/config/fuchsia/fidl_library.gni")
import("//fuchsia/release_channel.gni")
fidl_library("cast_fidl") { fidl_library("cast_fidl") {
library_name = "cast" library_name = "cast"

@@ -4,8 +4,10 @@
assert(is_fuchsia) assert(is_fuchsia)
import("//build/buildflag_header.gni")
import("//build/config/fuchsia/fidl_library.gni") import("//build/config/fuchsia/fidl_library.gni")
import("//build/config/fuchsia/generate_runner_scripts.gni") import("//build/config/fuchsia/generate_runner_scripts.gni")
import("//fuchsia/release_channel.gni")
import("//testing/test.gni") import("//testing/test.gni")
# Integration helpers for commonly used fuchsia.* APIs. # Integration helpers for commonly used fuchsia.* APIs.
@@ -58,9 +60,18 @@ source_set("message_port") {
] ]
} }
# Used to propagate release-qualified package names to integration test code.
buildflag_header("release_channel_buildflags") {
header = "release_channel.h"
flags = [ "FUCHSIA_RELEASE_CHANNEL_SUFFIX=\"$release_channel_suffix\"" ]
visibility = [ "//fuchsia/*" ]
}
source_set("test_support") { source_set("test_support") {
testonly = true testonly = true
sources = [ sources = [
"context_provider_test_connector.cc",
"context_provider_test_connector.h",
"fake_component_context.cc", "fake_component_context.cc",
"fake_component_context.h", "fake_component_context.h",
"fit_adapter.h", "fit_adapter.h",
@@ -77,6 +88,7 @@ source_set("test_support") {
public_deps = [ public_deps = [
":base", ":base",
":modular", ":modular",
":release_channel_buildflags",
"//base", "//base",
"//net", "//net",
"//net:test_support", "//net:test_support",

@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "fuchsia/engine/test/context_provider_test_connector.h" #include "fuchsia/base/context_provider_test_connector.h"
#include <unistd.h> #include <unistd.h>
@@ -15,14 +15,19 @@
#include "base/fuchsia/default_context.h" #include "base/fuchsia/default_context.h"
#include "base/fuchsia/fuchsia_logging.h" #include "base/fuchsia/fuchsia_logging.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/strcat.h"
#include "fuchsia/base/release_channel.h"
fuchsia::web::ContextProviderPtr StartWebEngineForTests( namespace cr_fuchsia {
fuchsia::web::ContextProviderPtr ConnectContextProvider(
fidl::InterfaceRequest<fuchsia::sys::ComponentController> fidl::InterfaceRequest<fuchsia::sys::ComponentController>
component_controller_request, component_controller_request,
const base::CommandLine& command_line) { const base::CommandLine& command_line) {
fuchsia::sys::LaunchInfo launch_info; fuchsia::sys::LaunchInfo launch_info;
launch_info.url = launch_info.url = base::StrCat({"fuchsia-pkg://fuchsia.com/web_engine",
"fuchsia-pkg://fuchsia.com/web_engine#meta/context_provider.cmx"; BUILDFLAG(FUCHSIA_RELEASE_CHANNEL_SUFFIX),
"#meta/context_provider.cmx"});
launch_info.arguments = command_line.argv(); launch_info.arguments = command_line.argv();
// Clone stderr from the current process to WebEngine and ask it to // Clone stderr from the current process to WebEngine and ask it to
@@ -51,3 +56,5 @@ fuchsia::web::ContextProviderPtr StartWebEngineForTests(
web_engine_service_dir.Connect(context_provider.NewRequest()); web_engine_service_dir.Connect(context_provider.NewRequest());
return context_provider; return context_provider;
} }
} // namespace cr_fuchsia

@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef FUCHSIA_ENGINE_TEST_CONTEXT_PROVIDER_TEST_CONNECTOR_H_ #ifndef FUCHSIA_BASE_CONTEXT_PROVIDER_TEST_CONNECTOR_H_
#define FUCHSIA_ENGINE_TEST_CONTEXT_PROVIDER_TEST_CONNECTOR_H_ #define FUCHSIA_BASE_CONTEXT_PROVIDER_TEST_CONNECTOR_H_
#include <fuchsia/sys/cpp/fidl.h> #include <fuchsia/sys/cpp/fidl.h>
#include <fuchsia/web/cpp/fidl.h> #include <fuchsia/web/cpp/fidl.h>
@@ -11,10 +11,15 @@
#include "base/command_line.h" #include "base/command_line.h"
fuchsia::web::ContextProviderPtr StartWebEngineForTests( namespace cr_fuchsia {
// TODO(crbug.com/1046615): Use test manifests for package specification.
fuchsia::web::ContextProviderPtr ConnectContextProvider(
fidl::InterfaceRequest<fuchsia::sys::ComponentController> fidl::InterfaceRequest<fuchsia::sys::ComponentController>
component_controller_request, component_controller_request,
const base::CommandLine& command_line = const base::CommandLine& command_line =
base::CommandLine(base::CommandLine::NO_PROGRAM)); base::CommandLine(base::CommandLine::NO_PROGRAM));
#endif // FUCHSIA_ENGINE_TEST_CONTEXT_PROVIDER_TEST_CONNECTOR_H_ } // namespace cr_fuchsia
#endif // FUCHSIA_BASE_CONTEXT_PROVIDER_TEST_CONNECTOR_H_

@@ -6,6 +6,7 @@ assert(is_fuchsia)
import("//build/config/fuchsia/generate_runner_scripts.gni") import("//build/config/fuchsia/generate_runner_scripts.gni")
import("//build/config/fuchsia/symbol_archive.gni") import("//build/config/fuchsia/symbol_archive.gni")
import("//fuchsia/release_channel.gni")
import("//mojo/public/tools/bindings/mojom.gni") import("//mojo/public/tools/bindings/mojom.gni")
import("//testing/test.gni") import("//testing/test.gni")
import("//tools/grit/repack.gni") import("//tools/grit/repack.gni")
@@ -205,6 +206,8 @@ fuchsia_package("web_engine") {
binary = ":web_engine_exe" binary = ":web_engine_exe"
manifest = "context_provider.cmx" manifest = "context_provider.cmx"
component_name_override = "context_provider" component_name_override = "context_provider"
package_name_override = "web_engine${release_channel_suffix}"
archive_name_override = "web_engine"
excluded_files = [ excluded_files = [
"lib/libswiftshader_libEGL.so", "lib/libswiftshader_libEGL.so",
@@ -300,8 +303,6 @@ test("web_engine_unittests") {
test("web_engine_integration_tests") { test("web_engine_integration_tests") {
manifest = "web_engine_integration_tests.cmx" manifest = "web_engine_integration_tests.cmx"
sources = [ sources = [
"test/context_provider_test_connector.cc",
"test/context_provider_test_connector.h",
"test_debug_listener.cc", "test_debug_listener.cc",
"test_debug_listener.h", "test_debug_listener.h",
"web_engine_debug_integration_test.cc", "web_engine_debug_integration_test.cc",
@@ -318,7 +319,7 @@ test("web_engine_integration_tests") {
] ]
package_deps = [ [ package_deps = [ [
":web_engine", ":web_engine",
"web_engine", "web_engine${release_channel_suffix}",
] ] ] ]
} }

@@ -13,12 +13,12 @@
#include "base/fuchsia/file_utils.h" #include "base/fuchsia/file_utils.h"
#include "base/macros.h" #include "base/macros.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "fuchsia/base/context_provider_test_connector.h"
#include "fuchsia/base/fit_adapter.h" #include "fuchsia/base/fit_adapter.h"
#include "fuchsia/base/frame_test_util.h" #include "fuchsia/base/frame_test_util.h"
#include "fuchsia/base/result_receiver.h" #include "fuchsia/base/result_receiver.h"
#include "fuchsia/base/test_devtools_list_fetcher.h" #include "fuchsia/base/test_devtools_list_fetcher.h"
#include "fuchsia/base/test_navigation_listener.h" #include "fuchsia/base/test_navigation_listener.h"
#include "fuchsia/engine/test/context_provider_test_connector.h"
#include "fuchsia/engine/test_debug_listener.h" #include "fuchsia/engine/test_debug_listener.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
@@ -38,7 +38,7 @@ class WebEngineDebugIntegrationTest : public testing::Test {
void SetUp() override { void SetUp() override {
web_context_provider_ = web_context_provider_ =
StartWebEngineForTests(web_engine_controller_.NewRequest()); cr_fuchsia::ConnectContextProvider(web_engine_controller_.NewRequest());
web_context_provider_.set_error_handler( web_context_provider_.set_error_handler(
[](zx_status_t status) { ADD_FAILURE(); }); [](zx_status_t status) { ADD_FAILURE(); });

@@ -17,12 +17,12 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "fuchsia/base/context_provider_test_connector.h"
#include "fuchsia/base/fit_adapter.h" #include "fuchsia/base/fit_adapter.h"
#include "fuchsia/base/frame_test_util.h" #include "fuchsia/base/frame_test_util.h"
#include "fuchsia/base/result_receiver.h" #include "fuchsia/base/result_receiver.h"
#include "fuchsia/base/test_devtools_list_fetcher.h" #include "fuchsia/base/test_devtools_list_fetcher.h"
#include "fuchsia/base/test_navigation_listener.h" #include "fuchsia/base/test_navigation_listener.h"
#include "fuchsia/engine/test/context_provider_test_connector.h"
#include "net/http/http_request_headers.h" #include "net/http/http_request_headers.h"
#include "net/test/embedded_test_server/default_handlers.h" #include "net/test/embedded_test_server/default_handlers.h"
#include "net/test/embedded_test_server/embedded_test_server.h" #include "net/test/embedded_test_server/embedded_test_server.h"
@@ -51,7 +51,7 @@ class WebEngineIntegrationTest : public testing::Test {
void StartWebEngine() { void StartWebEngine() {
web_context_provider_ = web_context_provider_ =
StartWebEngineForTests(web_engine_controller_.NewRequest()); cr_fuchsia::ConnectContextProvider(web_engine_controller_.NewRequest());
web_context_provider_.set_error_handler( web_context_provider_.set_error_handler(
[](zx_status_t status) { ADD_FAILURE(); }); [](zx_status_t status) { ADD_FAILURE(); });
} }

@@ -0,0 +1,15 @@
# Copyright 2020 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.
declare_args() {
# Specifies the name of the release channel for specific packages
# (web_engine, web_runner, cast_runner) when buildng on a release bot.
fuchsia_release_channel = ""
}
if (fuchsia_release_channel != "") {
release_channel_suffix = "-${fuchsia_release_channel}"
} else {
release_channel_suffix = ""
}

@@ -7,6 +7,7 @@ assert(is_fuchsia)
import("//build/buildflag_header.gni") import("//build/buildflag_header.gni")
import("//build/config/fuchsia/generate_runner_scripts.gni") import("//build/config/fuchsia/generate_runner_scripts.gni")
import("//build/config/fuchsia/symbol_archive.gni") import("//build/config/fuchsia/symbol_archive.gni")
import("//fuchsia/release_channel.gni")
import("//testing/test.gni") import("//testing/test.gni")
declare_args() { declare_args() {
@@ -14,6 +15,9 @@ declare_args() {
web_runner_remote_debugging_port = 0 web_runner_remote_debugging_port = 0
} }
_cast_runner_package_name = "cast_runner${release_channel_suffix}"
_web_runner_package_name = "web_runner${release_channel_suffix}"
buildflag_header("buildflags") { buildflag_header("buildflags") {
header = "buildflags.h" header = "buildflags.h"
flags = flags =
@@ -89,13 +93,14 @@ executable("cast_runner_exe") {
fuchsia_package("cast_runner_pkg") { fuchsia_package("cast_runner_pkg") {
binary = ":cast_runner_exe" binary = ":cast_runner_exe"
package_name_override = "cast_runner" package_name_override = _cast_runner_package_name
archive_name_override = "cast_runner"
manifest = "cast/cast_runner.cmx" manifest = "cast/cast_runner.cmx"
} }
fuchsia_package_runner("cast_runner") { fuchsia_package_runner("cast_runner") {
package = ":cast_runner_pkg" package = ":cast_runner_pkg"
package_name_override = "cast_runner" archive_name_override = "cast_runner"
install_only = true install_only = true
package_deps = [ [ package_deps = [ [
"//fuchsia/engine:web_engine", "//fuchsia/engine:web_engine",
@@ -193,13 +198,14 @@ executable("web_runner_exe") {
fuchsia_package("web_runner_pkg") { fuchsia_package("web_runner_pkg") {
binary = ":web_runner_exe" binary = ":web_runner_exe"
package_name_override = "web_runner" package_name_override = _web_runner_package_name
archive_name_override = "web_runner"
manifest = "web/web_runner.cmx" manifest = "web/web_runner.cmx"
} }
fuchsia_package_runner("web_runner") { fuchsia_package_runner("web_runner") {
package = ":web_runner_pkg" package = ":web_runner_pkg"
package_name_override = "web_runner" archive_name_override = "web_runner"
install_only = true install_only = true
package_deps = [ [ package_deps = [ [
"//fuchsia/engine:web_engine", "//fuchsia/engine:web_engine",

@@ -20,6 +20,7 @@
#include "base/test/task_environment.h" #include "base/test/task_environment.h"
#include "base/threading/sequenced_task_runner_handle.h" #include "base/threading/sequenced_task_runner_handle.h"
#include "fuchsia/base/agent_impl.h" #include "fuchsia/base/agent_impl.h"
#include "fuchsia/base/context_provider_test_connector.h"
#include "fuchsia/base/fake_component_context.h" #include "fuchsia/base/fake_component_context.h"
#include "fuchsia/base/fit_adapter.h" #include "fuchsia/base/fit_adapter.h"
#include "fuchsia/base/frame_test_util.h" #include "fuchsia/base/frame_test_util.h"
@@ -246,6 +247,9 @@ class CastRunnerIntegrationTest : public testing::Test {
cast_runner_ = std::make_unique<CastRunner>( cast_runner_ = std::make_unique<CastRunner>(
std::move(create_context_params), &outgoing_directory_); std::move(create_context_params), &outgoing_directory_);
cast_runner_->SetContextProviderForTest(cr_fuchsia::ConnectContextProvider(
context_provider_controller_.NewRequest()));
// Connect to the CastRunner's fuchsia.sys.Runner interface. // Connect to the CastRunner's fuchsia.sys.Runner interface.
fidl::InterfaceHandle<fuchsia::io::Directory> directory; fidl::InterfaceHandle<fuchsia::io::Directory> directory;
outgoing_directory_.GetOrCreateDirectory("svc")->Serve( outgoing_directory_.GetOrCreateDirectory("svc")->Serve(
@@ -299,6 +303,7 @@ class CastRunnerIntegrationTest : public testing::Test {
std::unique_ptr<CastRunner> cast_runner_; std::unique_ptr<CastRunner> cast_runner_;
fuchsia::sys::RunnerPtr cast_runner_ptr_; fuchsia::sys::RunnerPtr cast_runner_ptr_;
fuchsia::sys::ComponentControllerPtr context_provider_controller_;
}; };
// A basic integration test ensuring a basic cast request launches the right // A basic integration test ensuring a basic cast request launches the right

@@ -38,19 +38,14 @@ WebContentRunner::WebContentRunner(fuchsia::web::ContextPtr context,
WebContentRunner::~WebContentRunner() = default; WebContentRunner::~WebContentRunner() = default;
// static
fuchsia::web::ContextPtr WebContentRunner::CreateWebContext( fuchsia::web::ContextPtr WebContentRunner::CreateWebContext(
fuchsia::web::CreateContextParams create_params) { fuchsia::web::CreateContextParams create_params) {
auto web_context_provider = base::fuchsia::ComponentContextForCurrentProcess()
->svc()
->Connect<fuchsia::web::ContextProvider>();
fuchsia::web::ContextPtr web_context; fuchsia::web::ContextPtr web_context;
web_context_provider->Create(std::move(create_params), GetContextProvider()->Create(std::move(create_params),
web_context.NewRequest()); web_context.NewRequest());
web_context.set_error_handler([](zx_status_t status) { web_context.set_error_handler([](zx_status_t status) {
// If the browser instance died, then exit everything and do not attempt // If the browser instance died, then exit everything and do not attempt to
// to recover. appmgr will relaunch the runner when it is needed again. // recover. appmgr will relaunch the runner when it is needed again.
ZX_LOG(ERROR, status) << "Connection to Context lost."; ZX_LOG(ERROR, status) << "Connection to Context lost.";
}); });
@@ -103,3 +98,18 @@ void WebContentRunner::RegisterComponent(
components_.insert(std::move(component)); components_.insert(std::move(component));
} }
void WebContentRunner::SetContextProviderForTest(
fuchsia::web::ContextProviderPtr context_provider) {
DCHECK(context_provider);
context_provider_ = std::move(context_provider);
}
fuchsia::web::ContextProvider* WebContentRunner::GetContextProvider() {
if (!context_provider_) {
context_provider_ = base::fuchsia::ComponentContextForCurrentProcess()
->svc()
->Connect<fuchsia::web::ContextProvider>();
}
return context_provider_.get();
}

@@ -35,7 +35,9 @@ class WebContentRunner : public fuchsia::sys::Runner {
~WebContentRunner() override; ~WebContentRunner() override;
static fuchsia::web::ContextPtr CreateWebContext( // TODO(crbug.com/1046615): Make this static when the injected ContextProvider
// goes away.
fuchsia::web::ContextPtr CreateWebContext(
fuchsia::web::CreateContextParams create_params); fuchsia::web::CreateContextParams create_params);
// Gets a pointer to this runner's Context, creating one if needed. // Gets a pointer to this runner's Context, creating one if needed.
@@ -61,6 +63,11 @@ class WebContentRunner : public fuchsia::sys::Runner {
// Registers a WebComponent, or specialization, with this Runner. // Registers a WebComponent, or specialization, with this Runner.
void RegisterComponent(std::unique_ptr<WebComponent> component); void RegisterComponent(std::unique_ptr<WebComponent> component);
// Overrides the environment's the ContextProvider to use.
// TODO(crbug.com/1046615): Use test manifests for package specification.
void SetContextProviderForTest(
fuchsia::web::ContextProviderPtr context_provider);
protected: protected:
base::RepeatingCallback<void(WebComponent*)> base::RepeatingCallback<void(WebComponent*)>
web_component_created_callback_for_test() const { web_component_created_callback_for_test() const {
@@ -70,10 +77,13 @@ class WebContentRunner : public fuchsia::sys::Runner {
fuchsia::web::CreateContextParams create_params_; fuchsia::web::CreateContextParams create_params_;
private: private:
fuchsia::web::ContextProvider* GetContextProvider();
// If set, invoked whenever a WebComponent is created. // If set, invoked whenever a WebComponent is created.
base::RepeatingCallback<void(WebComponent*)> base::RepeatingCallback<void(WebComponent*)>
web_component_created_callback_for_test_; web_component_created_callback_for_test_;
fuchsia::web::ContextProviderPtr context_provider_;
fuchsia::web::ContextPtr context_; fuchsia::web::ContextPtr context_;
std::set<std::unique_ptr<WebComponent>, base::UniquePtrComparator> std::set<std::unique_ptr<WebComponent>, base::UniquePtrComparator>
components_; components_;