OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package application | 5 package application |
6 | 6 |
7 import ( | 7 import ( |
8 "log" | 8 "log" |
9 | 9 |
10 "mojo/public/go/bindings" | 10 "mojo/public/go/bindings" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 provider := &serviceProviderImpl{ | 104 provider := &serviceProviderImpl{ |
105 make(map[string]ServiceFactory), | 105 make(map[string]ServiceFactory), |
106 } | 106 } |
107 for _, service := range services { | 107 for _, service := range services { |
108 provider.AddService(service) | 108 provider.AddService(service) |
109 } | 109 } |
110 c.localServices = sp.NewServiceProviderStub(*c.servicesRequest, provider
, bindings.GetAsyncWaiter()) | 110 c.localServices = sp.NewServiceProviderStub(*c.servicesRequest, provider
, bindings.GetAsyncWaiter()) |
111 go func() { | 111 go func() { |
112 for { | 112 for { |
113 if err := c.localServices.ServeRequest(); err != nil { | 113 if err := c.localServices.ServeRequest(); err != nil { |
114 » » » » // TODO(rogulenko): don't log in case message pi
pe was closed | 114 » » » » connectionError, ok := err.(*bindings.Connection
Error) |
115 » » » » log.Println(err) | 115 » » » » if !ok || !connectionError.Closed() { |
| 116 » » » » » log.Println(err) |
| 117 » » » » } |
116 break | 118 break |
117 } | 119 } |
118 } | 120 } |
119 }() | 121 }() |
120 return c.outgoingConnection | 122 return c.outgoingConnection |
121 } | 123 } |
122 | 124 |
123 // Close closes both incoming and outgoing parts of the connection. | 125 // Close closes both incoming and outgoing parts of the connection. |
124 func (c *Connection) Close() { | 126 func (c *Connection) Close() { |
125 if c.servicesRequest != nil { | 127 if c.servicesRequest != nil { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 messagePipe.Close() | 167 messagePipe.Close() |
166 return nil | 168 return nil |
167 } | 169 } |
168 factory.Create(messagePipe) | 170 factory.Create(messagePipe) |
169 return nil | 171 return nil |
170 } | 172 } |
171 | 173 |
172 func (sp *serviceProviderImpl) AddService(factory ServiceFactory) { | 174 func (sp *serviceProviderImpl) AddService(factory ServiceFactory) { |
173 sp.factories[factory.Name()] = factory | 175 sp.factories[factory.Name()] = factory |
174 } | 176 } |
OLD | NEW |