| OLD | NEW |
| 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 { | 7 class _MojoMessagePipeNatives { |
| 8 static List MojoCreateMessagePipe(int flags) native "MojoMessagePipe_Create"; | 8 static List MojoCreateMessagePipe(int flags) native "MojoMessagePipe_Create"; |
| 9 | 9 |
| 10 static int MojoWriteMessage(int handle, ByteData data, int numBytes, | 10 static int MojoWriteMessage(int handle, ByteData data, int numBytes, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 | 76 |
| 77 // If numBytes has the default value, use the full length of the data. | 77 // If numBytes has the default value, use the full length of the data. |
| 78 int dataNumBytes; | 78 int dataNumBytes; |
| 79 if (data == null) { | 79 if (data == null) { |
| 80 dataNumBytes = 0; | 80 dataNumBytes = 0; |
| 81 } else { | 81 } else { |
| 82 dataNumBytes = (numBytes == -1) ? data.lengthInBytes : numBytes; | 82 dataNumBytes = (numBytes == -1) ? data.lengthInBytes : numBytes; |
| 83 if (dataNumBytes > data.lengthInBytes) { | 83 if (dataNumBytes > data.lengthInBytes) { |
| 84 status = MojoResult.INVALID_ARGUMENT; | 84 status = MojoResult.INVALID_ARGUMENT; |
| 85 return status; | 85 return null; |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 | 88 |
| 89 // handles may be null, otherwise make an int list for the handles. | 89 // handles may be null, otherwise make an int list for the handles. |
| 90 List<int> mojoHandles; | 90 List<int> mojoHandles; |
| 91 if (handles == null) { | 91 if (handles == null) { |
| 92 mojoHandles = null; | 92 mojoHandles = null; |
| 93 } else { | 93 } else { |
| 94 mojoHandles = new List<int>(handles.length); | 94 mojoHandles = new List<int>(handles.length); |
| 95 } | 95 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 MojoHandle end1 = new MojoHandle(result[1]); | 149 MojoHandle end1 = new MojoHandle(result[1]); |
| 150 MojoHandle end2 = new MojoHandle(result[2]); | 150 MojoHandle end2 = new MojoHandle(result[2]); |
| 151 MojoMessagePipe pipe = new MojoMessagePipe._(); | 151 MojoMessagePipe pipe = new MojoMessagePipe._(); |
| 152 pipe.endpoints = new List(2); | 152 pipe.endpoints = new List(2); |
| 153 pipe.endpoints[0] = new MojoMessagePipeEndpoint(end1); | 153 pipe.endpoints[0] = new MojoMessagePipeEndpoint(end1); |
| 154 pipe.endpoints[1] = new MojoMessagePipeEndpoint(end2); | 154 pipe.endpoints[1] = new MojoMessagePipeEndpoint(end2); |
| 155 pipe.status = new MojoResult(result[0]); | 155 pipe.status = new MojoResult(result[0]); |
| 156 return pipe; | 156 return pipe; |
| 157 } | 157 } |
| 158 } | 158 } |
| OLD | NEW |