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 terminal_client_mojom; | 5 library terminal_client_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_services/mojo/files/file.mojom.dart' as file_mojom; | 10 import 'package:mojo_services/mojo/files/file.mojom.dart' as file_mojom; |
11 | 11 |
12 | 12 |
13 | 13 |
14 class _TerminalClientConnectToTerminalParams extends bindings.Struct { | 14 class _TerminalClientConnectToTerminalParams extends bindings.Struct { |
15 static const List<bindings.StructDataHeader> kVersions = const [ | 15 static const List<bindings.StructDataHeader> kVersions = const [ |
16 const bindings.StructDataHeader(16, 0) | 16 const bindings.StructDataHeader(16, 0) |
17 ]; | 17 ]; |
18 file_mojom.FileInterface terminal = null; | 18 file_mojom.FileInterface terminal = null; |
19 | 19 |
20 _TerminalClientConnectToTerminalParams() : super(kVersions.last.size); | 20 _TerminalClientConnectToTerminalParams() : super(kVersions.last.size); |
21 | 21 |
| 22 _TerminalClientConnectToTerminalParams.init( |
| 23 file_mojom.FileInterface this.terminal |
| 24 ) : super(kVersions.last.size); |
| 25 |
22 static _TerminalClientConnectToTerminalParams deserialize(bindings.Message mes
sage) { | 26 static _TerminalClientConnectToTerminalParams deserialize(bindings.Message mes
sage) { |
23 var decoder = new bindings.Decoder(message); | 27 var decoder = new bindings.Decoder(message); |
24 var result = decode(decoder); | 28 var result = decode(decoder); |
25 if (decoder.excessHandles != null) { | 29 if (decoder.excessHandles != null) { |
26 decoder.excessHandles.forEach((h) => h.close()); | 30 decoder.excessHandles.forEach((h) => h.close()); |
27 } | 31 } |
28 return result; | 32 return result; |
29 } | 33 } |
30 | 34 |
31 static _TerminalClientConnectToTerminalParams decode(bindings.Decoder decoder0
) { | 35 static _TerminalClientConnectToTerminalParams decode(bindings.Decoder decoder0
) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 81 |
78 Map toJson() { | 82 Map toJson() { |
79 throw new bindings.MojoCodecError( | 83 throw new bindings.MojoCodecError( |
80 'Object containing handles cannot be encoded to JSON.'); | 84 'Object containing handles cannot be encoded to JSON.'); |
81 } | 85 } |
82 } | 86 } |
83 | 87 |
84 const int _terminalClientMethodConnectToTerminalName = 0; | 88 const int _terminalClientMethodConnectToTerminalName = 0; |
85 | 89 |
86 class _TerminalClientServiceDescription implements service_describer.ServiceDesc
ription { | 90 class _TerminalClientServiceDescription implements service_describer.ServiceDesc
ription { |
87 dynamic getTopLevelInterface([Function responseFactory]) => | 91 void getTopLevelInterface(Function responder) { |
88 responseFactory(null); | 92 responder(null); |
| 93 } |
89 | 94 |
90 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => | 95 void getTypeDefinition(String typeKey, Function responder) { |
91 responseFactory(null); | 96 responder(null); |
| 97 } |
92 | 98 |
93 dynamic getAllTypeDefinitions([Function responseFactory]) => | 99 void getAllTypeDefinitions(Function responder) { |
94 responseFactory(null); | 100 responder(null); |
| 101 } |
95 } | 102 } |
96 | 103 |
97 abstract class TerminalClient { | 104 abstract class TerminalClient { |
98 static const String serviceName = "mojo::terminal::TerminalClient"; | 105 static const String serviceName = "mojo::terminal::TerminalClient"; |
99 | 106 |
100 static service_describer.ServiceDescription _cachedServiceDescription; | 107 static service_describer.ServiceDescription _cachedServiceDescription; |
101 static service_describer.ServiceDescription get serviceDescription { | 108 static service_describer.ServiceDescription get serviceDescription { |
102 if (_cachedServiceDescription == null) { | 109 if (_cachedServiceDescription == null) { |
103 _cachedServiceDescription = new _TerminalClientServiceDescription(); | 110 _cachedServiceDescription = new _TerminalClientServiceDescription(); |
104 } | 111 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 : super.fromHandle(handle, autoBegin: impl != null) { | 228 : super.fromHandle(handle, autoBegin: impl != null) { |
222 _impl = impl; | 229 _impl = impl; |
223 } | 230 } |
224 | 231 |
225 _TerminalClientStubControl.unbound([this._impl]) : super.unbound(); | 232 _TerminalClientStubControl.unbound([this._impl]) : super.unbound(); |
226 | 233 |
227 String get serviceName => TerminalClient.serviceName; | 234 String get serviceName => TerminalClient.serviceName; |
228 | 235 |
229 | 236 |
230 | 237 |
231 dynamic handleMessage(bindings.ServiceMessage message) { | 238 void handleMessage(bindings.ServiceMessage message) { |
232 if (bindings.ControlMessageHandler.isControlMessage(message)) { | 239 if (bindings.ControlMessageHandler.isControlMessage(message)) { |
233 return bindings.ControlMessageHandler.handleMessage(this, | 240 bindings.ControlMessageHandler.handleMessage( |
234 0, | 241 this, 0, message); |
235 message); | 242 return; |
236 } | 243 } |
237 if (_impl == null) { | 244 if (_impl == null) { |
238 throw new core.MojoApiError("$this has no implementation set"); | 245 throw new core.MojoApiError("$this has no implementation set"); |
239 } | 246 } |
240 switch (message.header.type) { | 247 switch (message.header.type) { |
241 case _terminalClientMethodConnectToTerminalName: | 248 case _terminalClientMethodConnectToTerminalName: |
242 var params = _TerminalClientConnectToTerminalParams.deserialize( | 249 var params = _TerminalClientConnectToTerminalParams.deserialize( |
243 message.payload); | 250 message.payload); |
244 _impl.connectToTerminal(params.terminal); | 251 _impl.connectToTerminal(params.terminal); |
245 break; | 252 break; |
246 default: | 253 default: |
247 throw new bindings.MojoCodecError("Unexpected message name"); | 254 throw new bindings.MojoCodecError("Unexpected message name"); |
248 break; | 255 break; |
249 } | 256 } |
250 return null; | |
251 } | 257 } |
252 | 258 |
253 TerminalClient get impl => _impl; | 259 TerminalClient get impl => _impl; |
254 set impl(TerminalClient d) { | 260 set impl(TerminalClient d) { |
255 if (d == null) { | 261 if (d == null) { |
256 throw new core.MojoApiError("$this: Cannot set a null implementation"); | 262 throw new core.MojoApiError("$this: Cannot set a null implementation"); |
257 } | 263 } |
258 if (isBound && (_impl == null)) { | 264 if (isBound && (_impl == null)) { |
259 beginHandlingEvents(); | 265 beginHandlingEvents(); |
260 } | 266 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 } | 307 } |
302 | 308 |
303 | 309 |
304 void connectToTerminal(file_mojom.FileInterface terminal) { | 310 void connectToTerminal(file_mojom.FileInterface terminal) { |
305 return impl.connectToTerminal(terminal); | 311 return impl.connectToTerminal(terminal); |
306 } | 312 } |
307 } | 313 } |
308 | 314 |
309 | 315 |
310 | 316 |
OLD | NEW |