Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1356)

Unified Diff: mojo/public/go/application/connection.go

Issue 1345263002: Generate Mojom Types in Go (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: GetIdentifier without a default Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/go/tests/validation_type_test.go ('k') | mojo/public/go/application/describer.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
rudominer 2015/10/20 21:14:06 s/the provided mojo service/the mojo service/. Th
alexfandrianto 2015/10/20 23:08:03 Done. My original reason for having it was to echo
+ 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.
rudominer 2015/10/20 21:14:06 This method is part of the API consumed by an appl
alexfandrianto 2015/10/20 23:08:03 I improved the comment with most of your suggestio
+func (c *Connection) ProvideServicesWithDescriber(services ...ServiceFactory) *OutgoingConnection {
+ if c.servicesProvided {
+ panic("ProvideServices can be called only once")
rudominer 2015/10/20 21:14:06 "ProvideServices or ProvideServicesWithDescriber c
alexfandrianto 2015/10/20 23:08:03 That's true. Done.
+ }
+ 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()
}
« no previous file with comments | « mojo/go/tests/validation_type_test.go ('k') | mojo/public/go/application/describer.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698