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

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

Issue 1027603002: Dart: Removes all but native calls and the handle watcher from the snapshot. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Hoist application interface dependence Created 5 years, 9 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 | « mojo/public/dart/src/handle_watcher.dart ('k') | mojo/public/dart/src/natives.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 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 core; 5 part of core;
6 6
7 class _MojoMessagePipeNatives {
8 static List MojoCreateMessagePipe(int flags) native "MojoMessagePipe_Create";
9
10 static int MojoWriteMessage(int handle, ByteData data, int numBytes,
11 List<int> handles, int flags) native "MojoMessagePipe_Write";
12
13 static List MojoReadMessage(int handle, ByteData data, int numBytes,
14 List<int> handles, int flags) native "MojoMessagePipe_Read";
15 }
16
17 class MojoMessagePipeReadResult { 7 class MojoMessagePipeReadResult {
18 final MojoResult status; 8 final MojoResult status;
19 final int bytesRead; 9 final int bytesRead;
20 final int handlesRead; 10 final int handlesRead;
21 11
22 MojoMessagePipeReadResult(this.status, this.bytesRead, this.handlesRead); 12 MojoMessagePipeReadResult(this.status, this.bytesRead, this.handlesRead);
23 MojoMessagePipeReadResult.fromList(List<int> resultList) 13 MojoMessagePipeReadResult.fromList(List<int> resultList)
24 : this(new MojoResult(resultList[0]), resultList[1], resultList[2]); 14 : this(new MojoResult(resultList[0]), resultList[1], resultList[2]);
25 15
26 String toString() { 16 String toString() {
(...skipping 26 matching lines...) Expand all
53 if (dataNumBytes > dataLengthInBytes) { 43 if (dataNumBytes > dataLengthInBytes) {
54 status = MojoResult.INVALID_ARGUMENT; 44 status = MojoResult.INVALID_ARGUMENT;
55 return status; 45 return status;
56 } 46 }
57 47
58 // handles may be null, otherwise convert to ints. 48 // handles may be null, otherwise convert to ints.
59 List<int> mojoHandles = 49 List<int> mojoHandles =
60 (handles != null) ? handles.map((h) => h.h).toList() : null; 50 (handles != null) ? handles.map((h) => h.h).toList() : null;
61 51
62 // Do the call. 52 // Do the call.
63 int result = _MojoMessagePipeNatives.MojoWriteMessage( 53 int result = MojoMessagePipeNatives.MojoWriteMessage(
64 handle.h, data, dataNumBytes, mojoHandles, flags); 54 handle.h, data, dataNumBytes, mojoHandles, flags);
65 55
66 status = new MojoResult(result); 56 status = new MojoResult(result);
67 return status; 57 return status;
68 } 58 }
69 59
70 MojoMessagePipeReadResult read(ByteData data, 60 MojoMessagePipeReadResult read(ByteData data,
71 [int numBytes = -1, List<MojoHandle> handles = null, int flags = 0]) { 61 [int numBytes = -1, List<MojoHandle> handles = null, int flags = 0]) {
72 if (handle == null) { 62 if (handle == null) {
73 status = MojoResult.INVALID_ARGUMENT; 63 status = MojoResult.INVALID_ARGUMENT;
(...skipping 14 matching lines...) Expand all
88 78
89 // handles may be null, otherwise make an int list for the handles. 79 // handles may be null, otherwise make an int list for the handles.
90 List<int> mojoHandles; 80 List<int> mojoHandles;
91 if (handles == null) { 81 if (handles == null) {
92 mojoHandles = null; 82 mojoHandles = null;
93 } else { 83 } else {
94 mojoHandles = new List<int>(handles.length); 84 mojoHandles = new List<int>(handles.length);
95 } 85 }
96 86
97 // Do the call. 87 // Do the call.
98 List result = _MojoMessagePipeNatives.MojoReadMessage( 88 List result = MojoMessagePipeNatives.MojoReadMessage(
99 handle.h, data, dataNumBytes, mojoHandles, flags); 89 handle.h, data, dataNumBytes, mojoHandles, flags);
100 90
101 if (result == null) { 91 if (result == null) {
102 status = MojoResult.INVALID_ARGUMENT; 92 status = MojoResult.INVALID_ARGUMENT;
103 return null; 93 return null;
104 } 94 }
105 95
106 assert((result is List) && (result.length == 3)); 96 assert((result is List) && (result.length == 3));
107 var readResult = new MojoMessagePipeReadResult.fromList(result); 97 var readResult = new MojoMessagePipeReadResult.fromList(result);
108 98
(...skipping 24 matching lines...) Expand all
133 123
134 List<MojoMessagePipeEndpoint> endpoints; 124 List<MojoMessagePipeEndpoint> endpoints;
135 MojoResult status; 125 MojoResult status;
136 126
137 MojoMessagePipe._() { 127 MojoMessagePipe._() {
138 endpoints = null; 128 endpoints = null;
139 status = MojoResult.OK; 129 status = MojoResult.OK;
140 } 130 }
141 131
142 factory MojoMessagePipe([int flags = FLAG_NONE]) { 132 factory MojoMessagePipe([int flags = FLAG_NONE]) {
143 List result = _MojoMessagePipeNatives.MojoCreateMessagePipe(flags); 133 List result = MojoMessagePipeNatives.MojoCreateMessagePipe(flags);
144 if (result == null) { 134 if (result == null) {
145 return null; 135 return null;
146 } 136 }
147 assert((result is List) && (result.length == 3)); 137 assert((result is List) && (result.length == 3));
148 138
149 MojoHandle end1 = new MojoHandle(result[1]); 139 MojoHandle end1 = new MojoHandle(result[1]);
150 MojoHandle end2 = new MojoHandle(result[2]); 140 MojoHandle end2 = new MojoHandle(result[2]);
151 MojoMessagePipe pipe = new MojoMessagePipe._(); 141 MojoMessagePipe pipe = new MojoMessagePipe._();
152 pipe.endpoints = new List(2); 142 pipe.endpoints = new List(2);
153 pipe.endpoints[0] = new MojoMessagePipeEndpoint(end1); 143 pipe.endpoints[0] = new MojoMessagePipeEndpoint(end1);
154 pipe.endpoints[1] = new MojoMessagePipeEndpoint(end2); 144 pipe.endpoints[1] = new MojoMessagePipeEndpoint(end2);
155 pipe.status = new MojoResult(result[0]); 145 pipe.status = new MojoResult(result[0]);
156 return pipe; 146 return pipe;
157 } 147 }
158 } 148 }
OLDNEW
« no previous file with comments | « mojo/public/dart/src/handle_watcher.dart ('k') | mojo/public/dart/src/natives.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698