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

Side by Side Diff: mojo/dart/packages/mojo_services/lib/mojo/files/files.mojom.dart

Issue 2006093002: Dart: Futures -> Callbacks. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Merge Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // WARNING: DO NOT EDIT. This file was generated by a program. 1 // WARNING: DO NOT EDIT. This file was generated by a program.
2 // See $MOJO_SDK/tools/bindings/mojom_bindings_generator.py. 2 // See $MOJO_SDK/tools/bindings/mojom_bindings_generator.py.
3 3
4 library files_mojom; 4 library files_mojom;
5 import 'dart:async'; 5 import 'dart:async';
6 import 'package:mojo/bindings.dart' as bindings; 6 import 'package:mojo/bindings.dart' as bindings;
7 import 'package:mojo/core.dart' as core; 7 import 'package:mojo/core.dart' as core;
8 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer; 8 import 'package:mojo/mojo/bindings/types/service_describer.mojom.dart' as servic e_describer;
9 import 'package:mojo_services/mojo/files/directory.mojom.dart' as directory_mojo m; 9 import 'package:mojo_services/mojo/files/directory.mojom.dart' as directory_mojo m;
10 import 'package:mojo_services/mojo/files/types.mojom.dart' as types_mojom; 10 import 'package:mojo_services/mojo/files/types.mojom.dart' as types_mojom;
11 11
12 12
13 13
14 class _FilesOpenFileSystemParams extends bindings.Struct { 14 class _FilesOpenFileSystemParams extends bindings.Struct {
15 static const List<bindings.StructDataHeader> kVersions = const [ 15 static const List<bindings.StructDataHeader> kVersions = const [
16 const bindings.StructDataHeader(24, 0) 16 const bindings.StructDataHeader(24, 0)
17 ]; 17 ];
18 String fileSystem = null; 18 String fileSystem = null;
19 directory_mojom.DirectoryInterfaceRequest directory = null; 19 directory_mojom.DirectoryInterfaceRequest directory = null;
20 20
21 _FilesOpenFileSystemParams() : super(kVersions.last.size); 21 _FilesOpenFileSystemParams() : super(kVersions.last.size);
22 22
23 _FilesOpenFileSystemParams.init(
24 String this.fileSystem,
25 directory_mojom.DirectoryInterfaceRequest this.directory
26 ) : super(kVersions.last.size);
27
23 static _FilesOpenFileSystemParams deserialize(bindings.Message message) { 28 static _FilesOpenFileSystemParams deserialize(bindings.Message message) {
24 var decoder = new bindings.Decoder(message); 29 var decoder = new bindings.Decoder(message);
25 var result = decode(decoder); 30 var result = decode(decoder);
26 if (decoder.excessHandles != null) { 31 if (decoder.excessHandles != null) {
27 decoder.excessHandles.forEach((h) => h.close()); 32 decoder.excessHandles.forEach((h) => h.close());
28 } 33 }
29 return result; 34 return result;
30 } 35 }
31 36
32 static _FilesOpenFileSystemParams decode(bindings.Decoder decoder0) { 37 static _FilesOpenFileSystemParams decode(bindings.Decoder decoder0) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 101
97 102
98 class FilesOpenFileSystemResponseParams extends bindings.Struct { 103 class FilesOpenFileSystemResponseParams extends bindings.Struct {
99 static const List<bindings.StructDataHeader> kVersions = const [ 104 static const List<bindings.StructDataHeader> kVersions = const [
100 const bindings.StructDataHeader(16, 0) 105 const bindings.StructDataHeader(16, 0)
101 ]; 106 ];
102 types_mojom.Error error = null; 107 types_mojom.Error error = null;
103 108
104 FilesOpenFileSystemResponseParams() : super(kVersions.last.size); 109 FilesOpenFileSystemResponseParams() : super(kVersions.last.size);
105 110
111 FilesOpenFileSystemResponseParams.init(
112 types_mojom.Error this.error
113 ) : super(kVersions.last.size);
114
106 static FilesOpenFileSystemResponseParams deserialize(bindings.Message message) { 115 static FilesOpenFileSystemResponseParams deserialize(bindings.Message message) {
107 var decoder = new bindings.Decoder(message); 116 var decoder = new bindings.Decoder(message);
108 var result = decode(decoder); 117 var result = decode(decoder);
109 if (decoder.excessHandles != null) { 118 if (decoder.excessHandles != null) {
110 decoder.excessHandles.forEach((h) => h.close()); 119 decoder.excessHandles.forEach((h) => h.close());
111 } 120 }
112 return result; 121 return result;
113 } 122 }
114 123
115 static FilesOpenFileSystemResponseParams decode(bindings.Decoder decoder0) { 124 static FilesOpenFileSystemResponseParams decode(bindings.Decoder decoder0) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 Map toJson() { 175 Map toJson() {
167 Map map = new Map(); 176 Map map = new Map();
168 map["error"] = error; 177 map["error"] = error;
169 return map; 178 return map;
170 } 179 }
171 } 180 }
172 181
173 const int _filesMethodOpenFileSystemName = 0; 182 const int _filesMethodOpenFileSystemName = 0;
174 183
175 class _FilesServiceDescription implements service_describer.ServiceDescription { 184 class _FilesServiceDescription implements service_describer.ServiceDescription {
176 dynamic getTopLevelInterface([Function responseFactory]) => 185 void getTopLevelInterface(Function responder) {
177 responseFactory(null); 186 responder(null);
187 }
178 188
179 dynamic getTypeDefinition(String typeKey, [Function responseFactory]) => 189 void getTypeDefinition(String typeKey, Function responder) {
180 responseFactory(null); 190 responder(null);
191 }
181 192
182 dynamic getAllTypeDefinitions([Function responseFactory]) => 193 void getAllTypeDefinitions(Function responder) {
183 responseFactory(null); 194 responder(null);
195 }
184 } 196 }
185 197
186 abstract class Files { 198 abstract class Files {
187 static const String serviceName = "mojo::files::Files"; 199 static const String serviceName = "mojo::files::Files";
188 200
189 static service_describer.ServiceDescription _cachedServiceDescription; 201 static service_describer.ServiceDescription _cachedServiceDescription;
190 static service_describer.ServiceDescription get serviceDescription { 202 static service_describer.ServiceDescription get serviceDescription {
191 if (_cachedServiceDescription == null) { 203 if (_cachedServiceDescription == null) {
192 _cachedServiceDescription = new _FilesServiceDescription(); 204 _cachedServiceDescription = new _FilesServiceDescription();
193 } 205 }
194 return _cachedServiceDescription; 206 return _cachedServiceDescription;
195 } 207 }
196 208
197 static FilesProxy connectToService( 209 static FilesProxy connectToService(
198 bindings.ServiceConnector s, String url, [String serviceName]) { 210 bindings.ServiceConnector s, String url, [String serviceName]) {
199 FilesProxy p = new FilesProxy.unbound(); 211 FilesProxy p = new FilesProxy.unbound();
200 String name = serviceName ?? Files.serviceName; 212 String name = serviceName ?? Files.serviceName;
201 if ((name == null) || name.isEmpty) { 213 if ((name == null) || name.isEmpty) {
202 throw new core.MojoApiError( 214 throw new core.MojoApiError(
203 "If an interface has no ServiceName, then one must be provided."); 215 "If an interface has no ServiceName, then one must be provided.");
204 } 216 }
205 s.connectToService(url, p, name); 217 s.connectToService(url, p, name);
206 return p; 218 return p;
207 } 219 }
208 dynamic openFileSystem(String fileSystem,directory_mojom.DirectoryInterfaceReq uest directory,[Function responseFactory = null]); 220 void openFileSystem(String fileSystem,directory_mojom.DirectoryInterfaceReques t directory,void callback(types_mojom.Error error));
209 } 221 }
210 222
211 abstract class FilesInterface 223 abstract class FilesInterface
212 implements bindings.MojoInterface<Files>, 224 implements bindings.MojoInterface<Files>,
213 Files { 225 Files {
214 factory FilesInterface([Files impl]) => 226 factory FilesInterface([Files impl]) =>
215 new FilesStub.unbound(impl); 227 new FilesStub.unbound(impl);
216 228
217 factory FilesInterface.fromEndpoint( 229 factory FilesInterface.fromEndpoint(
218 core.MojoMessagePipeEndpoint endpoint, 230 core.MojoMessagePipeEndpoint endpoint,
(...skipping 29 matching lines...) Expand all
248 260
249 void handleResponse(bindings.ServiceMessage message) { 261 void handleResponse(bindings.ServiceMessage message) {
250 switch (message.header.type) { 262 switch (message.header.type) {
251 case _filesMethodOpenFileSystemName: 263 case _filesMethodOpenFileSystemName:
252 var r = FilesOpenFileSystemResponseParams.deserialize( 264 var r = FilesOpenFileSystemResponseParams.deserialize(
253 message.payload); 265 message.payload);
254 if (!message.header.hasRequestId) { 266 if (!message.header.hasRequestId) {
255 proxyError("Expected a message with a valid request Id."); 267 proxyError("Expected a message with a valid request Id.");
256 return; 268 return;
257 } 269 }
258 Completer c = completerMap[message.header.requestId]; 270 Function callback = callbackMap[message.header.requestId];
259 if (c == null) { 271 if (callback == null) {
260 proxyError( 272 proxyError(
261 "Message had unknown request Id: ${message.header.requestId}"); 273 "Message had unknown request Id: ${message.header.requestId}");
262 return; 274 return;
263 } 275 }
264 completerMap.remove(message.header.requestId); 276 callbackMap.remove(message.header.requestId);
265 if (c.isCompleted) { 277 callback(r.error );
266 proxyError("Response completer already completed");
267 return;
268 }
269 c.complete(r);
270 break; 278 break;
271 default: 279 default:
272 proxyError("Unexpected message type: ${message.header.type}"); 280 proxyError("Unexpected message type: ${message.header.type}");
273 close(immediate: true); 281 close(immediate: true);
274 break; 282 break;
275 } 283 }
276 } 284 }
277 285
278 @override 286 @override
279 String toString() { 287 String toString() {
(...skipping 24 matching lines...) Expand all
304 return newMockedProxy; 312 return newMockedProxy;
305 } 313 }
306 314
307 static FilesProxy newFromEndpoint( 315 static FilesProxy newFromEndpoint(
308 core.MojoMessagePipeEndpoint endpoint) { 316 core.MojoMessagePipeEndpoint endpoint) {
309 assert(endpoint.setDescription("For FilesProxy")); 317 assert(endpoint.setDescription("For FilesProxy"));
310 return new FilesProxy.fromEndpoint(endpoint); 318 return new FilesProxy.fromEndpoint(endpoint);
311 } 319 }
312 320
313 321
314 dynamic openFileSystem(String fileSystem,directory_mojom.DirectoryInterfaceReq uest directory,[Function responseFactory = null]) { 322 void openFileSystem(String fileSystem,directory_mojom.DirectoryInterfaceReques t directory,void callback(types_mojom.Error error)) {
315 if (impl != null) { 323 if (impl != null) {
316 return new Future(() => impl.openFileSystem(fileSystem,directory,_FilesStu bControl._filesOpenFileSystemResponseParamsFactory)); 324 impl.openFileSystem(fileSystem,directory,callback);
325 return;
317 } 326 }
318 var params = new _FilesOpenFileSystemParams(); 327 var params = new _FilesOpenFileSystemParams();
319 params.fileSystem = fileSystem; 328 params.fileSystem = fileSystem;
320 params.directory = directory; 329 params.directory = directory;
321 return ctrl.sendMessageWithRequestId( 330 ctrl.sendMessageWithRequestId(
322 params, 331 params,
323 _filesMethodOpenFileSystemName, 332 _filesMethodOpenFileSystemName,
324 -1, 333 -1,
325 bindings.MessageHeader.kMessageExpectsResponse); 334 bindings.MessageHeader.kMessageExpectsResponse,
335 callback);
326 } 336 }
327 } 337 }
328 338
329 class _FilesStubControl 339 class _FilesStubControl
330 extends bindings.StubMessageHandler 340 extends bindings.StubMessageHandler
331 implements bindings.StubControl<Files> { 341 implements bindings.StubControl<Files> {
332 Files _impl; 342 Files _impl;
333 343
334 _FilesStubControl.fromEndpoint( 344 _FilesStubControl.fromEndpoint(
335 core.MojoMessagePipeEndpoint endpoint, [Files impl]) 345 core.MojoMessagePipeEndpoint endpoint, [Files impl])
336 : super.fromEndpoint(endpoint, autoBegin: impl != null) { 346 : super.fromEndpoint(endpoint, autoBegin: impl != null) {
337 _impl = impl; 347 _impl = impl;
338 } 348 }
339 349
340 _FilesStubControl.fromHandle( 350 _FilesStubControl.fromHandle(
341 core.MojoHandle handle, [Files impl]) 351 core.MojoHandle handle, [Files impl])
342 : super.fromHandle(handle, autoBegin: impl != null) { 352 : super.fromHandle(handle, autoBegin: impl != null) {
343 _impl = impl; 353 _impl = impl;
344 } 354 }
345 355
346 _FilesStubControl.unbound([this._impl]) : super.unbound(); 356 _FilesStubControl.unbound([this._impl]) : super.unbound();
347 357
348 String get serviceName => Files.serviceName; 358 String get serviceName => Files.serviceName;
349 359
350 360
351 static FilesOpenFileSystemResponseParams _filesOpenFileSystemResponseParamsFac tory(types_mojom.Error error) { 361 Function _filesOpenFileSystemResponseParamsResponder(
352 var result = new FilesOpenFileSystemResponseParams(); 362 int requestId) {
353 result.error = error; 363 return (types_mojom.Error error) {
354 return result; 364 var result = new FilesOpenFileSystemResponseParams();
365 result.error = error;
366 sendResponse(buildResponseWithId(
367 result,
368 _filesMethodOpenFileSystemName,
369 requestId,
370 bindings.MessageHeader.kMessageIsResponse));
371 };
355 } 372 }
356 373
357 dynamic handleMessage(bindings.ServiceMessage message) { 374 void handleMessage(bindings.ServiceMessage message) {
358 if (bindings.ControlMessageHandler.isControlMessage(message)) { 375 if (bindings.ControlMessageHandler.isControlMessage(message)) {
359 return bindings.ControlMessageHandler.handleMessage(this, 376 bindings.ControlMessageHandler.handleMessage(
360 0, 377 this, 0, message);
361 message); 378 return;
362 } 379 }
363 if (_impl == null) { 380 if (_impl == null) {
364 throw new core.MojoApiError("$this has no implementation set"); 381 throw new core.MojoApiError("$this has no implementation set");
365 } 382 }
366 switch (message.header.type) { 383 switch (message.header.type) {
367 case _filesMethodOpenFileSystemName: 384 case _filesMethodOpenFileSystemName:
368 var params = _FilesOpenFileSystemParams.deserialize( 385 var params = _FilesOpenFileSystemParams.deserialize(
369 message.payload); 386 message.payload);
370 var response = _impl.openFileSystem(params.fileSystem,params.directory,_ filesOpenFileSystemResponseParamsFactory); 387 _impl.openFileSystem(params.fileSystem, params.directory, _filesOpenFile SystemResponseParamsResponder(message.header.requestId));
371 if (response is Future) {
372 return response.then((response) {
373 if (response != null) {
374 return buildResponseWithId(
375 response,
376 _filesMethodOpenFileSystemName,
377 message.header.requestId,
378 bindings.MessageHeader.kMessageIsResponse);
379 }
380 });
381 } else if (response != null) {
382 return buildResponseWithId(
383 response,
384 _filesMethodOpenFileSystemName,
385 message.header.requestId,
386 bindings.MessageHeader.kMessageIsResponse);
387 }
388 break; 388 break;
389 default: 389 default:
390 throw new bindings.MojoCodecError("Unexpected message name"); 390 throw new bindings.MojoCodecError("Unexpected message name");
391 break; 391 break;
392 } 392 }
393 return null;
394 } 393 }
395 394
396 Files get impl => _impl; 395 Files get impl => _impl;
397 set impl(Files d) { 396 set impl(Files d) {
398 if (d == null) { 397 if (d == null) {
399 throw new core.MojoApiError("$this: Cannot set a null implementation"); 398 throw new core.MojoApiError("$this: Cannot set a null implementation");
400 } 399 }
401 if (isBound && (_impl == null)) { 400 if (isBound && (_impl == null)) {
402 beginHandlingEvents(); 401 beginHandlingEvents();
403 } 402 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 core.MojoHandle handle, [Files impl]) 436 core.MojoHandle handle, [Files impl])
438 : super(new _FilesStubControl.fromHandle(handle, impl)); 437 : super(new _FilesStubControl.fromHandle(handle, impl));
439 438
440 static FilesStub newFromEndpoint( 439 static FilesStub newFromEndpoint(
441 core.MojoMessagePipeEndpoint endpoint) { 440 core.MojoMessagePipeEndpoint endpoint) {
442 assert(endpoint.setDescription("For FilesStub")); 441 assert(endpoint.setDescription("For FilesStub"));
443 return new FilesStub.fromEndpoint(endpoint); 442 return new FilesStub.fromEndpoint(endpoint);
444 } 443 }
445 444
446 445
447 dynamic openFileSystem(String fileSystem,directory_mojom.DirectoryInterfaceReq uest directory,[Function responseFactory = null]) { 446 void openFileSystem(String fileSystem,directory_mojom.DirectoryInterfaceReques t directory,void callback(types_mojom.Error error)) {
448 return impl.openFileSystem(fileSystem,directory,responseFactory); 447 return impl.openFileSystem(fileSystem,directory,callback);
449 } 448 }
450 } 449 }
451 450
452 451
453 452
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698