Commit 3736bfa8 authored by David Dorwin's avatar David Dorwin Committed by Commit Bot

[Fuchsia] Minor CastRunner cleanup

Change-Id: I0611b41a7f428204c9bf92b7a0438271edc7846a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1864408
Commit-Queue: David Dorwin <ddorwin@chromium.org>
Reviewed-by: default avatarWez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707428}
parent 68badfdb
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "fuchsia/runners/cast/cast_runner.h" #include "fuchsia/runners/cast/cast_runner.h"
#include <fuchsia/sys/cpp/fidl.h> #include <fuchsia/sys/cpp/fidl.h>
#include <fuchsia/web/cpp/fidl.h>
#include <memory> #include <memory>
#include <string> #include <string>
#include <utility> #include <utility>
...@@ -88,9 +89,9 @@ void CastRunner::StartComponent( ...@@ -88,9 +89,9 @@ void CastRunner::StartComponent(
return; return;
} }
// The application configuration asynchronously via the per-component // The application configuration is obtained asynchronously via the
// ApplicationConfigManager, the pointer to that service must be kept live // per-component ApplicationConfigManager. The pointer to that service must be
// until the request completes, or CastRunner is deleted. // kept live until the request completes or CastRunner is deleted.
auto pending_component = auto pending_component =
std::make_unique<CastComponent::CastComponentParams>(); std::make_unique<CastComponent::CastComponentParams>();
pending_component->startup_context = pending_component->startup_context =
...@@ -99,16 +100,6 @@ void CastRunner::StartComponent( ...@@ -99,16 +100,6 @@ void CastRunner::StartComponent(
pending_component->startup_context->incoming_services()); pending_component->startup_context->incoming_services());
pending_component->controller_request = std::move(controller_request); pending_component->controller_request = std::move(controller_request);
// Request the configuration for the specified application.
pending_component->agent_manager->ConnectToAgentService(
kAgentComponentUrl, pending_component->app_config_manager.NewRequest());
pending_component->app_config_manager.set_error_handler(
[this, pending_component = pending_component.get()](zx_status_t status) {
ZX_LOG(ERROR, status) << "ApplicationConfigManager disconnected.";
GetConfigCallback(pending_component,
chromium::cast::ApplicationConfig());
});
// Get binding details from the Agent. // Get binding details from the Agent.
fidl::InterfaceHandle<chromium::cast::ApiBindings> api_bindings_client; fidl::InterfaceHandle<chromium::cast::ApiBindings> api_bindings_client;
pending_component->agent_manager->ConnectToAgentService( pending_component->agent_manager->ConnectToAgentService(
...@@ -141,6 +132,15 @@ void CastRunner::StartComponent( ...@@ -141,6 +132,15 @@ void CastRunner::StartComponent(
MaybeStartComponent(pending_component); MaybeStartComponent(pending_component);
}); });
// Request the configuration for the specified application.
pending_component->agent_manager->ConnectToAgentService(
kAgentComponentUrl, pending_component->app_config_manager.NewRequest());
pending_component->app_config_manager.set_error_handler(
[this, pending_component = pending_component.get()](zx_status_t status) {
ZX_LOG(ERROR, status) << "ApplicationConfigManager disconnected.";
GetConfigCallback(pending_component,
chromium::cast::ApplicationConfig());
});
const std::string cast_app_id(cast_url.GetContent()); const std::string cast_app_id(cast_url.GetContent());
pending_component->app_config_manager->GetConfig( pending_component->app_config_manager->GetConfig(
cast_app_id, [this, pending_component = pending_component.get()]( cast_app_id, [this, pending_component = pending_component.get()](
...@@ -170,10 +170,15 @@ void CastRunner::GetConfigCallback( ...@@ -170,10 +170,15 @@ void CastRunner::GetConfigCallback(
auto it = pending_components_.find(pending_component); auto it = pending_components_.find(pending_component);
DCHECK(it != pending_components_.end()); DCHECK(it != pending_components_.end());
// If no configuration was returned then ignore the request. if (app_config.IsEmpty()) {
pending_components_.erase(it);
DLOG(WARNING) << "No application config was found.";
return;
}
if (!app_config.has_web_url()) { if (!app_config.has_web_url()) {
pending_components_.erase(it); pending_components_.erase(it);
DLOG(WARNING) << "No ApplicationConfig was found."; DLOG(WARNING) << "Only web-based applications are supported.";
return; return;
} }
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#ifndef FUCHSIA_RUNNERS_CAST_CAST_RUNNER_H_ #ifndef FUCHSIA_RUNNERS_CAST_CAST_RUNNER_H_
#define FUCHSIA_RUNNERS_CAST_CAST_RUNNER_H_ #define FUCHSIA_RUNNERS_CAST_CAST_RUNNER_H_
#include <fuchsia/sys/cpp/fidl.h>
#include <fuchsia/web/cpp/fidl.h>
#include <memory> #include <memory>
#include <set> #include <set>
#include <vector> #include <vector>
......
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