Chromium Code Reviews| Index: examples/echo/echo_server.cc |
| diff --git a/examples/echo/echo_server.cc b/examples/echo/echo_server.cc |
| index 6ff79a68826c38f04029bd8db85b2ddab5eb4a79..3eaf81f7190656969a1467d3cd99d4cd948e1710 100644 |
| --- a/examples/echo/echo_server.cc |
| +++ b/examples/echo/echo_server.cc |
| @@ -7,9 +7,12 @@ |
| #include "mojo/public/c/system/main.h" |
| #include "mojo/public/cpp/application/application_connection.h" |
| #include "mojo/public/cpp/application/application_delegate.h" |
| +#include "mojo/public/cpp/application/application_impl.h" |
| #include "mojo/public/cpp/application/application_runner.h" |
| #include "mojo/public/cpp/application/interface_factory.h" |
| #include "mojo/public/cpp/bindings/strong_binding.h" |
| +#include "mojo/public/cpp/utility/run_loop.h" |
| +#include "mojo/services/vanadium/security/public/interfaces/principal.mojom.h" |
| namespace mojo { |
| namespace examples { |
| @@ -48,15 +51,30 @@ class StrongBindingEchoImpl : public EchoImpl { |
| mojo::StrongBinding<Echo> strong_binding_; |
| }; |
| +class GetBlessingResponse { |
| + public: |
| + void Run(const BlessingPtr& b) const { |
| + // EchoClient user available in b.get()->chain[0]->extension |
|
ataly
2015/07/31 19:04:04
MInor: Should we just say "user identity available
gauthamt
2015/07/31 20:24:16
Done.
|
| + RunLoop::current()->Quit(); |
| + } |
| +}; |
| + |
| // MultiServer creates a new object to handle each message pipe. |
| class MultiServer : public mojo::ApplicationDelegate, |
| public mojo::InterfaceFactory<Echo> { |
| public: |
| MultiServer() {} |
| + void Initialize(ApplicationImpl* app) override { |
| + app->ConnectToService("mojo:go_principal_service", &login_service_); |
| + } |
| + |
| // From ApplicationDelegate |
| bool ConfigureIncomingConnection( |
| mojo::ApplicationConnection* connection) override { |
| + AppNamePtr app(AppName::New()); |
| + app->url = connection->GetRemoteApplicationURL(); |
| + login_service_->GetUserBlessing(app.Pass(), GetBlessingResponse()); |
| connection->AddService<Echo>(this); |
| return true; |
| } |
| @@ -68,6 +86,9 @@ class MultiServer : public mojo::ApplicationDelegate, |
| // StrongBinding<> for the declaration of |strong_binding_|. |
| new StrongBindingEchoImpl(request.Pass()); |
| } |
| + |
| + private: |
| + PrincipalServicePtr login_service_; |
| }; |
| // SingletonServer uses the same object to handle all message pipes. Useful |