Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

[fuchsia] Update Inspect library usage #50467

Merged
merged 1 commit into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions shell/platform/fuchsia/dart_runner/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ template("runner_sources") {
"$fuchsia_sdk_root/pkg:async-loop-cpp",
"$fuchsia_sdk_root/pkg:async-loop-default",
"$fuchsia_sdk_root/pkg:fidl_cpp",
"$fuchsia_sdk_root/pkg:inspect",
"$fuchsia_sdk_root/pkg:inspect_component_cpp",
"$fuchsia_sdk_root/pkg:sys_cpp",
"$fuchsia_sdk_root/pkg:sys_cpp_testing",
"$fuchsia_sdk_root/pkg:sys_inspect_cpp",
"$fuchsia_sdk_root/pkg:trace",
"$fuchsia_sdk_root/pkg:vfs_cpp",
"$fuchsia_sdk_root/pkg:zx",
Expand Down Expand Up @@ -99,7 +100,7 @@ template("runner") {

deps = [
":" + target_name + "_runner_sources",
"$fuchsia_sdk_root/pkg:sys_inspect_cpp",
"$fuchsia_sdk_root/pkg:inspect_component_cpp",
"$fuchsia_sdk_root/pkg:trace-provider-so",
] + extra_deps
}
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/fuchsia/dart_runner/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <lib/async-loop/cpp/loop.h>
#include <lib/async-loop/default.h>
#include <lib/sys/inspect/cpp/component.h>
#include <lib/inspect/component/cpp/component.h>
#include <lib/trace-provider/provider.h>
#include <lib/trace/event.h>

Expand Down
23 changes: 2 additions & 21 deletions shell/platform/fuchsia/dart_runner/meta/common.shard.cml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
{
capabilities: [
// Required for inspect.
// Copied from inspect/client.shard.cml because out-of-tree doesn't
// have support for CML includes from the SDK.
{
directory: "diagnostics",
rights: [ "connect" ],
path: "/diagnostics",
},
],
use: [
// This is used by the Dart VM to communicate from Dart code to C++ code.
{
Expand All @@ -36,6 +26,7 @@
protocol: [
"fuchsia.device.NameProvider", // For fdio uname()
"fuchsia.feedback.CrashReporter",
"fuchsia.inspect.InspectSink", // For inspect
"fuchsia.intl.PropertyProvider", // For dartVM timezone support
"fuchsia.logger.LogSink", // For syslog
"fuchsia.net.name.Lookup", // For fdio sockets
Expand All @@ -50,15 +41,5 @@
from: "parent",
availability: "optional",
},
],
expose: [
// Required for inspect.
// Copied from inspect/client.shard.cml because out-of-tree doesn't
// have support for CML includes from the SDK.
{
directory: "diagnostics",
from: "self",
to: "framework",
},
],
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ TEST_F(RealmBuilderTest, DartRunnerStartsUp) {
Protocol{"fuchsia.posix.socket.Provider"},
Protocol{"fuchsia.intl.PropertyProvider"},
Protocol{"fuchsia.vulkan.loader.Loader"},
Protocol{"fuchsia.inspect.InspectSink"},
Directory{"config-data"}},
.source = ParentRef(),
.targets = {kDartAotRunnerRef, kDartAotEchoServerRef}});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// Offer capabilities needed by components in this test realm.
// Keep it minimal, describe only what's actually needed.
protocol: [
"fuchsia.inspect.InspectSink",
"fuchsia.logger.LogSink",
"fuchsia.sysmem.Allocator",
"fuchsia.tracing.provider.Registry",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ TEST_F(RealmBuilderTest, DartRunnerStartsUp) {
Protocol{"fuchsia.tracing.provider.Registry"},
Protocol{"fuchsia.posix.socket.Provider"},
Protocol{"fuchsia.intl.PropertyProvider"},
Protocol{"fuchsia.inspect.InspectSink"},
Directory{"config-data"}},
.source = ParentRef(),
.targets = {kDartJitRunnerRef, kDartJitEchoServerRef}});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// Offer capabilities needed by components in this test realm.
// Keep it minimal, describe only what's actually needed.
protocol: [
"fuchsia.inspect.InspectSink",
"fuchsia.logger.LogSink",
"fuchsia.sysmem.Allocator",
"fuchsia.tracing.provider.Registry",
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/fuchsia/flutter/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ template("runner_sources") {

public_deps = [
"$fuchsia_sdk_root/pkg:inspect",
"$fuchsia_sdk_root/pkg:inspect_component_cpp",
"$fuchsia_sdk_root/pkg:sys_cpp",
"$fuchsia_sdk_root/pkg:sys_inspect_cpp",
"//flutter/shell/platform/fuchsia/runtime/dart/utils",
] + flutter_public_deps

Expand Down
2 changes: 1 addition & 1 deletion shell/platform/fuchsia/flutter/accessibility_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <fuchsia/accessibility/semantics/cpp/fidl.h>
#include <fuchsia/ui/gfx/cpp/fidl.h>
#include <lib/fidl/cpp/binding_set.h>
#include <lib/sys/inspect/cpp/component.h>
#include <lib/inspect/component/cpp/component.h>
#include <zircon/types.h>

#include <memory>
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/fuchsia/flutter/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// found in the LICENSE file.

#include <lib/async-loop/cpp/loop.h>
#include <lib/sys/inspect/cpp/component.h>
#include <lib/inspect/component/cpp/component.h>
#include <lib/trace-provider/provider.h>
#include <lib/trace/event.h>

Expand Down
23 changes: 2 additions & 21 deletions shell/platform/fuchsia/flutter/meta/common.shard.cml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file
{
capabilities: [
// Required for inspect.
// Copied from inspect/client.shard.cml because out-of-tree doesn't
// have support for CML includes from the SDK.
{
directory: "diagnostics",
rights: [ "connect" ],
path: "/diagnostics",
},
],
use: [
// This is used by the Dart VM to communicate from Dart code to C++ code.
{
Expand Down Expand Up @@ -43,6 +33,7 @@
"fuchsia.device.NameProvider",
"fuchsia.feedback.CrashReporter",
"fuchsia.fonts.Provider",
"fuchsia.inspect.InspectSink", // Copied from inspect/client.shard.cml.
"fuchsia.intl.PropertyProvider",
"fuchsia.logger.LogSink", // Copied from syslog/client.shard.cml.
"fuchsia.media.ProfileProvider",
Expand All @@ -64,15 +55,5 @@
],
availability: "optional",
},
],
expose: [
// Required for inspect.
// Copied from inspect/client.shard.cml because out-of-tree doesn't
// have support for CML includes from the SDK.
{
directory: "diagnostics",
from: "self",
to: "framework",
},
],
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ executable("flutter-embedder-test-bin") {
libs = [ "$fuchsia_sdk_path/arch/$target_cpu/sysroot/lib/libzircon.so" ]

deps = [
"$fuchsia_sdk_root/fidl:fuchsia.inspect",
"$fuchsia_sdk_root/fidl:fuchsia.logger",
"$fuchsia_sdk_root/fidl:fuchsia.tracing.provider",
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include <fuchsia/inspect/cpp/fidl.h>
#include <fuchsia/logger/cpp/fidl.h>
#include <fuchsia/tracing/provider/cpp/fidl.h>
#include <fuchsia/ui/app/cpp/fidl.h>
Expand Down Expand Up @@ -232,6 +233,7 @@ void FlutterEmbedderTest::SetUpRealmBase() {
Route{.capabilities =
{
Protocol{fuchsia::logger::LogSink::Name_},
Protocol{fuchsia::inspect::InspectSink::Name_},
Protocol{fuchsia::sysmem::Allocator::Name_},
Protocol{fuchsia::tracing::provider::Registry::Name_},
Protocol{kVulkanLoaderServiceName},
Expand All @@ -243,6 +245,7 @@ void FlutterEmbedderTest::SetUpRealmBase() {
// Route base system services to the test UI stack.
realm_builder_.AddRoute(Route{
.capabilities = {Protocol{fuchsia::logger::LogSink::Name_},
Protocol{fuchsia::inspect::InspectSink::Name_},
Protocol{fuchsia::sysmem::Allocator::Name_},
Protocol{fuchsia::tracing::provider::Registry::Name_},
Protocol{kVulkanLoaderServiceName}},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// Offer capabilities needed by components in this test realm.
// Keep it minimal, describe only what's actually needed.
protocol: [
"fuchsia.inspect.InspectSink",
"fuchsia.logger.LogSink",
"fuchsia.sysmem.Allocator",
"fuchsia.tracing.provider.Registry",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// Offer capabilities needed by components in this test realm.
// Keep it minimal, describe only what's actually needed.
protocol: [
"fuchsia.inspect.InspectSink",
"fuchsia.kernel.RootJobForInspect",
"fuchsia.kernel.Stats",
"fuchsia.logger.LogSink",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
offer: [
{
protocol: [
"fuchsia.inspect.InspectSink",
"fuchsia.kernel.RootJobForInspect",
"fuchsia.kernel.Stats",
"fuchsia.logger.LogSink",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
// Offer capabilities needed by components in this test realm.
// Keep it minimal, describe only what's actually needed.
protocol: [
"fuchsia.inspect.InspectSink",
"fuchsia.kernel.RootJobForInspect",
"fuchsia.kernel.Stats",
"fuchsia.logger.LogSink",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ source_set("portable_ui_test") {

deps = [
":check_view",
"$fuchsia_sdk_root/fidl:fuchsia.inspect",
"$fuchsia_sdk_root/fidl:fuchsia.logger",
"$fuchsia_sdk_root/fidl:fuchsia.ui.app",
"$fuchsia_sdk_root/fidl:fuchsia.ui.composition",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "portable_ui_test.h"

#include <fuchsia/inspect/cpp/fidl.h>
#include <fuchsia/logger/cpp/fidl.h>
#include <fuchsia/tracing/provider/cpp/fidl.h>
#include <fuchsia/ui/app/cpp/fidl.h>
Expand Down Expand Up @@ -77,6 +78,7 @@ void PortableUITest::SetUpRealmBase() {
// // Route base system services to flutter and the test UI stack.
realm_builder_.AddRoute(Route{
.capabilities = {Protocol{fuchsia::logger::LogSink::Name_},
Protocol{fuchsia::inspect::InspectSink::Name_},
Protocol{fuchsia::sysmem::Allocator::Name_},
Protocol{fuchsia::tracing::provider::Registry::Name_},
Protocol{fuchsia::ui::input::ImeService::Name_},
Expand Down
5 changes: 3 additions & 2 deletions shell/platform/fuchsia/runtime/dart/utils/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ template("make_utils") {
"$fuchsia_sdk_root/pkg:async-loop-default",
"$fuchsia_sdk_root/pkg:fdio",
"$fuchsia_sdk_root/pkg:sys_cpp",
"$fuchsia_sdk_root/pkg:sys_inspect_cpp",
"$fuchsia_sdk_root/pkg:inspect_component_cpp",
"$fuchsia_sdk_root/pkg:trace",
"$fuchsia_sdk_root/pkg:vfs_cpp",
"$fuchsia_sdk_root/pkg:zx",
Expand Down Expand Up @@ -99,7 +99,8 @@ executable("dart_utils_unittests") {
deps = [
":utils",
":utils_fixtures",
"$fuchsia_sdk_root/pkg:sys_inspect_cpp",
"$fuchsia_sdk_root/pkg:inspect_component_cpp",
"$fuchsia_sdk_root/pkg:sys_cpp",
"//flutter/testing",
"//third_party/dart/runtime:libdart_jit",
"//third_party/dart/runtime/bin:dart_io_api",
Expand Down
10 changes: 6 additions & 4 deletions shell/platform/fuchsia/runtime/dart/utils/root_inspect_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@
// found in the LICENSE file.

#include "root_inspect_node.h"
#include <lib/async/default.h>

namespace dart_utils {

std::unique_ptr<sys::ComponentInspector> RootInspectNode::inspector_;
std::unique_ptr<inspect::ComponentInspector> RootInspectNode::inspector_;
std::mutex RootInspectNode::mutex_;

void RootInspectNode::Initialize(sys::ComponentContext* context) {
std::lock_guard<std::mutex> lock(mutex_);
if (!inspector_) {
inspector_ = std::make_unique<sys::ComponentInspector>(context);
inspector_ = std::make_unique<inspect::ComponentInspector>(
async_get_default_dispatcher(), inspect::PublishOptions{});
}
}

inspect::Node RootInspectNode::CreateRootChild(const std::string& name) {
std::lock_guard<std::mutex> lock(mutex_);
return inspector_->inspector()->GetRoot().CreateChild(name);
return inspector_->inspector().GetRoot().CreateChild(name);
}

inspect::Inspector* RootInspectNode::GetInspector() {
return inspector_->inspector();
return &inspector_->inspector();
}

} // namespace dart_utils
5 changes: 3 additions & 2 deletions shell/platform/fuchsia/runtime/dart/utils/root_inspect_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#ifndef FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNTIME_DART_UTILS_ROOT_INSPECT_NODE_H_
#define FLUTTER_SHELL_PLATFORM_FUCHSIA_RUNTIME_DART_UTILS_ROOT_INSPECT_NODE_H_

#include <lib/sys/inspect/cpp/component.h>
#include <lib/inspect/component/cpp/component.h>
#include <lib/sys/cpp/component_context.h>

#include <memory>
#include <mutex>
Expand Down Expand Up @@ -36,7 +37,7 @@ class RootInspectNode {
static inspect::Inspector* GetInspector();

private:
static std::unique_ptr<sys::ComponentInspector> inspector_;
static std::unique_ptr<inspect::ComponentInspector> inspector_;
static std::mutex mutex_;
};

Expand Down