[scenic] modular: view_framework->base_view
All peridot clients expose both the V1 and V2 ViewProvider interfaces,
prepping them for the full move to eventpairs.
No dependencies remain on ui/view_framework in peridot.
TEST: Ran SysUI
SCN-897 #comment
SCN-993 #comment
SCN-1033 #comment
Change-Id: Ibbb80530c40f8f05c9c63002e19ab9892d70f43c
diff --git a/bin/basemgr/basemgr_impl.cc b/bin/basemgr/basemgr_impl.cc
index a5816d4..9ca47da 100644
--- a/bin/basemgr/basemgr_impl.cc
+++ b/bin/basemgr/basemgr_impl.cc
@@ -92,7 +92,8 @@
: presentation_state_.presentation.NewRequest();
context_->ConnectToEnvironmentService<fuchsia::ui::policy::Presenter>()
- ->Present(std::move(view_owner), std::move(presentation_request));
+ ->Present2(zx::eventpair(view_owner.TakeChannel().release()),
+ std::move(presentation_request));
AddGlobalKeyboardShortcuts(presentation_state_.presentation);
diff --git a/bin/basemgr/dev_base_shell.cc b/bin/basemgr/dev_base_shell.cc
index b24e5db..2e6c674 100644
--- a/bin/basemgr/dev_base_shell.cc
+++ b/bin/basemgr/dev_base_shell.cc
@@ -99,11 +99,14 @@
private:
// |SingleServiceApp|
void CreateView(
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request,
- fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> /*services*/)
- override {
- view_owner_request_ = std::move(view_owner_request);
+ zx::eventpair view_token,
+ fidl::InterfaceRequest<
+ fuchsia::sys::ServiceProvider> /*incoming_services*/,
+ fidl::InterfaceHandle<
+ fuchsia::sys::ServiceProvider> /*outgoing_services*/) override {
+ view_owner_request_ =
+ fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>(
+ zx::channel(view_token.release()));
Connect();
}
diff --git a/bin/basemgr/meta/dev_base_shell.cmx b/bin/basemgr/meta/dev_base_shell.cmx
index bb431a0..d35dd89 100644
--- a/bin/basemgr/meta/dev_base_shell.cmx
+++ b/bin/basemgr/meta/dev_base_shell.cmx
@@ -15,6 +15,7 @@
"fuchsia.testing.runner.TestRunnerStore",
"fuchsia.tracelink.Registry",
"fuchsia.ui.policy.Presenter",
+ "fuchsia.ui.scenic.Scenic",
"fuchsia.ui.viewsv1.ViewManager"
],
"system": [
diff --git a/bin/sessionmgr/BUILD.gn b/bin/sessionmgr/BUILD.gn
index d7fafd2..2ebab59 100644
--- a/bin/sessionmgr/BUILD.gn
+++ b/bin/sessionmgr/BUILD.gn
@@ -104,10 +104,8 @@
]
deps = [
- "//garnet/public/fidl/fuchsia.ui.viewsv1",
"//garnet/public/lib/fidl/cpp",
"//garnet/public/lib/fxl",
- "//garnet/public/lib/ui/view_framework",
"//peridot/lib/common:names",
"//peridot/lib/fidl:array_to_string",
"//peridot/lib/fidl:single_service_app",
@@ -117,6 +115,7 @@
"//peridot/public/fidl/fuchsia.modular",
"//peridot/public/lib/app_driver/cpp",
"//zircon/public/lib/async-loop-cpp",
+ "//zircon/public/lib/trace-provider",
]
}
diff --git a/bin/sessionmgr/dev_session_shell.cc b/bin/sessionmgr/dev_session_shell.cc
index 3028700..4f84771 100644
--- a/bin/sessionmgr/dev_session_shell.cc
+++ b/bin/sessionmgr/dev_session_shell.cc
@@ -23,6 +23,7 @@
#include <lib/fxl/command_line.h>
#include <lib/fxl/logging.h>
#include <lib/fxl/macros.h>
+#include <zx/eventpair.h>
#include "peridot/lib/common/names.h"
#include "peridot/lib/fidl/single_service_app.h"
@@ -85,26 +86,34 @@
private:
// |ViewApp|
void CreateView(
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request,
- fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> /*services*/)
- override {
- view_owner_request_ = std::move(view_owner_request);
+ zx::eventpair view_token,
+ fidl::InterfaceRequest<
+ fuchsia::sys::ServiceProvider> /*incoming_services*/,
+ fidl::InterfaceHandle<
+ fuchsia::sys::ServiceProvider> /*outgoing_services*/) override {
+ view_token_ = std::move(view_token);
Connect();
}
void Connect() {
- FXL_CHECK(!!view_owner_request_);
+ FXL_CHECK(!!view_token_);
FXL_CHECK(!!story_provider_);
FXL_CHECK(!!puppet_master_);
FXL_LOG(INFO) << "DevSessionShell START " << settings_.root_module << " "
<< settings_.root_link;
- view_ = std::make_unique<modular::ViewHost>(
+ auto scenic =
startup_context()
- ->ConnectToEnvironmentService<fuchsia::ui::viewsv1::ViewManager>(),
- std::move(view_owner_request_));
+ ->ConnectToEnvironmentService<fuchsia::ui::scenic::Scenic>();
+ scenic::ViewContext context = {
+ .session_and_listener_request =
+ scenic::CreateScenicSessionPtrAndListenerRequest(scenic.get()),
+ .view_token = std::move(view_token_),
+ .startup_context = startup_context(),
+ };
+
+ view_ = std::make_unique<modular::ViewHost>(std::move(context));
puppet_master_->ControlStory(settings_.story_id,
story_puppet_master_.NewRequest());
@@ -235,8 +244,7 @@
const Settings settings_;
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request_;
+ zx::eventpair view_token_;
std::unique_ptr<modular::ViewHost> view_;
fuchsia::modular::SessionShellContextPtr session_shell_context_;
diff --git a/bin/sessionmgr/meta/dev_session_shell.cmx b/bin/sessionmgr/meta/dev_session_shell.cmx
index b43fd2f..8def1f3 100644
--- a/bin/sessionmgr/meta/dev_session_shell.cmx
+++ b/bin/sessionmgr/meta/dev_session_shell.cmx
@@ -14,6 +14,7 @@
"fuchsia.sys.Loader",
"fuchsia.tracelink.Registry",
"fuchsia.ui.policy.Presenter",
+ "fuchsia.ui.scenic.Scenic",
"fuchsia.ui.viewsv1.ViewManager",
"fuchsia.ui.viewsv1.ViewSnapshot"
]
diff --git a/bin/sessionmgr/meta/sessionmgr.cmx b/bin/sessionmgr/meta/sessionmgr.cmx
index 1c6d25f..34544b5 100644
--- a/bin/sessionmgr/meta/sessionmgr.cmx
+++ b/bin/sessionmgr/meta/sessionmgr.cmx
@@ -10,6 +10,7 @@
"fuchsia.sys.Launcher",
"fuchsia.sys.Loader",
"fuchsia.tracelink.Registry",
+ "fuchsia.ui.scenic.Scenic",
"fuchsia.ui.viewsv1.ViewManager",
"fuchsia.ui.viewsv1.ViewSnapshot"
]
diff --git a/bin/sessionmgr/sessionmgr_impl.cc b/bin/sessionmgr/sessionmgr_impl.cc
index 59a0782..be538a4 100644
--- a/bin/sessionmgr/sessionmgr_impl.cc
+++ b/bin/sessionmgr/sessionmgr_impl.cc
@@ -192,8 +192,9 @@
InitializeMessageQueueManager();
InitializeMaxwellAndModular(session_shell.url, std::move(story_shell));
InitializeClipboard();
- InitializeSessionShell(std::move(session_shell),
- std::move(view_owner_request));
+ InitializeSessionShell(
+ std::move(session_shell),
+ zx::eventpair(view_owner_request.TakeChannel().release()));
ReportEvent(ModularEvent::BOOTED_TO_SESSIONMGR);
}
@@ -687,15 +688,20 @@
}
void SessionmgrImpl::InitializeSessionShell(
- fuchsia::modular::AppConfig session_shell,
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request) {
+ fuchsia::modular::AppConfig session_shell, zx::eventpair view_token) {
// We setup our own view and make the fuchsia::modular::SessionShell a child
// of it.
- session_shell_view_host_ = std::make_unique<ViewHost>(
+ auto scenic =
startup_context_
- ->ConnectToEnvironmentService<fuchsia::ui::viewsv1::ViewManager>(),
- std::move(view_owner_request));
+ ->ConnectToEnvironmentService<fuchsia::ui::scenic::Scenic>();
+ scenic::ViewContext view_context = {
+ .session_and_listener_request =
+ scenic::CreateScenicSessionPtrAndListenerRequest(scenic.get()),
+ .view_token = std::move(view_token),
+ .startup_context = startup_context_,
+ };
+ session_shell_view_host_ =
+ std::make_unique<ViewHost>(std::move(view_context));
RunSessionShell(std::move(session_shell));
AtEnd([this](std::function<void()> cont) { TerminateSessionShell(cont); });
}
diff --git a/bin/sessionmgr/sessionmgr_impl.h b/bin/sessionmgr/sessionmgr_impl.h
index d57636c..24a6526 100644
--- a/bin/sessionmgr/sessionmgr_impl.h
+++ b/bin/sessionmgr/sessionmgr_impl.h
@@ -22,6 +22,7 @@
#include <lib/fidl/cpp/binding.h>
#include <lib/fidl/cpp/interface_ptr.h>
#include <lib/fxl/macros.h>
+#include <zx/eventpair.h>
#include "peridot/bin/sessionmgr/agent_runner/agent_runner_storage_impl.h"
#include "peridot/bin/sessionmgr/entity_provider_runner/entity_provider_launcher.h"
@@ -116,10 +117,8 @@
void InitializeMessageQueueManager();
void InitializeMaxwellAndModular(const fidl::StringPtr& session_shell_url,
fuchsia::modular::AppConfig story_shell);
- void InitializeSessionShell(
- fuchsia::modular::AppConfig session_shell,
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request);
+ void InitializeSessionShell(fuchsia::modular::AppConfig session_shell,
+ zx::eventpair view_token);
void RunSessionShell(fuchsia::modular::AppConfig session_shell);
// This is a termination sequence that may be used with |AtEnd()|, but also
diff --git a/bin/sessionmgr/story_runner/dev_story_shell.cc b/bin/sessionmgr/story_runner/dev_story_shell.cc
index 772ce76..238461a 100644
--- a/bin/sessionmgr/story_runner/dev_story_shell.cc
+++ b/bin/sessionmgr/story_runner/dev_story_shell.cc
@@ -34,11 +34,14 @@
private:
// |SingleServiceApp|
void CreateView(
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request,
+ zx::eventpair view_token,
fidl::InterfaceRequest<
- fuchsia::sys::ServiceProvider> /*services_request*/) override {
- view_owner_request_ = std::move(view_owner_request);
+ fuchsia::sys::ServiceProvider> /*incoming_services*/,
+ fidl::InterfaceHandle<
+ fuchsia::sys::ServiceProvider> /*outgoing_services*/) override {
+ view_owner_request_ =
+ fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>(
+ zx::channel(view_token.release()));
Connect();
}
@@ -90,11 +93,17 @@
void Connect() {
if (story_shell_context_.is_bound() && view_owner_request_) {
- view_ = std::make_unique<modular::ViewHost>(
+ auto scenic =
startup_context()
- ->ConnectToEnvironmentService<
- fuchsia::ui::viewsv1::ViewManager>(),
- std::move(view_owner_request_));
+ ->ConnectToEnvironmentService<fuchsia::ui::scenic::Scenic>();
+ scenic::ViewContext view_context = {
+ .session_and_listener_request =
+ scenic::CreateScenicSessionPtrAndListenerRequest(scenic.get()),
+ .view_token =
+ zx::eventpair(view_owner_request_.TakeChannel().release()),
+ .startup_context = startup_context(),
+ };
+ view_ = std::make_unique<modular::ViewHost>(std::move(view_context));
for (auto& view_owner : child_views_) {
view_->ConnectView(std::move(view_owner));
diff --git a/bin/sessionmgr/story_runner/meta/dev_story_shell.cmx b/bin/sessionmgr/story_runner/meta/dev_story_shell.cmx
index 2e80e98..3245dd7 100644
--- a/bin/sessionmgr/story_runner/meta/dev_story_shell.cmx
+++ b/bin/sessionmgr/story_runner/meta/dev_story_shell.cmx
@@ -9,6 +9,7 @@
"fuchsia.sys.Launcher",
"fuchsia.tracelink.Registry",
"fuchsia.ui.policy.Presenter",
+ "fuchsia.ui.scenic.Scenic",
"fuchsia.ui.viewsv1.ViewManager"
]
}
diff --git a/bin/token_manager/meta/dev_token_manager.cmx b/bin/token_manager/meta/dev_token_manager.cmx
index fe2317c..adbd508 100644
--- a/bin/token_manager/meta/dev_token_manager.cmx
+++ b/bin/token_manager/meta/dev_token_manager.cmx
@@ -12,6 +12,7 @@
"fuchsia.sys.Loader",
"fuchsia.tracelink.Registry",
"fuchsia.ui.policy.Presenter",
+ "fuchsia.ui.scenic.Scenic",
"fuchsia.ui.viewsv1.ViewManager",
"fuchsia.ui.viewsv1.ViewSnapshot"
]
diff --git a/examples/swap_cpp/BUILD.gn b/examples/swap_cpp/BUILD.gn
index a7b699b..eaa5ac3 100644
--- a/examples/swap_cpp/BUILD.gn
+++ b/examples/swap_cpp/BUILD.gn
@@ -19,6 +19,7 @@
":module",
"//peridot/public/lib/app_driver/cpp:app_driver",
"//zircon/public/lib/async-loop-cpp",
+ "//zircon/public/lib/trace-provider",
]
}
@@ -37,6 +38,7 @@
":module",
"//peridot/public/lib/app_driver/cpp:app_driver",
"//zircon/public/lib/async-loop-cpp",
+ "//zircon/public/lib/trace-provider",
]
}
@@ -51,7 +53,7 @@
]
deps = [
- "//garnet/public/lib/ui/view_framework",
+ "//garnet/public/lib/ui/base_view/cpp",
"//peridot/public/fidl/fuchsia.modular",
"//peridot/public/lib/app_driver/cpp",
]
@@ -69,10 +71,11 @@
"swap_recipe.cc",
]
deps = [
- "//garnet/public/lib/ui/view_framework",
+ "//garnet/public/lib/ui/base_view/cpp",
"//peridot/lib/fidl:single_service_app",
"//peridot/public/fidl/fuchsia.modular",
"//peridot/public/lib/app_driver/cpp",
"//zircon/public/lib/async-loop-cpp",
+ "//zircon/public/lib/trace-provider",
]
}
diff --git a/examples/swap_cpp/module.cc b/examples/swap_cpp/module.cc
index 0253f1c..415bfbd 100644
--- a/examples/swap_cpp/module.cc
+++ b/examples/swap_cpp/module.cc
@@ -4,17 +4,13 @@
#include "peridot/examples/swap_cpp/module.h"
+#include <lib/component/cpp/startup_context.h>
#include <utility>
namespace modular_example {
-ModuleView::ModuleView(
- fuchsia::ui::viewsv1::ViewManagerPtr view_manager,
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request,
- uint32_t color)
- : BaseView(std::move(view_manager), std::move(view_owner_request),
- "ModuleView"),
+ModuleView::ModuleView(scenic::ViewContext view_context, uint32_t color)
+ : V1BaseView(std::move(view_context), "ModuleView"),
background_node_(session()) {
scenic::Material background_material(session());
background_material.SetColor((color >> 16) & 0xff, (color >> 8) & 0xff,
@@ -37,13 +33,22 @@
: ViewApp(startup_context), create_(std::move(create)) {}
void ModuleApp::CreateView(
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request,
- fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> /*services*/) {
- view_.reset(create_(
+ zx::eventpair view_token,
+ fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> incoming_services,
+ fidl::InterfaceHandle<fuchsia::sys::ServiceProvider> outgoing_services) {
+ auto scenic =
startup_context()
- ->ConnectToEnvironmentService<fuchsia::ui::viewsv1::ViewManager>(),
- std::move(view_owner_request)));
+ ->ConnectToEnvironmentService<fuchsia::ui::scenic::Scenic>();
+ scenic::ViewContext context = {
+ .session_and_listener_request =
+ scenic::CreateScenicSessionPtrAndListenerRequest(scenic.get()),
+ .view_token = std::move(view_token),
+ .incoming_services = std::move(incoming_services),
+ .outgoing_services = std::move(outgoing_services),
+ .startup_context = startup_context(),
+ };
+
+ view_.reset(create_(std::move(context)));
}
} // namespace modular_example
diff --git a/examples/swap_cpp/module.h b/examples/swap_cpp/module.h
index 8cebfca..40f275f 100644
--- a/examples/swap_cpp/module.h
+++ b/examples/swap_cpp/module.h
@@ -6,22 +6,19 @@
#define PERIDOT_EXAMPLES_SWAP_CPP_MODULE_H_
#include <fuchsia/modular/cpp/fidl.h>
-#include <lib/ui/view_framework/base_view.h>
+#include <lib/ui/base_view/cpp/v1_base_view.h>
+#include <zx/eventpair.h>
#include "peridot/lib/fidl/single_service_app.h"
namespace modular_example {
-class ModuleView : public mozart::BaseView {
+class ModuleView : public scenic::V1BaseView {
public:
- explicit ModuleView(
- fuchsia::ui::viewsv1::ViewManagerPtr view_manager,
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request,
- uint32_t color);
+ explicit ModuleView(scenic::ViewContext view_context, uint32_t color);
private:
- // |BaseView|:
+ // |scenic::V1BaseView|
void OnPropertiesChanged(
fuchsia::ui::viewsv1::ViewProperties old_properties) override;
@@ -32,22 +29,22 @@
class ModuleApp : public modular::ViewApp {
public:
- using CreateViewCallback = std::function<mozart::BaseView*(
- fuchsia::ui::viewsv1::ViewManagerPtr,
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>)>;
+ using CreateViewCallback =
+ std::function<scenic::V1BaseView*(scenic::ViewContext view_context)>;
explicit ModuleApp(component::StartupContext* const startup_context,
CreateViewCallback create);
private:
- // |SingleServiceApp|
+ // |ViewApp|
void CreateView(
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request,
- fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> services) override;
+ zx::eventpair view_token,
+ fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> incoming_services,
+ fidl::InterfaceHandle<fuchsia::sys::ServiceProvider> outgoing_services)
+ override;
CreateViewCallback create_;
- std::unique_ptr<mozart::BaseView> view_;
+ std::unique_ptr<scenic::V1BaseView> view_;
FXL_DISALLOW_COPY_AND_ASSIGN(ModuleApp);
};
diff --git a/examples/swap_cpp/swap_module1.cc b/examples/swap_cpp/swap_module1.cc
index 289c4fa..af6f889 100644
--- a/examples/swap_cpp/swap_module1.cc
+++ b/examples/swap_cpp/swap_module1.cc
@@ -5,21 +5,22 @@
#include <lib/app_driver/cpp/app_driver.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/component/cpp/startup_context.h>
+#include <trace-provider/provider.h>
#include "peridot/examples/swap_cpp/module.h"
int main(int /*argc*/, const char** /*argv*/) {
async::Loop loop(&kAsyncLoopConfigAttachToThread);
+ trace::TraceProvider trace_provider(loop.dispatcher());
auto context = component::StartupContext::CreateFromStartupInfo();
modular::AppDriver<modular_example::ModuleApp> driver(
context->outgoing().deprecated_services(),
std::make_unique<modular_example::ModuleApp>(
context.get(),
- [](auto view_manager, auto view_owner_request) {
- return new modular_example::ModuleView(
- std::move(view_manager), std::move(view_owner_request),
- 0xFF00FFFF);
+ [](scenic::ViewContext view_context) {
+ return new modular_example::ModuleView(std::move(view_context),
+ 0xFF00FFFF);
}),
[&loop] { loop.Quit(); });
diff --git a/examples/swap_cpp/swap_module2.cc b/examples/swap_cpp/swap_module2.cc
index 5a5d1b5..2f4ed3b 100644
--- a/examples/swap_cpp/swap_module2.cc
+++ b/examples/swap_cpp/swap_module2.cc
@@ -5,21 +5,22 @@
#include <lib/app_driver/cpp/app_driver.h>
#include <lib/async-loop/cpp/loop.h>
#include <lib/component/cpp/startup_context.h>
+#include <trace-provider/provider.h>
#include "peridot/examples/swap_cpp/module.h"
int main(int /*argc*/, const char** /*argv*/) {
async::Loop loop(&kAsyncLoopConfigAttachToThread);
+ trace::TraceProvider trace_provider(loop.dispatcher());
auto context = component::StartupContext::CreateFromStartupInfo();
modular::AppDriver<modular_example::ModuleApp> driver(
context->outgoing().deprecated_services(),
std::make_unique<modular_example::ModuleApp>(
context.get(),
- [](auto view_manager, auto view_owner_request) {
- return new modular_example::ModuleView(
- std::move(view_manager), std::move(view_owner_request),
- 0xFFFF00FF);
+ [](scenic::ViewContext view_context) {
+ return new modular_example::ModuleView(std::move(view_context),
+ 0xFFFF00FF);
}),
[&loop] { loop.Quit(); });
diff --git a/examples/swap_cpp/swap_recipe.cc b/examples/swap_cpp/swap_recipe.cc
index df3c3b2..abee4e3 100644
--- a/examples/swap_cpp/swap_recipe.cc
+++ b/examples/swap_cpp/swap_recipe.cc
@@ -11,7 +11,9 @@
#include <lib/async/cpp/task.h>
#include <lib/async/default.h>
#include <lib/component/cpp/startup_context.h>
-#include <lib/ui/view_framework/base_view.h>
+#include <lib/ui/base_view/cpp/v1_base_view.h>
+#include <trace-provider/provider.h>
+#include <zx/eventpair.h>
#include "peridot/lib/fidl/single_service_app.h"
@@ -22,38 +24,34 @@
constexpr std::array<const char*, 2> kModuleQueries{
{"swap_module1", "swap_module2"}};
-class RecipeView : public mozart::BaseView {
+class RecipeView : public scenic::V1BaseView {
public:
- explicit RecipeView(
- fuchsia::ui::viewsv1::ViewManagerPtr view_manager,
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request)
- : BaseView(std::move(view_manager), std::move(view_owner_request),
- "RecipeView") {}
+ explicit RecipeView(scenic::ViewContext view_context)
+ : V1BaseView(std::move(view_context), "RecipeView") {}
~RecipeView() override = default;
- void SetChild(fuchsia::ui::viewsv1token::ViewOwnerPtr view_owner) {
+ void SetChild(zx::eventpair view_token) {
if (host_node_) {
- GetViewContainer()->RemoveChild(kChildKey, nullptr);
+ GetViewContainer()->RemoveChild2(kChildKey, zx::eventpair());
host_node_->Detach();
host_node_.reset();
}
- if (view_owner) {
+ if (view_token) {
host_node_ = std::make_unique<scenic::EntityNode>(session());
zx::eventpair host_import_token;
host_node_->ExportAsRequest(&host_import_token);
parent_node().AddChild(*host_node_);
- GetViewContainer()->AddChild(kChildKey, std::move(view_owner),
- std::move(host_import_token));
+ GetViewContainer()->AddChild2(kChildKey, std::move(view_token),
+ std::move(host_import_token));
}
}
private:
- // |BaseView|:
+ // |scenic::V1BaseView|
void OnPropertiesChanged(fuchsia::ui::viewsv1::ViewProperties) override {
if (host_node_) {
auto child_properties = fuchsia::ui::viewsv1::ViewProperties::New();
@@ -77,16 +75,24 @@
~RecipeApp() override = default;
private:
- // |SingleServiceApp|
+ // |ViewApp|
void CreateView(
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request,
- fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> /*services*/)
+ zx::eventpair view_token,
+ fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> incoming_services,
+ fidl::InterfaceHandle<fuchsia::sys::ServiceProvider> outgoing_services)
override {
- view_ = std::make_unique<RecipeView>(
+ auto scenic =
startup_context()
- ->ConnectToEnvironmentService<fuchsia::ui::viewsv1::ViewManager>(),
- std::move(view_owner_request));
+ ->ConnectToEnvironmentService<fuchsia::ui::scenic::Scenic>();
+ scenic::ViewContext view_context = {
+ .session_and_listener_request =
+ scenic::CreateScenicSessionPtrAndListenerRequest(scenic.get()),
+ .view_token = std::move(view_token),
+ .incoming_services = std::move(incoming_services),
+ .outgoing_services = std::move(outgoing_services),
+ .startup_context = startup_context(),
+ };
+ view_ = std::make_unique<RecipeView>(std::move(view_context));
SetChild();
}
@@ -119,7 +125,8 @@
void SetChild() {
if (view_ && module_view_) {
- view_->SetChild(std::move(module_view_));
+ view_->SetChild(
+ zx::eventpair(module_view_.Unbind().TakeChannel().release()));
}
}
@@ -135,6 +142,7 @@
int main(int /*argc*/, const char** /*argv*/) {
async::Loop loop(&kAsyncLoopConfigAttachToThread);
+ trace::TraceProvider trace_provider(loop.dispatcher());
auto context = component::StartupContext::CreateFromStartupInfo();
modular::AppDriver<RecipeApp> driver(
diff --git a/lib/fidl/BUILD.gn b/lib/fidl/BUILD.gn
index 183f0bc..cbf3a3a 100644
--- a/lib/fidl/BUILD.gn
+++ b/lib/fidl/BUILD.gn
@@ -94,11 +94,14 @@
public_deps = [
"//garnet/public/fidl/fuchsia.sys",
+ "//garnet/public/fidl/fuchsia.ui.app",
"//garnet/public/fidl/fuchsia.ui.viewsv1",
+ "//garnet/public/fidl/fuchsia.ui.viewsv1token",
"//garnet/public/lib/component/cpp",
"//garnet/public/lib/fidl/cpp",
"//garnet/public/lib/fxl",
"//peridot/public/fidl/fuchsia.modular",
+ "//zircon/public/lib/zx",
]
}
@@ -110,13 +113,16 @@
public_deps = [
"//garnet/public/lib/component/cpp",
+ "//garnet/public/lib/ui/base_view/cpp",
+ "//zircon/public/lib/zx",
]
deps = [
+ "//garnet/public/fidl/fuchsia.ui.app",
"//garnet/public/fidl/fuchsia.ui.viewsv1",
+ "//garnet/public/fidl/fuchsia.ui.viewsv1token",
"//garnet/public/lib/fsl",
"//garnet/public/lib/fxl",
- "//garnet/public/lib/ui/view_framework",
]
}
diff --git a/lib/fidl/single_service_app.h b/lib/fidl/single_service_app.h
index 4a789ff..f28e778 100644
--- a/lib/fidl/single_service_app.h
+++ b/lib/fidl/single_service_app.h
@@ -5,78 +5,41 @@
#ifndef PERIDOT_LIB_FIDL_SINGLE_SERVICE_APP_H_
#define PERIDOT_LIB_FIDL_SINGLE_SERVICE_APP_H_
-#include <memory>
-
#include <fuchsia/sys/cpp/fidl.h>
+#include <fuchsia/ui/app/cpp/fidl.h>
#include <fuchsia/ui/viewsv1/cpp/fidl.h>
#include <fuchsia/ui/viewsv1token/cpp/fidl.h>
#include <lib/component/cpp/startup_context.h>
#include <lib/fidl/cpp/interface_request.h>
#include <lib/fxl/logging.h>
#include <lib/fxl/macros.h>
+#include <zx/eventpair.h>
+#include <memory>
namespace modular {
-// Base class for a simple application which provides a single instance of a
-// single service and the ViewProvider service. It also implements a Terminate()
-// method that makes it suitable to be used as an Impl class of AppDriver.
-template <class Service>
-class SingleServiceApp : protected Service,
- private fuchsia::ui::viewsv1::ViewProvider {
- public:
- SingleServiceApp(component::StartupContext* const startup_context)
- : startup_context_(startup_context),
- service_binding_(new fidl::Binding<Service>(this)),
- view_provider_binding_(this) {
- startup_context_->outgoing().AddPublicService<Service>(
- [this](fidl::InterfaceRequest<Service> request) {
- FXL_DCHECK(!service_binding_->is_bound());
- service_binding_->Bind(std::move(request));
- });
- startup_context_->outgoing()
- .AddPublicService<fuchsia::ui::viewsv1::ViewProvider>(
- [this](fidl::InterfaceRequest<fuchsia::ui::viewsv1::ViewProvider>
- request) {
- FXL_DCHECK(!view_provider_binding_.is_bound());
- view_provider_binding_.Bind(std::move(request));
- });
- }
-
- ~SingleServiceApp() override = default;
-
- virtual void Terminate(std::function<void()> done) { done(); }
-
- protected:
- component::StartupContext* startup_context() const {
- return startup_context_;
- }
-
- private:
- // |ViewProvider| -- Derived classes may override this method.
- void CreateView(
- fidl::InterfaceRequest<
- fuchsia::ui::viewsv1token::ViewOwner> /*view_owner_request*/,
- fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> /*services*/)
- override {}
-
- component::StartupContext* const startup_context_;
- std::unique_ptr<fidl::Binding<Service>> service_binding_;
- fidl::Binding<fuchsia::ui::viewsv1::ViewProvider> view_provider_binding_;
-
- FXL_DISALLOW_COPY_AND_ASSIGN(SingleServiceApp);
-};
-
// Base class for a simple application which only provides the ViewProvider
// service. It also implements a Terminate() method that makes it suitable to be
// used as an Impl class of AppDriver.
-class ViewApp : private fuchsia::ui::viewsv1::ViewProvider {
+class ViewApp : private fuchsia::ui::app::ViewProvider,
+ private fuchsia::ui::viewsv1::ViewProvider {
public:
ViewApp(component::StartupContext* const startup_context)
- : startup_context_(startup_context), view_provider_binding_(this) {
+ : startup_context_(startup_context),
+ old_view_provider_binding_(this),
+ view_provider_binding_(this) {
startup_context_->outgoing()
.AddPublicService<fuchsia::ui::viewsv1::ViewProvider>(
[this](fidl::InterfaceRequest<fuchsia::ui::viewsv1::ViewProvider>
request) {
+ FXL_DCHECK(!old_view_provider_binding_.is_bound());
+ old_view_provider_binding_.Bind(std::move(request));
+ });
+
+ startup_context_->outgoing()
+ .AddPublicService<fuchsia::ui::app::ViewProvider>(
+ [this](fidl::InterfaceRequest<fuchsia::ui::app::ViewProvider>
+ request) {
FXL_DCHECK(!view_provider_binding_.is_bound());
view_provider_binding_.Bind(std::move(request));
});
@@ -92,19 +55,55 @@
}
private:
- // |ViewProvider| -- Derived classes may override this method.
+ // |ViewProvider|
void CreateView(
- fidl::InterfaceRequest<
- fuchsia::ui::viewsv1token::ViewOwner> /*view_owner_request*/,
- fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> /*services*/)
- override {}
+ fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
+ view_owner_request,
+ fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> services) final {
+ // Forward into fuchsia.ui.app.ViewProvider by "casting" the ViewOwner
+ // channel to an eventpair.
+ CreateView(zx::eventpair(view_owner_request.TakeChannel().release()),
+ std::move(services), nullptr);
+ }
+
+ // |ViewProvider| -- Derived classes should override this method.
+ void CreateView(
+ zx::eventpair /*view_token*/,
+ fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> incoming_services,
+ fidl::InterfaceHandle<
+ fuchsia::sys::ServiceProvider> /*outgoing_services*/) override {}
component::StartupContext* const startup_context_;
- fidl::Binding<fuchsia::ui::viewsv1::ViewProvider> view_provider_binding_;
+ fidl::Binding<fuchsia::ui::viewsv1::ViewProvider> old_view_provider_binding_;
+ fidl::Binding<fuchsia::ui::app::ViewProvider> view_provider_binding_;
FXL_DISALLOW_COPY_AND_ASSIGN(ViewApp);
};
+// Base class for a simple application which provides a single instance of a
+// single service and the ViewProvider service.
+template <class Service>
+class SingleServiceApp : public ViewApp, protected Service {
+ public:
+ SingleServiceApp(component::StartupContext* const start_context)
+ : ViewApp(start_context), service_binding_(this) {
+ // The 'template' is required here because AddPublicService is a dependent
+ // template name.
+ startup_context()->outgoing().template AddPublicService<Service>(
+ [this](fidl::InterfaceRequest<Service> request) {
+ FXL_DCHECK(!service_binding_.is_bound());
+ service_binding_.Bind(std::move(request));
+ });
+ }
+
+ ~SingleServiceApp() override = default;
+
+ private:
+ fidl::Binding<Service> service_binding_;
+
+ FXL_DISALLOW_COPY_AND_ASSIGN(SingleServiceApp);
+};
+
} // namespace modular
#endif // PERIDOT_LIB_FIDL_SINGLE_SERVICE_APP_H_
diff --git a/lib/fidl/view_host.cc b/lib/fidl/view_host.cc
index 822ac5e..5ff24d5 100644
--- a/lib/fidl/view_host.cc
+++ b/lib/fidl/view_host.cc
@@ -6,7 +6,6 @@
#include <lib/fxl/logging.h>
#include <lib/fxl/macros.h>
-#include <lib/ui/view_framework/base_view.h>
namespace modular {
@@ -16,11 +15,8 @@
scenic::EntityNode host_node;
};
-ViewHost::ViewHost(fuchsia::ui::viewsv1::ViewManagerPtr view_manager,
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request)
- : BaseView(std::move(view_manager), std::move(view_owner_request),
- "ViewHost"),
+ViewHost::ViewHost(scenic::ViewContext view_context)
+ : V1BaseView(std::move(view_context), "ViewHost"),
container_node_(session()) {
parent_node().AddChild(container_node_);
}
@@ -38,8 +34,9 @@
container_node_.AddChild(view_data->host_node);
views_.emplace(child_key, std::move(view_data));
- GetViewContainer()->AddChild(child_key, std::move(view_owner),
- std::move(host_import_token));
+ GetViewContainer()->AddChild2(
+ child_key, zx::eventpair(view_owner.TakeChannel().release()),
+ std::move(host_import_token));
UpdateScene();
}
@@ -57,7 +54,7 @@
it->second->host_node.Detach();
views_.erase(it);
- GetViewContainer()->RemoveChild(child_key, nullptr);
+ GetViewContainer()->RemoveChild2(child_key, zx::eventpair());
UpdateScene();
}
diff --git a/lib/fidl/view_host.h b/lib/fidl/view_host.h
index 72c9601..399e8be 100644
--- a/lib/fidl/view_host.h
+++ b/lib/fidl/view_host.h
@@ -11,7 +11,8 @@
#include <fuchsia/ui/viewsv1/cpp/fidl.h>
#include <fuchsia/ui/viewsv1token/cpp/fidl.h>
#include <lib/fxl/macros.h>
-#include <lib/ui/view_framework/base_view.h>
+#include <lib/ui/base_view/cpp/v1_base_view.h>
+#include <zx/eventpair.h>
namespace modular {
@@ -20,11 +21,9 @@
// that play the role of a view controller (aka quarterback, recipe).
// It supports to embed views of *multiple* children, which are laid
// out horizontally.
-class ViewHost : public mozart::BaseView {
+class ViewHost : public scenic::V1BaseView {
public:
- explicit ViewHost(fuchsia::ui::viewsv1::ViewManagerPtr view_manager,
- fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
- view_owner_request);
+ explicit ViewHost(scenic::ViewContext view_context);
~ViewHost() override;
// Connects one more view. Calling this method multiple times adds
@@ -37,7 +36,7 @@
private:
struct ViewData;
- // |BaseView|:
+ // |scenic::V1BaseView|
void OnPropertiesChanged(
fuchsia::ui::viewsv1::ViewProperties old_properties) override;
void OnChildUnavailable(uint32_t child_key) override;
diff --git a/public/lib/app_driver/cpp/module_driver.h b/public/lib/app_driver/cpp/module_driver.h
index 0de34f6..6431f48 100644
--- a/public/lib/app_driver/cpp/module_driver.h
+++ b/public/lib/app_driver/cpp/module_driver.h
@@ -76,6 +76,12 @@
on_terminated_(std::move(on_terminated)) {
context_->ConnectToEnvironmentService(module_context_.NewRequest());
+ context_->outgoing().AddPublicService<fuchsia::ui::app::ViewProvider>(
+ [this](fidl::InterfaceRequest<fuchsia::ui::app::ViewProvider> request) {
+ impl_ = std::make_unique<Impl>(static_cast<ModuleHost*>(this),
+ std::move(request));
+ });
+
context_->outgoing().AddPublicService<fuchsia::ui::viewsv1::ViewProvider>(
[this](fidl::InterfaceRequest<fuchsia::ui::viewsv1::ViewProvider>
request) {
diff --git a/tests/module_context/module_context_test_entity_module.cc b/tests/module_context/module_context_test_entity_module.cc
index 24ca471..521db7b 100644
--- a/tests/module_context/module_context_test_entity_module.cc
+++ b/tests/module_context/module_context_test_entity_module.cc
@@ -34,7 +34,7 @@
"Entity data correct after entity resolution"};
TestApp(modular::ModuleHost* const module_host,
fidl::InterfaceRequest<
- fuchsia::ui::viewsv1::ViewProvider> /*view_provider_request*/)
+ fuchsia::ui::app::ViewProvider> /*view_provider_request*/)
: module_context_(module_host->module_context()) {
modular::testing::Init(module_host->startup_context(), __FILE__);
initialized_.Pass();
@@ -100,6 +100,13 @@
}));
}
+ TestApp(modular::ModuleHost* const module_host,
+ fidl::InterfaceRequest<
+ fuchsia::ui::viewsv1::ViewProvider> /*view_provider_request*/)
+ : TestApp(
+ module_host,
+ fidl::InterfaceRequest<fuchsia::ui::app::ViewProvider>(nullptr)) {}
+
TestPoint stopped_{"Entity module stopped"};
void Terminate(const std::function<void()>& done) {
stopped_.Pass();
diff --git a/tests/session_shell/session_shell_test_session_shell.cc b/tests/session_shell/session_shell_test_session_shell.cc
index 3bcee63..c4f8d03 100644
--- a/tests/session_shell/session_shell_test_session_shell.cc
+++ b/tests/session_shell/session_shell_test_session_shell.cc
@@ -159,10 +159,11 @@
// |SingleServiceApp|
void CreateView(
+ zx::eventpair /*view_token*/,
fidl::InterfaceRequest<
- fuchsia::ui::viewsv1token::ViewOwner> /*view_owner_request*/,
- fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> /*services*/)
- override {
+ fuchsia::sys::ServiceProvider> /*incoming_services*/,
+ fidl::InterfaceHandle<
+ fuchsia::sys::ServiceProvider> /*outgoing_services*/) override {
create_view_.Pass();
}
diff --git a/tests/story_shell/story_shell_test_session_shell.cc b/tests/story_shell/story_shell_test_session_shell.cc
index 5ce7495..793b637 100644
--- a/tests/story_shell/story_shell_test_session_shell.cc
+++ b/tests/story_shell/story_shell_test_session_shell.cc
@@ -101,10 +101,11 @@
// |SingleServiceApp|
void CreateView(
+ zx::eventpair /*view_token*/,
fidl::InterfaceRequest<
- fuchsia::ui::viewsv1token::ViewOwner> /*view_owner_request*/,
- fidl::InterfaceRequest<fuchsia::sys::ServiceProvider> /*services*/)
- override {
+ fuchsia::sys::ServiceProvider> /*incoming_services*/,
+ fidl::InterfaceHandle<
+ fuchsia::sys::ServiceProvider> /*outgoing_services*/) override {
create_view_.Pass();
}