Commit 669a04e0 authored by Wez's avatar Wez Committed by Commit Bot

[Fuchsia] Enable CastRunner to reach the ApplicationConfigManager.

Work-around some issues with the component launcher implementation by
falling-back to using LaunchInfo-provided services if the
ApplicationConfigManager cannot be found in the CastRunner's incoming
service directory.

Bug: 893229
Change-Id: I500920cb21186fdbd60f59783f359fdaf65aecaf
Reviewed-on: https://chromium-review.googlesource.com/c/1476594Reviewed-by: default avatarKevin Marshall <kmarshall@chromium.org>
Commit-Queue: Wez <wez@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#633808}
parent 821b349e
......@@ -25,6 +25,21 @@ StartupContext::StartupContext(::fuchsia::sys::StartupInfo startup_info)
break;
}
}
// TODO(https://crbug.com/933834): Remove this workaround when we migrate to
// the new component manager.
if (!incoming_services_ && startup_info_.launch_info.flat_namespace) {
LOG(WARNING) << "Falling back to LaunchInfo namespace";
for (size_t i = 0;
i < startup_info_.launch_info.flat_namespace->paths.size(); ++i) {
if (startup_info_.launch_info.flat_namespace->paths[i] == "/svc") {
incoming_services_ = std::make_unique<ServiceDirectoryClient>(
fidl::InterfaceHandle<::fuchsia::io::Directory>(std::move(
startup_info_.launch_info.flat_namespace->directories[i])));
break;
}
}
}
}
StartupContext::~StartupContext() = default;
......
......@@ -9,8 +9,10 @@
#include <string>
#include <utility>
#include "base/fuchsia/fuchsia_logging.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/process/process.h"
#include "fuchsia/runners/cast/cast_component.h"
#include "url/gurl.h"
......@@ -22,7 +24,11 @@ CastRunner::CastRunner(
: WebContentRunner(service_directory,
std::move(context),
std::move(on_idle_closure)),
app_config_manager_(std::move(app_config_manager)) {}
app_config_manager_(std::move(app_config_manager)) {
app_config_manager_.set_error_handler([](zx_status_t status) {
ZX_LOG(WARNING, status) << "ApplicationConfigManager disconnected";
});
}
CastRunner::~CastRunner() = default;
......@@ -46,11 +52,22 @@ void CastRunner::StartComponent(
// Fetch the Cast application configuration for the specified Id.
const std::string cast_app_id(cast_url.GetContent());
// TODO(https://crbug.com/933831): Look for ApplicationConfigManager in the
// per-component incoming services. This works-around an issue with binding
// to that service via the Runner's incoming services. Replace this with a
// request for services from a Cast-specific Agent.
auto startup_context =
std::make_unique<base::fuchsia::StartupContext>(std::move(startup_info));
if (!app_config_manager_) {
LOG(WARNING) << "Connect to ApplicationConfigManager from component /svc";
startup_context->incoming_services()->ConnectToService(
app_config_manager_.NewRequest());
}
app_config_manager_->GetConfig(
cast_app_id,
[this,
startup_context = std::make_unique<base::fuchsia::StartupContext>(
std::move(startup_info)),
[this, startup_context = std::move(startup_context),
controller_request = std::move(controller_request)](
chromium::cast::ApplicationConfigPtr app_config) mutable {
GetConfigCallback(std::move(startup_context),
......
......@@ -35,7 +35,7 @@ class CastRunner : public WebContentRunner {
controller_request,
chromium::cast::ApplicationConfigPtr app_config);
const chromium::cast::ApplicationConfigManagerPtr app_config_manager_;
chromium::cast::ApplicationConfigManagerPtr app_config_manager_;
DISALLOW_COPY_AND_ASSIGN(CastRunner);
};
......
{
"features": [],
"services": [
"chromium.cast.ApplicationConfigManager",
"chromium.web.ContextProvider",
"fuchsia.fonts.Provider",
"fuchsia.media.Audio",
......
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