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

Side by Side Diff: benchmarks/mojo_rtt_benchmark/lib/echo_server.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
« no previous file with comments | « no previous file | benchmarks/mojo_rtt_benchmark/lib/main.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:mojo/application.dart'; 7 import 'package:mojo/application.dart';
8 import 'package:mojo/bindings.dart'; 8 import 'package:mojo/bindings.dart';
9 import 'package:mojo/core.dart'; 9 import 'package:mojo/core.dart';
10 import 'package:_mojo_for_test_only/mojo/examples/echo.mojom.dart'; 10 import 'package:_mojo_for_test_only/mojo/examples/echo.mojom.dart';
11 11
12 class EchoImpl implements Echo { 12 class EchoImpl implements Echo {
13 EchoInterface _echo; 13 EchoInterface _echo;
14 EchoApplication _application; 14 EchoApplication _application;
15 15
16 EchoImpl(this._application, MojoMessagePipeEndpoint endpoint) { 16 EchoImpl(this._application, MojoMessagePipeEndpoint endpoint) {
17 _echo = new EchoInterface.fromEndpoint(endpoint, this); 17 _echo = new EchoInterface.fromEndpoint(endpoint, this);
18 _echo.ctrl.onError = _errorHandler; 18 _echo.ctrl.onError = _errorHandler;
19 } 19 }
20 20
21 echoString(String value, [Function responseFactory]) => 21 void echoString(String value, void respond(String response)) {
22 responseFactory(value); 22 respond(value);
23 }
23 24
24 Future close() => _echo.close(); 25 Future close() => _echo.close();
25 26
26 _errorHandler(Object e) => _application.removeService(this); 27 _errorHandler(Object e) => _application.removeService(this);
27 } 28 }
28 29
29 class EchoApplication extends Application { 30 class EchoApplication extends Application {
30 List<EchoImpl> _echoServices; 31 List<EchoImpl> _echoServices;
31 bool _closing; 32 bool _closing;
32 33
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 await service.close(); 66 await service.close();
66 } 67 }
67 MojoHandle.reportLeakedHandles(); 68 MojoHandle.reportLeakedHandles();
68 } 69 }
69 } 70 }
70 71
71 main(List args, Object handleToken) { 72 main(List args, Object handleToken) {
72 MojoHandle appHandle = new MojoHandle(handleToken); 73 MojoHandle appHandle = new MojoHandle(handleToken);
73 new EchoApplication.fromHandle(appHandle); 74 new EchoApplication.fromHandle(appHandle);
74 } 75 }
OLDNEW
« no previous file with comments | « no previous file | benchmarks/mojo_rtt_benchmark/lib/main.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698