Commit 5462eba5 authored by Wez's avatar Wez Committed by Chromium LUCI CQ

[fuchsia] Set a |debug_name| on each CastComponent.

Set a |debug_name| when creating the Frame for each web component, for
the Frame's console log output to be tagged with.

Bug: 1088094, 1139396
Change-Id: Ie58a932d68ef225796cf4ae367a7e5c106f0d51a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2582319
Commit-Queue: Wez <wez@chromium.org>
Reviewed-by: default avatarDavid Dorwin <ddorwin@chromium.org>
Auto-Submit: Wez <wez@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836646}
parent 154de628
...@@ -69,10 +69,12 @@ bool CastComponent::Params::AreComplete() const { ...@@ -69,10 +69,12 @@ bool CastComponent::Params::AreComplete() const {
return true; return true;
} }
CastComponent::CastComponent(WebContentRunner* runner, CastComponent::CastComponent(base::StringPiece debug_name,
WebContentRunner* runner,
CastComponent::Params params, CastComponent::Params params,
bool is_headless) bool is_headless)
: WebComponent(runner, : WebComponent(debug_name,
runner,
std::move(params.startup_context), std::move(params.startup_context),
std::move(params.controller_request)), std::move(params.controller_request)),
is_headless_(is_headless), is_headless_(is_headless),
......
...@@ -59,7 +59,15 @@ class CastComponent : public WebComponent, ...@@ -59,7 +59,15 @@ class CastComponent : public WebComponent,
base::Optional<uint64_t> media_session_id; base::Optional<uint64_t> media_session_id;
}; };
CastComponent(WebContentRunner* runner, Params params, bool is_headless); // See WebComponent documentation for details of |debug_name| and |runner|.
// |params| provides the Cast application configuration to use.
// |is_headless| must match the headless setting of the specfied |runner|, to
// have CreateView() operations trigger enabling & disabling of off-screen
// rendering.
CastComponent(base::StringPiece debug_name,
WebContentRunner* runner,
Params params,
bool is_headless);
~CastComponent() final; ~CastComponent() final;
void SetOnDestroyedCallback(base::OnceClosure on_destroyed); void SetOnDestroyedCallback(base::OnceClosure on_destroyed);
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "base/fuchsia/fuchsia_logging.h" #include "base/fuchsia/fuchsia_logging.h"
#include "base/fuchsia/process_context.h" #include "base/fuchsia/process_context.h"
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/strcat.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "base/values.h" #include "base/values.h"
#include "fuchsia/base/agent_manager.h" #include "fuchsia/base/agent_manager.h"
...@@ -435,7 +436,8 @@ void CastRunner::LaunchPendingComponent(PendingCastComponent* pending_component, ...@@ -435,7 +436,8 @@ void CastRunner::LaunchPendingComponent(PendingCastComponent* pending_component,
} }
auto cast_component = std::make_unique<CastComponent>( auto cast_component = std::make_unique<CastComponent>(
component_owner, std::move(params), is_headless_); base::StrCat({"cast:", pending_component->app_id()}), component_owner,
std::move(params), is_headless_);
// Start the component, which creates and configures the web.Frame, and load // Start the component, which creates and configures the web.Frame, and load
// the specified web content into it. // the specified web content into it.
......
...@@ -15,7 +15,7 @@ PendingCastComponent::PendingCastComponent( ...@@ -15,7 +15,7 @@ PendingCastComponent::PendingCastComponent(
fidl::InterfaceRequest<fuchsia::sys::ComponentController> fidl::InterfaceRequest<fuchsia::sys::ComponentController>
controller_request, controller_request,
base::StringPiece app_id) base::StringPiece app_id)
: delegate_(delegate) { : delegate_(delegate), app_id_(app_id.as_string()) {
DCHECK(startup_context); DCHECK(startup_context);
DCHECK(controller_request); DCHECK(controller_request);
......
...@@ -50,6 +50,8 @@ class PendingCastComponent { ...@@ -50,6 +50,8 @@ class PendingCastComponent {
PendingCastComponent(const PendingCastComponent&) = delete; PendingCastComponent(const PendingCastComponent&) = delete;
PendingCastComponent& operator=(const PendingCastComponent&) = delete; PendingCastComponent& operator=(const PendingCastComponent&) = delete;
const base::StringPiece app_id() const { return app_id_; }
private: private:
void RequestCorsExemptHeaders(); void RequestCorsExemptHeaders();
...@@ -66,6 +68,9 @@ class PendingCastComponent { ...@@ -66,6 +68,9 @@ class PendingCastComponent {
// Reference to the Delegate which manages |this|. // Reference to the Delegate which manages |this|.
Delegate* const delegate_; Delegate* const delegate_;
// Id of the Cast application that this instance describes.
const std::string app_id_;
// Parameters required to construct the CastComponent. // Parameters required to construct the CastComponent.
CastComponent::Params params_; CastComponent::Params params_;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "fuchsia/runners/common/web_component.h" #include "fuchsia/runners/common/web_component.h"
#include <fuchsia/logger/cpp/fidl.h>
#include <fuchsia/sys/cpp/fidl.h> #include <fuchsia/sys/cpp/fidl.h>
#include <fuchsia/ui/views/cpp/fidl.h> #include <fuchsia/ui/views/cpp/fidl.h>
#include <lib/fidl/cpp/binding_set.h> #include <lib/fidl/cpp/binding_set.h>
...@@ -18,11 +19,13 @@ ...@@ -18,11 +19,13 @@
#include "fuchsia/runners/common/web_content_runner.h" #include "fuchsia/runners/common/web_content_runner.h"
WebComponent::WebComponent( WebComponent::WebComponent(
base::StringPiece debug_name,
WebContentRunner* runner, WebContentRunner* runner,
std::unique_ptr<base::fuchsia::StartupContext> context, std::unique_ptr<base::fuchsia::StartupContext> context,
fidl::InterfaceRequest<fuchsia::sys::ComponentController> fidl::InterfaceRequest<fuchsia::sys::ComponentController>
controller_request) controller_request)
: runner_(runner), : debug_name_(debug_name.as_string()),
runner_(runner),
startup_context_(std::move(context)), startup_context_(std::move(context)),
controller_binding_(this), controller_binding_(this),
module_context_( module_context_(
...@@ -66,6 +69,8 @@ void WebComponent::StartComponent() { ...@@ -66,6 +69,8 @@ void WebComponent::StartComponent() {
// Create the underlying Frame and get its NavigationController. // Create the underlying Frame and get its NavigationController.
fuchsia::web::CreateFrameParams create_params; fuchsia::web::CreateFrameParams create_params;
if (!debug_name_.empty())
create_params.set_debug_name(debug_name_);
create_params.set_enable_remote_debugging(enable_remote_debugging_); create_params.set_enable_remote_debugging(enable_remote_debugging_);
create_params.set_autoplay_policy( create_params.set_autoplay_policy(
fuchsia::web::AutoplayPolicy::REQUIRE_USER_ACTIVATION); fuchsia::web::AutoplayPolicy::REQUIRE_USER_ACTIVATION);
......
...@@ -32,12 +32,17 @@ class WebComponent : public fuchsia::sys::ComponentController, ...@@ -32,12 +32,17 @@ class WebComponent : public fuchsia::sys::ComponentController,
public fuchsia::ui::app::ViewProvider, public fuchsia::ui::app::ViewProvider,
public fuchsia::web::NavigationEventListener { public fuchsia::web::NavigationEventListener {
public: public:
// Creates a WebComponent encapsulating a web.Frame. A ViewProvider service // Creates a WebComponent encapsulating a web.Frame.
// will be published to the service-directory specified by |startup_context|, // |debug_name| may be empty, or specified a name to use to uniquely identify
// and if |controller_request| is valid then it will be bound to this // the Frame in log output.
// component, and the component configured to teardown if that channel closes. // |runner| must out-live |this|.
// |runner| must outlive this component. // [context| will be retained to provide component-specific services.
WebComponent(WebContentRunner* runner, // If |context| includes an outgoing-directory request then the component
// will publish ViewProvider and Lifecycle services.
// |controller_request| may optionally be supplied and used to control the
// lifetime of this component instance.
WebComponent(base::StringPiece debug_name,
WebContentRunner* runner,
std::unique_ptr<base::fuchsia::StartupContext> context, std::unique_ptr<base::fuchsia::StartupContext> context,
fidl::InterfaceRequest<fuchsia::sys::ComponentController> fidl::InterfaceRequest<fuchsia::sys::ComponentController>
controller_request); controller_request);
...@@ -96,7 +101,13 @@ class WebComponent : public fuchsia::sys::ComponentController, ...@@ -96,7 +101,13 @@ class WebComponent : public fuchsia::sys::ComponentController,
fuchsia::sys::TerminationReason reason); fuchsia::sys::TerminationReason reason);
private: private:
// Optional name with which to tag console log output from the Frame.
const std::string debug_name_;
// Refers to the owner of the web.Context hosting this component instance.
WebContentRunner* const runner_ = nullptr; WebContentRunner* const runner_ = nullptr;
// Component context for this instance, including incoming services.
const std::unique_ptr<base::fuchsia::StartupContext> startup_context_; const std::unique_ptr<base::fuchsia::StartupContext> startup_context_;
fuchsia::web::FramePtr frame_; fuchsia::web::FramePtr frame_;
......
...@@ -77,7 +77,7 @@ void WebContentRunner::StartComponent( ...@@ -77,7 +77,7 @@ void WebContentRunner::StartComponent(
} }
std::unique_ptr<WebComponent> component = std::make_unique<WebComponent>( std::unique_ptr<WebComponent> component = std::make_unique<WebComponent>(
this, std::string(), this,
std::make_unique<base::fuchsia::StartupContext>(std::move(startup_info)), std::make_unique<base::fuchsia::StartupContext>(std::move(startup_info)),
std::move(controller_request)); std::move(controller_request));
#if BUILDFLAG(WEB_RUNNER_REMOTE_DEBUGGING_PORT) != 0 #if BUILDFLAG(WEB_RUNNER_REMOTE_DEBUGGING_PORT) != 0
......
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