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 package org.chromium.mojo.system.impl; | 5 package org.chromium.mojo.system.impl; |
6 | 6 |
7 import org.chromium.base.CalledByNative; | 7 import org.chromium.base.CalledByNative; |
8 import org.chromium.base.JNINamespace; | 8 import org.chromium.base.JNINamespace; |
9 import org.chromium.mojo.system.AsyncWaiter; | 9 import org.chromium.mojo.system.AsyncWaiter; |
10 import org.chromium.mojo.system.Core; | 10 import org.chromium.mojo.system.Core; |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
319 } | 319 } |
320 return result; | 320 return result; |
321 } | 321 } |
322 | 322 |
323 /** | 323 /** |
324 * @see ConsumerHandle#discardData(int, DataPipe.ReadFlags) | 324 * @see ConsumerHandle#discardData(int, DataPipe.ReadFlags) |
325 */ | 325 */ |
326 int discardData(DataPipeConsumerHandleImpl handle, int numBytes, DataPipe.Re adFlags flags) { | 326 int discardData(DataPipeConsumerHandleImpl handle, int numBytes, DataPipe.Re adFlags flags) { |
327 int result = nativeReadData(handle.getMojoHandle(), null, numBytes, | 327 int result = nativeReadData(handle.getMojoHandle(), null, numBytes, |
328 flags.getFlags() | MOJO_READ_DATA_FLAG_DISCARD); | 328 flags.getFlags() | MOJO_READ_DATA_FLAG_DISCARD); |
329 if (result < 0) { | 329 if (result != MojoResult.OK) { |
330 throw new MojoException(result); | 330 throw new MojoException(result); |
331 } | 331 } |
332 return result; | 332 return result; |
viettrungluu
2015/04/02 23:02:42
This should always be MojoResult.OK, I think.
| |
333 } | 333 } |
334 | 334 |
335 /** | 335 /** |
336 * @see ConsumerHandle#readData(ByteBuffer, DataPipe.ReadFlags) | 336 * @see ConsumerHandle#readData(ByteBuffer, DataPipe.ReadFlags) |
337 */ | 337 */ |
338 int readData(DataPipeConsumerHandleImpl handle, ByteBuffer elements, DataPip e.ReadFlags flags) { | 338 int readData(DataPipeConsumerHandleImpl handle, ByteBuffer elements, DataPip e.ReadFlags flags) { |
339 int result = nativeReadData(handle.getMojoHandle(), elements, | 339 int result = nativeReadData(handle.getMojoHandle(), elements, |
340 elements == null ? 0 : elements.capacity(), flags.getFlags()); | 340 elements == null ? 0 : elements.capacity(), flags.getFlags()); |
341 if (result < 0) { | 341 if (result != MojoResult.OK) { |
342 throw new MojoException(result); | 342 throw new MojoException(result); |
343 } | 343 } |
344 if (elements != null) { | 344 if (elements != null) { |
345 elements.limit(result); | 345 elements.limit(result); |
346 } | 346 } |
347 return result; | 347 return result; |
viettrungluu
2015/04/02 23:02:42
This is obviously wrong (and hence nativeReadData(
| |
348 } | 348 } |
349 | 349 |
350 /** | 350 /** |
351 * @see ConsumerHandle#beginReadData(int, DataPipe.ReadFlags) | 351 * @see ConsumerHandle#beginReadData(int, DataPipe.ReadFlags) |
352 */ | 352 */ |
353 ByteBuffer beginReadData( | 353 ByteBuffer beginReadData( |
354 DataPipeConsumerHandleImpl handle, int numBytes, DataPipe.ReadFlags flags) { | 354 DataPipeConsumerHandleImpl handle, int numBytes, DataPipe.ReadFlags flags) { |
355 NativeCodeAndBufferResult result = | 355 NativeCodeAndBufferResult result = |
356 nativeBeginReadData(handle.getMojoHandle(), numBytes, flags.getF lags()); | 356 nativeBeginReadData(handle.getMojoHandle(), numBytes, flags.getF lags()); |
357 if (result.getMojoResult() != MojoResult.OK) { | 357 if (result.getMojoResult() != MojoResult.OK) { |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
569 NativeCodeAndBufferResult result = new NativeCodeAndBufferResult(); | 569 NativeCodeAndBufferResult result = new NativeCodeAndBufferResult(); |
570 result.setMojoResult(mojoResult); | 570 result.setMojoResult(mojoResult); |
571 result.setBuffer(buffer); | 571 result.setBuffer(buffer); |
572 return result; | 572 return result; |
573 } | 573 } |
574 | 574 |
575 @CalledByNative | 575 @CalledByNative |
576 private static MessagePipeHandle.ReadMessageResult newReadMessageResult( | 576 private static MessagePipeHandle.ReadMessageResult newReadMessageResult( |
577 int mojoResult, int messageSize, int handlesCount) { | 577 int mojoResult, int messageSize, int handlesCount) { |
578 MessagePipeHandle.ReadMessageResult result = new MessagePipeHandle.ReadM essageResult(); | 578 MessagePipeHandle.ReadMessageResult result = new MessagePipeHandle.ReadM essageResult(); |
579 if (mojoResult >= 0) { | 579 result.setMojoResult(MojoResult.OK); |
580 result.setMojoResult(MojoResult.OK); | |
581 } else { | |
582 result.setMojoResult(mojoResult); | |
583 } | |
584 result.setMessageSize(messageSize); | 580 result.setMessageSize(messageSize); |
585 result.setHandlesCount(handlesCount); | 581 result.setHandlesCount(handlesCount); |
586 return result; | 582 return result; |
587 } | 583 } |
588 | 584 |
589 private static class NativeCreationResult { | 585 private static class NativeCreationResult { |
590 private int mMojoResult; | 586 private int mMojoResult; |
591 private int mMojoHandle1; | 587 private int mMojoHandle1; |
592 private int mMojoHandle2; | 588 private int mMojoHandle2; |
593 | 589 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
685 private native NativeCodeAndBufferResult nativeMap( | 681 private native NativeCodeAndBufferResult nativeMap( |
686 int mojoHandle, long offset, long numBytes, int flags); | 682 int mojoHandle, long offset, long numBytes, int flags); |
687 | 683 |
688 private native int nativeUnmap(ByteBuffer buffer); | 684 private native int nativeUnmap(ByteBuffer buffer); |
689 | 685 |
690 private native AsyncWaiterCancellableImpl nativeAsyncWait( | 686 private native AsyncWaiterCancellableImpl nativeAsyncWait( |
691 int mojoHandle, int signals, long deadline, AsyncWaiter.Callback cal lback); | 687 int mojoHandle, int signals, long deadline, AsyncWaiter.Callback cal lback); |
692 | 688 |
693 private native void nativeCancelAsyncWait(long mId, long dataPtr); | 689 private native void nativeCancelAsyncWait(long mId, long dataPtr); |
694 } | 690 } |
OLD | NEW |