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

Side by Side Diff: benchmarks/mojo_rtt_benchmark/lib/echo_server.dart

Issue 1414483010: Dart: Use a RawReceivePort to receive events for Mojo handles. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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/isolate.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:mojom/mojo/examples/echo.mojom.dart'; 10 import 'package:mojom/mojo/examples/echo.mojom.dart';
11 11
12 class EchoImpl implements Echo { 12 class EchoImpl implements Echo {
13 EchoStub _stub; 13 EchoStub _stub;
14 EchoApplication _application; 14 EchoApplication _application;
15 15
16 EchoImpl(this._application, MojoMessagePipeEndpoint endpoint) { 16 EchoImpl(this._application, MojoMessagePipeEndpoint endpoint) {
17 _stub = new EchoStub.fromEndpoint(endpoint, this); 17 _stub = new EchoStub.fromEndpoint(endpoint, this);
18 _stub.onError = _errorHandler; 18 _stub.onError = _errorHandler;
19 } 19 }
20 20
21 echoString(String value, [Function responseFactory]) => 21 echoString(String value, [Function responseFactory]) =>
22 responseFactory(value); 22 responseFactory(value);
23 23
24 Future close() => _stub.close(); 24 Future close() => _stub.close();
25 25
26 _errorHandler() => _application.removeService(this); 26 _errorHandler(Object e) => _application.removeService(this);
27 } 27 }
28 28
29 class EchoApplication extends Application { 29 class EchoApplication extends Application {
30 List<EchoImpl> _echoServices; 30 List<EchoImpl> _echoServices;
31 bool _closing; 31 bool _closing;
32 32
33 EchoApplication.fromHandle(MojoHandle handle) 33 EchoApplication.fromHandle(MojoHandle handle)
34 : _closing = false, 34 : _closing = false,
35 _echoServices = [], 35 _echoServices = [],
36 super.fromHandle(handle) { 36 super.fromHandle(handle) {
(...skipping 15 matching lines...) Expand all
52 EchoImpl _createService(MojoMessagePipeEndpoint endpoint) { 52 EchoImpl _createService(MojoMessagePipeEndpoint endpoint) {
53 if (_closing) { 53 if (_closing) {
54 endpoint.close(); 54 endpoint.close();
55 return null; 55 return null;
56 } 56 }
57 var echoService = new EchoImpl(this, endpoint); 57 var echoService = new EchoImpl(this, endpoint);
58 _echoServices.add(echoService); 58 _echoServices.add(echoService);
59 return echoService; 59 return echoService;
60 } 60 }
61 61
62 _errorHandler() async { 62 _errorHandler(Object e) async {
63 _closing = true; 63 _closing = true;
64 for (var service in _echoServices) { 64 for (var service in _echoServices) {
65 await service.close(); 65 await service.close();
66 } 66 }
67 MojoHandle.reportLeakedHandles(); 67 MojoHandle.reportLeakedHandles();
68 } 68 }
69 } 69 }
70 70
71 main(List args) { 71 main(List args) {
72 MojoHandle appHandle = new MojoHandle(args[0]); 72 MojoHandle appHandle = new MojoHandle(args[0]);
73 String url = args[1]; 73 String url = args[1];
74 new EchoApplication.fromHandle(appHandle); 74 new EchoApplication.fromHandle(appHandle);
75 } 75 }
OLDNEW
« no previous file with comments | « no previous file | benchmarks/mojo_rtt_benchmark/lib/isolate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698