[scenic] SessionMgr now uses eventpairs

TEST: set_root_view perspective; Ran SysUI
SCN-897 #comment
SCN-1033 #comment

Change-Id: I18d57c41081912c8fcd2d6277854d1d401068399
diff --git a/bin/sessionmgr/sessionmgr_impl.cc b/bin/sessionmgr/sessionmgr_impl.cc
index c64d75d..3ef496c 100644
--- a/bin/sessionmgr/sessionmgr_impl.cc
+++ b/bin/sessionmgr/sessionmgr_impl.cc
@@ -191,6 +191,20 @@
     fidl::InterfaceHandle<fuchsia::modular::internal::UserContext> user_context,
     fidl::InterfaceRequest<fuchsia::ui::viewsv1token::ViewOwner>
         view_owner_request) {
+  Initialize2(std::move(account), std::move(session_shell),
+              std::move(story_shell), std::move(ledger_token_manager),
+              std::move(agent_token_manager), std::move(user_context),
+              zx::eventpair(view_owner_request.TakeChannel().release()));
+}
+
+void SessionmgrImpl::Initialize2(
+    fuchsia::modular::auth::AccountPtr account,
+    fuchsia::modular::AppConfig session_shell,
+    fuchsia::modular::AppConfig story_shell,
+    fidl::InterfaceHandle<fuchsia::auth::TokenManager> ledger_token_manager,
+    fidl::InterfaceHandle<fuchsia::auth::TokenManager> agent_token_manager,
+    fidl::InterfaceHandle<fuchsia::modular::internal::UserContext> user_context,
+    zx::eventpair session_shell_view_token) {
   InitializeUser(std::move(account), std::move(agent_token_manager),
                  std::move(user_context));
   InitializeLedger(std::move(ledger_token_manager));
@@ -198,9 +212,8 @@
   InitializeMessageQueueManager();
   InitializeMaxwellAndModular(session_shell.url, std::move(story_shell));
   InitializeClipboard();
-  InitializeSessionShell(
-      std::move(session_shell),
-      zx::eventpair(view_owner_request.TakeChannel().release()));
+  InitializeSessionShell(std::move(session_shell),
+                         std::move(session_shell_view_token));
 
   ReportEvent(ModularEvent::BOOTED_TO_SESSIONMGR);
 }
@@ -706,11 +719,14 @@
     Logout();
   });
 
-  fuchsia::ui::viewsv1token::ViewOwnerPtr view_owner;
-  fuchsia::ui::viewsv1::ViewProviderPtr view_provider;
+  zx::eventpair view_token, view_holder_token;
+  if (zx::eventpair::create(0u, &view_token, &view_holder_token) != ZX_OK)
+    FXL_NOTREACHED() << "Failed to create view tokens";
+
+  fuchsia::ui::app::ViewProviderPtr view_provider;
   session_shell_app_->services().ConnectToService(view_provider.NewRequest());
-  view_provider->CreateView(view_owner.NewRequest(), nullptr);
-  session_shell_view_host_->ConnectView(std::move(view_owner));
+  view_provider->CreateView(std::move(view_token), nullptr, nullptr);
+  session_shell_view_host_->ConnectView(std::move(view_holder_token));
 
   fuchsia::modular::SessionShellPtr session_shell;
   session_shell_app_->services().ConnectToService(session_shell.NewRequest());
diff --git a/bin/sessionmgr/sessionmgr_impl.h b/bin/sessionmgr/sessionmgr_impl.h
index f1571ae..989bee5 100644
--- a/bin/sessionmgr/sessionmgr_impl.h
+++ b/bin/sessionmgr/sessionmgr_impl.h
@@ -96,6 +96,17 @@
           view_owner_request) override;
 
   // |Sessionmgr|
+  void Initialize2(
+      fuchsia::modular::auth::AccountPtr account,
+      fuchsia::modular::AppConfig session_shell,
+      fuchsia::modular::AppConfig story_shell,
+      fidl::InterfaceHandle<fuchsia::auth::TokenManager> ledger_token_manager,
+      fidl::InterfaceHandle<fuchsia::auth::TokenManager> agent_token_manager,
+      fidl::InterfaceHandle<fuchsia::modular::internal::UserContext>
+          user_context,
+      zx::eventpair session_shell_view_token) override;
+
+  // |Sessionmgr|
   void SwapSessionShell(fuchsia::modular::AppConfig session_shell_config,
                         SwapSessionShellCallback callback) override;
 
diff --git a/public/fidl/fuchsia.modular.internal/sessionmgr.fidl b/public/fidl/fuchsia.modular.internal/sessionmgr.fidl
index 5a9f440..04cc63c 100644
--- a/public/fidl/fuchsia.modular.internal/sessionmgr.fidl
+++ b/public/fidl/fuchsia.modular.internal/sessionmgr.fidl
@@ -19,21 +19,30 @@
     // Launches a sessionmgr instance for a user identified by |user_id| and
     // specific TokenManager handles for ledger and agent_runner.
     // TODO(alhaad): Fold paramters into |UserContext|.
-    1: Initialize(fuchsia.modular.auth.Account? account,
-                  fuchsia.modular.AppConfig session_shell,
-                  fuchsia.modular.AppConfig story_shell,
-                  fuchsia.auth.TokenManager? ledger_token_manager,
-                  fuchsia.auth.TokenManager? agent_token_manager,
-                  UserContext user_context,
-                  request<fuchsia.ui.viewsv1token.ViewOwner>? view_owner);
+    Initialize(fuchsia.modular.auth.Account? account,
+               fuchsia.modular.AppConfig session_shell,
+               fuchsia.modular.AppConfig story_shell,
+               fuchsia.auth.TokenManager? ledger_token_manager,
+               fuchsia.auth.TokenManager? agent_token_manager,
+               UserContext user_context,
+               request<fuchsia.ui.viewsv1token.ViewOwner>? view_owner);
 
-    2: SwapSessionShell(fuchsia.modular.AppConfig session_shell) -> ();
+    [Transitional]
+    Initialize2(fuchsia.modular.auth.Account? account,
+                fuchsia.modular.AppConfig session_shell,
+                fuchsia.modular.AppConfig story_shell,
+                fuchsia.auth.TokenManager? ledger_token_manager,
+                fuchsia.auth.TokenManager? agent_token_manager,
+                UserContext user_context,
+                handle<eventpair> session_shell_view_token);
+
+    SwapSessionShell(fuchsia.modular.AppConfig session_shell) -> ();
 };
 
 // This interface is provided by basemgr to |Sessionmgr|.
 interface UserContext {
     // See detailed comments in SessionShellContext.Logout().
-    1: Logout();
+    Logout();
 
-    2: GetPresentation(request<fuchsia.ui.policy.Presentation> presentation);
+    GetPresentation(request<fuchsia.ui.policy.Presentation> presentation);
 };