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

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

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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/public/go/application/connection.go ('k') | mojo/public/go/bindings/async_waiter.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/go/application/describer.go
diff --git a/mojo/public/go/application/describer.go b/mojo/public/go/application/describer.go
deleted file mode 100644
index 09eceb1a08df09a75fc8dba2febcd7b64e3b6d84..0000000000000000000000000000000000000000
--- a/mojo/public/go/application/describer.go
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package application
-
-import (
- "fmt"
- "log"
-
- "mojo/public/go/bindings"
-
- "mojo/public/interfaces/bindings/mojom_types"
- "mojo/public/interfaces/bindings/service_describer"
-)
-
-// ServiceDescriberFactory implements ServiceFactory for ServiceDescriber.
-// For cleanup purposes, it is also the implementation of a ServiceDescriber.
-type ServiceDescriberFactory struct {
- // mapping holds the map from interface names to ServiceDescription's.
- mapping map[string]service_describer.ServiceDescription
- // stubs stores the stubs for connections opened to this factory.
- stubs []*bindings.Stub
- // descriptionFactories maps interface names to ServiceDescriptionFactory's.
- descriptionFactories map[string]*ServiceDescriptionFactory
-}
-
-func newServiceDescriberFactory(mapping map[string]service_describer.ServiceDescription) *ServiceDescriberFactory {
- return &ServiceDescriberFactory{
- mapping: mapping,
- descriptionFactories: make(map[string]*ServiceDescriptionFactory),
- }
-}
-
-func (sd *ServiceDescriberFactory) Create(request service_describer.ServiceDescriber_Request) {
- stub := service_describer.NewServiceDescriberStub(request, sd, bindings.GetAsyncWaiter())
- sd.stubs = append(sd.stubs, stub)
- go func() {
- for {
- if err := stub.ServeRequest(); err != nil {
- connectionError, ok := err.(*bindings.ConnectionError)
- if !ok || !connectionError.Closed() {
- log.Println(err)
- }
- break
- }
- }
- }()
-}
-
-func (sd *ServiceDescriberFactory) Close() {
- for _, stub := range sd.stubs {
- stub.Close()
- }
- for _, factory := range sd.descriptionFactories {
- for _, stub := range factory.stubs {
- stub.Close()
- }
- }
-}
-
-// Helper method for DescribeService
-func (sd *ServiceDescriberFactory) getServiceDescriptionFactory(inInterfaceName string) *ServiceDescriptionFactory {
- // Assumes the interface name is in the mapping.
- if desc, ok := sd.descriptionFactories[inInterfaceName]; ok {
- return desc
- }
- sd.descriptionFactories[inInterfaceName] = &ServiceDescriptionFactory{
- impl: sd.mapping[inInterfaceName],
- }
- return sd.descriptionFactories[inInterfaceName]
-}
-
-func (sd *ServiceDescriberFactory) DescribeService(inInterfaceName string, inDescriptionRequest service_describer.ServiceDescription_Request) (err error) {
- if _, ok := sd.mapping[inInterfaceName]; ok {
- sd.getServiceDescriptionFactory(inInterfaceName).Create(inDescriptionRequest)
- return nil
- }
- return fmt.Errorf("The interface %s is unknown by this application", inInterfaceName)
-}
-
-// ServiceDescriptionFactory implements ServiceFactory for ServiceDescription.
-type ServiceDescriptionFactory struct {
- // stubs stores the stubs for connections opened to this factory.
- stubs []*bindings.Stub
- // impl is the ServiceDescription implementation served by this factory.
- impl service_describer.ServiceDescription
-}
-
-func (serviceDescriptionFactory *ServiceDescriptionFactory) Create(request service_describer.ServiceDescription_Request) {
- stub := service_describer.NewServiceDescriptionStub(request, serviceDescriptionFactory.impl, bindings.GetAsyncWaiter())
- serviceDescriptionFactory.stubs = append(serviceDescriptionFactory.stubs, stub)
- go func() {
- for {
- if err := stub.ServeRequest(); err != nil {
- connectionError, ok := err.(*bindings.ConnectionError)
- if !ok || !connectionError.Closed() {
- log.Println(err)
- }
- break
- }
- }
- }()
-}
-
-// ObjectWithMojomTypeSupport is an interface implemented by pointers to
-// Mojo structs, enums, interface requests and union variants, but only if the
-// support of runtime mojom type information was enabled at build time.
-type ObjectWithMojomTypeSupport interface {
- // MojomType returns the UserDefinedType that describes the Mojom
- // type of this object. To obtain the UserDefinedType for Mojom types recursively
- // contained in the returned UserDefinedType, look in the map returned
- // by the function AllMojomTypes().
- MojomType() mojom_types.UserDefinedType
-
- // AllMojomTypes returns a map that contains the UserDefinedType for
- // all Mojom types in the complete type graph of the Mojom type of this object.
- AllMojomTypes() map[string]mojom_types.UserDefinedType
-}
« no previous file with comments | « mojo/public/go/application/connection.go ('k') | mojo/public/go/bindings/async_waiter.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698