OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 library content_handler_mojom; | 5 library content_handler_mojom; |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:mojo/bindings.dart' as bindings; | 7 import 'package:mojo/bindings.dart' as bindings; |
8 import 'package:mojo/core.dart' as core; | 8 import 'package:mojo/core.dart' as core; |
9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; | 9 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic
e_describer; |
10 import 'package:mojo/mojo/application.mojom.dart' as application_mojom; | 10 import 'package:mojo/mojo/application.mojom.dart' as application_mojom; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 107 |
108 dynamic getAllTypeDefinitions([Function responseFactory]) => | 108 dynamic getAllTypeDefinitions([Function responseFactory]) => |
109 responseFactory(null); | 109 responseFactory(null); |
110 } | 110 } |
111 | 111 |
112 abstract class ContentHandler { | 112 abstract class ContentHandler { |
113 static const String serviceName = "mojo::ContentHandler"; | 113 static const String serviceName = "mojo::ContentHandler"; |
114 void startApplication(Object application, url_response_mojom.UrlResponse respo
nse); | 114 void startApplication(Object application, url_response_mojom.UrlResponse respo
nse); |
115 } | 115 } |
116 | 116 |
117 | 117 class _ContentHandlerProxyControl |
118 class _ContentHandlerProxyControl extends bindings.ProxyMessageHandler | 118 extends bindings.ProxyMessageHandler |
119 implements bindings.ProxyControl { | 119 implements bindings.ProxyControl { |
120 _ContentHandlerProxyControl.fromEndpoint( | 120 _ContentHandlerProxyControl.fromEndpoint( |
121 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 121 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
122 | 122 |
123 _ContentHandlerProxyControl.fromHandle( | 123 _ContentHandlerProxyControl.fromHandle( |
124 core.MojoHandle handle) : super.fromHandle(handle); | 124 core.MojoHandle handle) : super.fromHandle(handle); |
125 | 125 |
126 _ContentHandlerProxyControl.unbound() : super.unbound(); | 126 _ContentHandlerProxyControl.unbound() : super.unbound(); |
127 | 127 |
128 service_describer.ServiceDescription get serviceDescription => | 128 service_describer.ServiceDescription get serviceDescription => |
129 new _ContentHandlerServiceDescription(); | 129 new _ContentHandlerServiceDescription(); |
130 | 130 |
131 String get serviceName => ContentHandler.serviceName; | 131 String get serviceName => ContentHandler.serviceName; |
132 | 132 |
133 @override | |
134 void handleResponse(bindings.ServiceMessage message) { | 133 void handleResponse(bindings.ServiceMessage message) { |
135 switch (message.header.type) { | 134 switch (message.header.type) { |
136 default: | 135 default: |
137 proxyError("Unexpected message type: ${message.header.type}"); | 136 proxyError("Unexpected message type: ${message.header.type}"); |
138 close(immediate: true); | 137 close(immediate: true); |
139 break; | 138 break; |
140 } | 139 } |
141 } | 140 } |
142 | 141 |
143 @override | 142 @override |
144 String toString() { | 143 String toString() { |
145 var superString = super.toString(); | 144 var superString = super.toString(); |
146 return "_ContentHandlerProxyControl($superString)"; | 145 return "_ContentHandlerProxyControl($superString)"; |
147 } | 146 } |
148 } | 147 } |
149 | 148 |
150 | 149 class ContentHandlerProxy |
151 class ContentHandlerProxy extends bindings.Proxy | 150 extends bindings.Proxy |
152 implements ContentHandler { | 151 implements ContentHandler { |
153 ContentHandlerProxy.fromEndpoint( | 152 ContentHandlerProxy.fromEndpoint( |
154 core.MojoMessagePipeEndpoint endpoint) | 153 core.MojoMessagePipeEndpoint endpoint) |
155 : super(new _ContentHandlerProxyControl.fromEndpoint(endpoint)); | 154 : super(new _ContentHandlerProxyControl.fromEndpoint(endpoint)); |
156 | 155 |
157 ContentHandlerProxy.fromHandle(core.MojoHandle handle) | 156 ContentHandlerProxy.fromHandle(core.MojoHandle handle) |
158 : super(new _ContentHandlerProxyControl.fromHandle(handle)); | 157 : super(new _ContentHandlerProxyControl.fromHandle(handle)); |
159 | 158 |
160 ContentHandlerProxy.unbound() | 159 ContentHandlerProxy.unbound() |
161 : super(new _ContentHandlerProxyControl.unbound()); | 160 : super(new _ContentHandlerProxyControl.unbound()); |
162 | 161 |
(...skipping 17 matching lines...) Expand all Loading... |
180 return; | 179 return; |
181 } | 180 } |
182 var params = new _ContentHandlerStartApplicationParams(); | 181 var params = new _ContentHandlerStartApplicationParams(); |
183 params.application = application; | 182 params.application = application; |
184 params.response = response; | 183 params.response = response; |
185 ctrl.sendMessage(params, | 184 ctrl.sendMessage(params, |
186 _contentHandlerMethodStartApplicationName); | 185 _contentHandlerMethodStartApplicationName); |
187 } | 186 } |
188 } | 187 } |
189 | 188 |
190 | 189 class _ContentHandlerStubControl |
191 class ContentHandlerStub extends bindings.Stub { | 190 extends bindings.StubMessageHandler |
| 191 implements bindings.StubControl<ContentHandler> { |
192 ContentHandler _impl; | 192 ContentHandler _impl; |
193 | 193 |
194 ContentHandlerStub.fromEndpoint( | 194 _ContentHandlerStubControl.fromEndpoint( |
195 core.MojoMessagePipeEndpoint endpoint, [ContentHandler impl]) | 195 core.MojoMessagePipeEndpoint endpoint, [ContentHandler impl]) |
196 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 196 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
197 _impl = impl; | 197 _impl = impl; |
198 } | 198 } |
199 | 199 |
200 ContentHandlerStub.fromHandle( | 200 _ContentHandlerStubControl.fromHandle( |
201 core.MojoHandle handle, [ContentHandler impl]) | 201 core.MojoHandle handle, [ContentHandler impl]) |
202 : super.fromHandle(handle, autoBegin: impl != null) { | 202 : super.fromHandle(handle, autoBegin: impl != null) { |
203 _impl = impl; | 203 _impl = impl; |
204 } | 204 } |
205 | 205 |
206 ContentHandlerStub.unbound([this._impl]) : super.unbound(); | 206 _ContentHandlerStubControl.unbound([this._impl]) : super.unbound(); |
207 | |
208 static ContentHandlerStub newFromEndpoint( | |
209 core.MojoMessagePipeEndpoint endpoint) { | |
210 assert(endpoint.setDescription("For ContentHandlerStub")); | |
211 return new ContentHandlerStub.fromEndpoint(endpoint); | |
212 } | |
213 | 207 |
214 | 208 |
215 | 209 |
216 dynamic handleMessage(bindings.ServiceMessage message) { | 210 dynamic handleMessage(bindings.ServiceMessage message) { |
217 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 211 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
218 return bindings.ControlMessageHandler.handleMessage(this, | 212 return bindings.ControlMessageHandler.handleMessage(this, |
219 0, | 213 0, |
220 message); | 214 message); |
221 } | 215 } |
222 if (_impl == null) { | 216 if (_impl == null) { |
(...skipping 24 matching lines...) Expand all Loading... |
247 } | 241 } |
248 | 242 |
249 @override | 243 @override |
250 void bind(core.MojoMessagePipeEndpoint endpoint) { | 244 void bind(core.MojoMessagePipeEndpoint endpoint) { |
251 super.bind(endpoint); | 245 super.bind(endpoint); |
252 if (!isOpen && (_impl != null)) { | 246 if (!isOpen && (_impl != null)) { |
253 beginHandlingEvents(); | 247 beginHandlingEvents(); |
254 } | 248 } |
255 } | 249 } |
256 | 250 |
| 251 @override |
257 String toString() { | 252 String toString() { |
258 var superString = super.toString(); | 253 var superString = super.toString(); |
259 return "ContentHandlerStub($superString)"; | 254 return "_ContentHandlerStubControl($superString)"; |
260 } | 255 } |
261 | 256 |
262 int get version => 0; | 257 int get version => 0; |
263 | 258 |
264 static service_describer.ServiceDescription _cachedServiceDescription; | 259 static service_describer.ServiceDescription _cachedServiceDescription; |
265 static service_describer.ServiceDescription get serviceDescription { | 260 static service_describer.ServiceDescription get serviceDescription { |
266 if (_cachedServiceDescription == null) { | 261 if (_cachedServiceDescription == null) { |
267 _cachedServiceDescription = new _ContentHandlerServiceDescription(); | 262 _cachedServiceDescription = new _ContentHandlerServiceDescription(); |
268 } | 263 } |
269 return _cachedServiceDescription; | 264 return _cachedServiceDescription; |
270 } | 265 } |
271 } | 266 } |
272 | 267 |
| 268 class ContentHandlerStub |
| 269 extends bindings.Stub<ContentHandler> |
| 270 implements ContentHandler { |
| 271 ContentHandlerStub.fromEndpoint( |
| 272 core.MojoMessagePipeEndpoint endpoint, [ContentHandler impl]) |
| 273 : super(new _ContentHandlerStubControl.fromEndpoint(endpoint, impl)); |
| 274 |
| 275 ContentHandlerStub.fromHandle( |
| 276 core.MojoHandle handle, [ContentHandler impl]) |
| 277 : super(new _ContentHandlerStubControl.fromHandle(handle, impl)); |
| 278 |
| 279 ContentHandlerStub.unbound([ContentHandler impl]) |
| 280 : super(new _ContentHandlerStubControl.unbound(impl)); |
| 281 |
| 282 static ContentHandlerStub newFromEndpoint( |
| 283 core.MojoMessagePipeEndpoint endpoint) { |
| 284 assert(endpoint.setDescription("For ContentHandlerStub")); |
| 285 return new ContentHandlerStub.fromEndpoint(endpoint); |
| 286 } |
| 287 |
| 288 static service_describer.ServiceDescription get serviceDescription => |
| 289 _ContentHandlerStubControl.serviceDescription; |
| 290 |
| 291 |
| 292 void startApplication(Object application, url_response_mojom.UrlResponse respo
nse) { |
| 293 return impl.startApplication(application, response); |
| 294 } |
| 295 } |
| 296 |
273 | 297 |
274 | 298 |
OLD | NEW |