[Fuchsia] Log component start & stop in runners
Now runners will log when a new component is created or destroyed. Bug: 1108487 Change-Id: I0327b43064f632b91129c5c16c94ca3a00fbcee5 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2872532 Auto-Submit: Sergey Ulanov <sergeyu@chromium.org> Reviewed-by: Jochen Eisinger <jochen@chromium.org> Reviewed-by: David Dorwin <ddorwin@chromium.org> Commit-Queue: Jochen Eisinger <jochen@chromium.org> Cr-Commit-Position: refs/heads/master@{#880871}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
1ef99c8922
commit
6db14b4d64
@ -2336,6 +2336,7 @@ def CheckSpamLogging(input_api, output_api):
|
||||
r"^extensions[\\/]renderer[\\/]logging_native_handler\.cc$",
|
||||
r"^fuchsia[\\/]engine[\\/]browser[\\/]frame_impl.cc$",
|
||||
r"^fuchsia[\\/]engine[\\/]context_provider_main.cc$",
|
||||
r"^fuchsia[\\/]runners[\\/]common[\\/]web_component.cc$",
|
||||
r"^headless[\\/]app[\\/]headless_shell\.cc$",
|
||||
r"^ipc[\\/]ipc_logging\.cc$",
|
||||
r"^native_client_sdk[\\/]",
|
||||
|
@ -32,15 +32,18 @@ WebComponent::WebComponent(
|
||||
module_context_(
|
||||
startup_context()->svc()->Connect<fuchsia::modular::ModuleContext>()),
|
||||
navigation_listener_binding_(this) {
|
||||
DCHECK(!debug_name_.empty());
|
||||
DCHECK(runner);
|
||||
|
||||
LOG(INFO) << "Creating component " << debug_name_;
|
||||
|
||||
// If the ComponentController request is valid then bind it, and configure it
|
||||
// to destroy this component on error.
|
||||
if (controller_request.is_valid()) {
|
||||
controller_binding_.Bind(std::move(controller_request));
|
||||
controller_binding_.set_error_handler([this](zx_status_t status) {
|
||||
ZX_LOG_IF(ERROR, status != ZX_ERR_PEER_CLOSED, status)
|
||||
<< " ComponentController disconnected";
|
||||
<< " ComponentController disconnected for component " << debug_name_;
|
||||
// Teardown the component with dummy values, since ComponentController
|
||||
// channel isn't there to receive them.
|
||||
DestroyComponent(0, fuchsia::sys::TerminationReason::UNKNOWN);
|
||||
@ -82,8 +85,10 @@ void WebComponent::StartComponent() {
|
||||
// ZX_ERR_PEER_CLOSED will usually indicate a crash, reported elsewhere.
|
||||
// Therefore only log other, more unusual, |status| codes.
|
||||
frame_.set_error_handler([this](zx_status_t status) {
|
||||
if (status != ZX_OK && status != ZX_ERR_PEER_CLOSED)
|
||||
ZX_LOG(ERROR, status) << " Frame disconnected";
|
||||
if (status != ZX_OK && status != ZX_ERR_PEER_CLOSED) {
|
||||
ZX_LOG(ERROR, status)
|
||||
<< " component " << debug_name_ << ": Frame disconnected";
|
||||
}
|
||||
DestroyComponent(status, fuchsia::sys::TerminationReason::EXITED);
|
||||
});
|
||||
|
||||
@ -109,6 +114,7 @@ void WebComponent::LoadUrl(
|
||||
const GURL& url,
|
||||
std::vector<fuchsia::net::http::Header> extra_headers) {
|
||||
DCHECK(url.is_valid());
|
||||
|
||||
fuchsia::web::NavigationControllerPtr navigation_controller;
|
||||
frame()->GetNavigationController(navigation_controller.NewRequest());
|
||||
|
||||
@ -184,6 +190,10 @@ void WebComponent::OnNavigationStateChanged(
|
||||
|
||||
void WebComponent::DestroyComponent(int64_t exit_code,
|
||||
fuchsia::sys::TerminationReason reason) {
|
||||
LOG(INFO) << "Component " << debug_name_
|
||||
<< " is shutting down. reason=" << static_cast<int>(reason)
|
||||
<< " exit_code=" << exit_code;
|
||||
|
||||
termination_reason_ = reason;
|
||||
termination_exit_code_ = exit_code;
|
||||
runner_->DestroyComponent(this);
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include "base/fuchsia/scoped_service_binding.h"
|
||||
#include "base/fuchsia/startup_context.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "fuchsia/runners/buildflags.h"
|
||||
#include "fuchsia/runners/common/web_component.h"
|
||||
#include "url/gurl.h"
|
||||
@ -42,6 +43,11 @@ bool IsChannelClosed(const zx::channel& channel) {
|
||||
return status == ZX_OK;
|
||||
}
|
||||
|
||||
std::string CreateUniqueComponentName() {
|
||||
static int last_component_id_ = 0;
|
||||
return base::StringPrintf("web-component:%d", ++last_component_id_);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
WebContentRunner::WebContentRunner(
|
||||
@ -90,7 +96,7 @@ void WebContentRunner::StartComponent(
|
||||
}
|
||||
|
||||
std::unique_ptr<WebComponent> component = std::make_unique<WebComponent>(
|
||||
std::string(), this,
|
||||
CreateUniqueComponentName(), this,
|
||||
std::make_unique<base::StartupContext>(std::move(startup_info)),
|
||||
std::move(controller_request));
|
||||
#if BUILDFLAG(WEB_RUNNER_REMOTE_DEBUGGING_PORT) != 0
|
||||
|
Reference in New Issue
Block a user