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 view_token_mojom; | 5 library view_token_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 | 10 |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 dynamic getAllTypeDefinitions([Function responseFactory]) => | 224 dynamic getAllTypeDefinitions([Function responseFactory]) => |
225 responseFactory(null); | 225 responseFactory(null); |
226 } | 226 } |
227 | 227 |
228 abstract class ViewOwner { | 228 abstract class ViewOwner { |
229 static const String serviceName = null; | 229 static const String serviceName = null; |
230 dynamic getToken([Function responseFactory = null]); | 230 dynamic getToken([Function responseFactory = null]); |
231 } | 231 } |
232 | 232 |
233 | 233 |
234 class _ViewOwnerProxyImpl extends bindings.Proxy { | 234 class _ViewOwnerProxyControl extends bindings.ProxyMessageHandler |
235 _ViewOwnerProxyImpl.fromEndpoint( | 235 implements bindings.ProxyControl { |
| 236 _ViewOwnerProxyControl.fromEndpoint( |
236 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); | 237 core.MojoMessagePipeEndpoint endpoint) : super.fromEndpoint(endpoint); |
237 | 238 |
238 _ViewOwnerProxyImpl.fromHandle(core.MojoHandle handle) : | 239 _ViewOwnerProxyControl.fromHandle( |
239 super.fromHandle(handle); | 240 core.MojoHandle handle) : super.fromHandle(handle); |
240 | 241 |
241 _ViewOwnerProxyImpl.unbound() : super.unbound(); | 242 _ViewOwnerProxyControl.unbound() : super.unbound(); |
242 | |
243 static _ViewOwnerProxyImpl newFromEndpoint( | |
244 core.MojoMessagePipeEndpoint endpoint) { | |
245 assert(endpoint.setDescription("For _ViewOwnerProxyImpl")); | |
246 return new _ViewOwnerProxyImpl.fromEndpoint(endpoint); | |
247 } | |
248 | 243 |
249 service_describer.ServiceDescription get serviceDescription => | 244 service_describer.ServiceDescription get serviceDescription => |
250 new _ViewOwnerServiceDescription(); | 245 new _ViewOwnerServiceDescription(); |
251 | 246 |
| 247 String get serviceName => ViewOwner.serviceName; |
| 248 |
| 249 @override |
252 void handleResponse(bindings.ServiceMessage message) { | 250 void handleResponse(bindings.ServiceMessage message) { |
253 switch (message.header.type) { | 251 switch (message.header.type) { |
254 case _viewOwnerMethodGetTokenName: | 252 case _viewOwnerMethodGetTokenName: |
255 var r = ViewOwnerGetTokenResponseParams.deserialize( | 253 var r = ViewOwnerGetTokenResponseParams.deserialize( |
256 message.payload); | 254 message.payload); |
257 if (!message.header.hasRequestId) { | 255 if (!message.header.hasRequestId) { |
258 proxyError("Expected a message with a valid request Id."); | 256 proxyError("Expected a message with a valid request Id."); |
259 return; | 257 return; |
260 } | 258 } |
261 Completer c = completerMap[message.header.requestId]; | 259 Completer c = completerMap[message.header.requestId]; |
262 if (c == null) { | 260 if (c == null) { |
263 proxyError( | 261 proxyError( |
264 "Message had unknown request Id: ${message.header.requestId}"); | 262 "Message had unknown request Id: ${message.header.requestId}"); |
265 return; | 263 return; |
266 } | 264 } |
267 completerMap.remove(message.header.requestId); | 265 completerMap.remove(message.header.requestId); |
268 if (c.isCompleted) { | 266 if (c.isCompleted) { |
269 proxyError("Response completer already completed"); | 267 proxyError("Response completer already completed"); |
270 return; | 268 return; |
271 } | 269 } |
272 c.complete(r); | 270 c.complete(r); |
273 break; | 271 break; |
274 default: | 272 default: |
275 proxyError("Unexpected message type: ${message.header.type}"); | 273 proxyError("Unexpected message type: ${message.header.type}"); |
276 close(immediate: true); | 274 close(immediate: true); |
277 break; | 275 break; |
278 } | 276 } |
279 } | 277 } |
280 | 278 |
| 279 @override |
281 String toString() { | 280 String toString() { |
282 var superString = super.toString(); | 281 var superString = super.toString(); |
283 return "_ViewOwnerProxyImpl($superString)"; | 282 return "_ViewOwnerProxyControl($superString)"; |
284 } | 283 } |
285 } | 284 } |
286 | 285 |
287 | 286 |
288 class _ViewOwnerProxyCalls implements ViewOwner { | 287 class ViewOwnerProxy extends bindings.Proxy |
289 _ViewOwnerProxyImpl _proxyImpl; | 288 implements ViewOwner { |
| 289 ViewOwnerProxy.fromEndpoint( |
| 290 core.MojoMessagePipeEndpoint endpoint) |
| 291 : super(new _ViewOwnerProxyControl.fromEndpoint(endpoint)); |
290 | 292 |
291 _ViewOwnerProxyCalls(this._proxyImpl); | 293 ViewOwnerProxy.fromHandle(core.MojoHandle handle) |
292 dynamic getToken([Function responseFactory = null]) { | 294 : super(new _ViewOwnerProxyControl.fromHandle(handle)); |
293 var params = new _ViewOwnerGetTokenParams(); | |
294 return _proxyImpl.sendMessageWithRequestId( | |
295 params, | |
296 _viewOwnerMethodGetTokenName, | |
297 -1, | |
298 bindings.MessageHeader.kMessageExpectsResponse); | |
299 } | |
300 } | |
301 | 295 |
| 296 ViewOwnerProxy.unbound() |
| 297 : super(new _ViewOwnerProxyControl.unbound()); |
302 | 298 |
303 class ViewOwnerProxy implements bindings.ProxyBase { | 299 static ViewOwnerProxy newFromEndpoint( |
304 final bindings.Proxy impl; | 300 core.MojoMessagePipeEndpoint endpoint) { |
305 ViewOwner ptr; | 301 assert(endpoint.setDescription("For ViewOwnerProxy")); |
306 | 302 return new ViewOwnerProxy.fromEndpoint(endpoint); |
307 ViewOwnerProxy(_ViewOwnerProxyImpl proxyImpl) : | |
308 impl = proxyImpl, | |
309 ptr = new _ViewOwnerProxyCalls(proxyImpl); | |
310 | |
311 ViewOwnerProxy.fromEndpoint( | |
312 core.MojoMessagePipeEndpoint endpoint) : | |
313 impl = new _ViewOwnerProxyImpl.fromEndpoint(endpoint) { | |
314 ptr = new _ViewOwnerProxyCalls(impl); | |
315 } | |
316 | |
317 ViewOwnerProxy.fromHandle(core.MojoHandle handle) : | |
318 impl = new _ViewOwnerProxyImpl.fromHandle(handle) { | |
319 ptr = new _ViewOwnerProxyCalls(impl); | |
320 } | |
321 | |
322 ViewOwnerProxy.unbound() : | |
323 impl = new _ViewOwnerProxyImpl.unbound() { | |
324 ptr = new _ViewOwnerProxyCalls(impl); | |
325 } | 303 } |
326 | 304 |
327 factory ViewOwnerProxy.connectToService( | 305 factory ViewOwnerProxy.connectToService( |
328 bindings.ServiceConnector s, String url, [String serviceName]) { | 306 bindings.ServiceConnector s, String url, [String serviceName]) { |
329 ViewOwnerProxy p = new ViewOwnerProxy.unbound(); | 307 ViewOwnerProxy p = new ViewOwnerProxy.unbound(); |
330 s.connectToService(url, p, serviceName); | 308 s.connectToService(url, p, serviceName); |
331 return p; | 309 return p; |
332 } | 310 } |
333 | 311 |
334 static ViewOwnerProxy newFromEndpoint( | |
335 core.MojoMessagePipeEndpoint endpoint) { | |
336 assert(endpoint.setDescription("For ViewOwnerProxy")); | |
337 return new ViewOwnerProxy.fromEndpoint(endpoint); | |
338 } | |
339 | 312 |
340 String get serviceName => ViewOwner.serviceName; | 313 dynamic getToken([Function responseFactory = null]) { |
341 | 314 var params = new _ViewOwnerGetTokenParams(); |
342 Future close({bool immediate: false}) => impl.close(immediate: immediate); | 315 return ctrl.sendMessageWithRequestId( |
343 | 316 params, |
344 Future responseOrError(Future f) => impl.responseOrError(f); | 317 _viewOwnerMethodGetTokenName, |
345 | 318 -1, |
346 Future get errorFuture => impl.errorFuture; | 319 bindings.MessageHeader.kMessageExpectsResponse); |
347 | |
348 int get version => impl.version; | |
349 | |
350 Future<int> queryVersion() => impl.queryVersion(); | |
351 | |
352 void requireVersion(int requiredVersion) { | |
353 impl.requireVersion(requiredVersion); | |
354 } | |
355 | |
356 String toString() { | |
357 return "ViewOwnerProxy($impl)"; | |
358 } | 320 } |
359 } | 321 } |
360 | 322 |
361 | 323 |
362 class ViewOwnerStub extends bindings.Stub { | 324 class ViewOwnerStub extends bindings.Stub { |
363 ViewOwner _impl; | 325 ViewOwner _impl; |
364 | 326 |
365 ViewOwnerStub.fromEndpoint( | 327 ViewOwnerStub.fromEndpoint( |
366 core.MojoMessagePipeEndpoint endpoint, [ViewOwner impl]) | 328 core.MojoMessagePipeEndpoint endpoint, [ViewOwner impl]) |
367 : super.fromEndpoint(endpoint, autoBegin: impl != null) { | 329 : super.fromEndpoint(endpoint, autoBegin: impl != null) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 static service_describer.ServiceDescription get serviceDescription { | 418 static service_describer.ServiceDescription get serviceDescription { |
457 if (_cachedServiceDescription == null) { | 419 if (_cachedServiceDescription == null) { |
458 _cachedServiceDescription = new _ViewOwnerServiceDescription(); | 420 _cachedServiceDescription = new _ViewOwnerServiceDescription(); |
459 } | 421 } |
460 return _cachedServiceDescription; | 422 return _cachedServiceDescription; |
461 } | 423 } |
462 } | 424 } |
463 | 425 |
464 | 426 |
465 | 427 |
OLD | NEW |