| Index: mojo/public/go/application/connection.go
|
| diff --git a/mojo/public/go/application/connection.go b/mojo/public/go/application/connection.go
|
| index f3be55c9a691443630e02d33e3d7bbfe3ffe38db..b226cf133c5bf722c34c3da90e1c23b7110ac815 100644
|
| --- a/mojo/public/go/application/connection.go
|
| +++ b/mojo/public/go/application/connection.go
|
| @@ -11,6 +11,7 @@ import (
|
| "mojo/public/go/system"
|
|
|
| sp "mojo/public/interfaces/application/service_provider"
|
| + "mojo/public/interfaces/bindings/service_describer"
|
| )
|
|
|
| type connectionInfo struct {
|
| @@ -34,6 +35,10 @@ type ServiceRequest interface {
|
| // Name returns the name of requested mojo service.
|
| Name() string
|
|
|
| + // ServiceDescription returns a service description, which can be queried to
|
| + // examine the type information of the requested mojo service.
|
| + ServiceDescription() service_describer.ServiceDescription
|
| +
|
| // PassMessagePipe passes ownership of the underlying message pipe
|
| // handle to the newly created handle object, invalidating the
|
| // underlying handle object in the process.
|
| @@ -45,6 +50,10 @@ type ServiceFactory interface {
|
| // Name returns the name of provided mojo service.
|
| Name() string
|
|
|
| + // ServiceDescription returns a service description, which can be queried to
|
| + // examine the type information of the provided mojo service.
|
| + ServiceDescription() service_describer.ServiceDescription
|
| +
|
| // Create binds an implementation of mojo service to the provided
|
| // message pipe and runs it.
|
| Create(pipe system.MessagePipeHandle)
|
| @@ -62,6 +71,7 @@ type Connection struct {
|
| localServices *bindings.Stub
|
| outgoingConnection *OutgoingConnection
|
| isClosed bool
|
| + describer *ServiceDescriberFactory
|
| }
|
|
|
| func newConnection(requestorURL string, services *sp.ServiceProvider_Request, exposedServices *sp.ServiceProvider_Pointer, resolvedURL string) *Connection {
|
| @@ -122,6 +132,22 @@ func (c *Connection) ProvideServices(services ...ServiceFactory) *OutgoingConnec
|
| return c.outgoingConnection
|
| }
|
|
|
| +// ProvideServicesWithDescriber calls ProvideServices with a ServiceDescriber.
|
| +// The ServiceDescriber will have knowledge of all of the services passed in.
|
| +func (c *Connection) ProvideServicesWithDescriber(services ...ServiceFactory) *OutgoingConnection {
|
| + if c.servicesProvided {
|
| + panic("ProvideServices can be called only once")
|
| + }
|
| + mapping := make(map[string]service_describer.ServiceDescription)
|
| + for _, service := range services {
|
| + mapping[service.Name()] = service.ServiceDescription()
|
| + }
|
| + c.describer = newServiceDescriberFactory(mapping)
|
| + servicesWithDescriber := append(services, &service_describer.ServiceDescriber_ServiceFactory{c.describer})
|
| +
|
| + return c.ProvideServices(servicesWithDescriber...)
|
| +}
|
| +
|
| // Close closes both incoming and outgoing parts of the connection.
|
| func (c *Connection) Close() {
|
| if c.servicesRequest != nil {
|
| @@ -130,6 +156,9 @@ func (c *Connection) Close() {
|
| if c.localServices != nil {
|
| c.localServices.Close()
|
| }
|
| + if c.describer != nil {
|
| + c.describer.Close()
|
| + }
|
| if c.outgoingConnection.remoteServices != nil {
|
| c.outgoingConnection.remoteServices.Close_Proxy()
|
| }
|
|
|