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

Side by Side Diff: mojo/public/dart/src/interface.dart

Issue 851173002: Dart: Encode/Decode handle and interface types. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Fix Interface encode parameters Created 5 years, 11 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 // 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 part of bindings; 5 part of bindings;
6 6
7 abstract class Interface extends core.MojoEventStreamListener { 7 abstract class Interface extends core.MojoEventStreamListener {
8 int _outstandingResponseFutures = 0; 8 int _outstandingResponseFutures = 0;
9 bool _isClosing = false; 9 bool _isClosing = false;
10 10
11 Interface(core.MojoMessagePipeEndpoint endpoint) : super(endpoint); 11 Interface(core.MojoMessagePipeEndpoint endpoint) : super(endpoint);
12 12
13 Interface.fromHandle(int handle) : super.fromHandle(handle); 13 Interface.fromHandle(core.MojoHandle handle) : super.fromHandle(handle);
14
15 Interface.unbound() : super.unbound();
14 16
15 Future<Message> handleMessage(ServiceMessage message); 17 Future<Message> handleMessage(ServiceMessage message);
16 18
17 void handleRead() { 19 void handleRead() {
18 // Query how many bytes are available. 20 // Query how many bytes are available.
19 var result = endpoint.query(); 21 var result = endpoint.query();
20 assert(result.status.isOk || result.status.isResourceExhausted); 22 assert(result.status.isOk || result.status.isResourceExhausted);
21 23
22 // Read the data and view as a message. 24 // Read the data and view as a message.
23 var bytes = new ByteData(result.bytesRead); 25 var bytes = new ByteData(result.bytesRead);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 return response.serializeWithHeader(header); 86 return response.serializeWithHeader(header);
85 } 87 }
86 88
87 void sendMessage(Struct message, int name) { 89 void sendMessage(Struct message, int name) {
88 var header = new MessageHeader(name); 90 var header = new MessageHeader(name);
89 var serviceMessage = message.serializeWithHeader(header); 91 var serviceMessage = message.serializeWithHeader(header);
90 endpoint.write(serviceMessage.buffer, 92 endpoint.write(serviceMessage.buffer,
91 serviceMessage.buffer.lengthInBytes, 93 serviceMessage.buffer.lengthInBytes,
92 serviceMessage.handles); 94 serviceMessage.handles);
93 if (!endpoint.status.isOk) { 95 if (!endpoint.status.isOk) {
94 throw "message pipe write failed"; 96 throw "message pipe write failed: ${endpoint.status}";
95 } 97 }
96 } 98 }
97 99
98 Future sendMessageWithRequestId(Struct response, int name, int id) { 100 Future sendMessageWithRequestId(Struct response, int name, int id) {
99 throw "The client interface should not expect a response"; 101 throw "The client interface should not expect a response";
100 } 102 }
101 } 103 }
OLDNEW
« no previous file with comments | « mojo/public/dart/src/event_stream.dart ('k') | mojo/public/tools/bindings/generators/dart_templates/interface_definition.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698