Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 package org.chromium.net.impl; | 5 package org.chromium.net.impl; |
| 6 | 6 |
| 7 import org.chromium.base.Log; | 7 import org.chromium.base.Log; |
| 8 import org.chromium.base.VisibleForTesting; | 8 import org.chromium.base.VisibleForTesting; |
| 9 import org.chromium.base.annotations.CalledByNative; | 9 import org.chromium.base.annotations.CalledByNative; |
| 10 import org.chromium.base.annotations.JNINamespace; | 10 import org.chromium.base.annotations.JNINamespace; |
| (...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 postTaskToExecutor(mOnReadCompletedTask); | 539 postTaskToExecutor(mOnReadCompletedTask); |
| 540 } | 540 } |
| 541 | 541 |
| 542 @SuppressWarnings("unused") | 542 @SuppressWarnings("unused") |
| 543 @CalledByNative | 543 @CalledByNative |
| 544 private void onWritevCompleted(final ByteBuffer[] byteBuffers, int[] initial Positions, | 544 private void onWritevCompleted(final ByteBuffer[] byteBuffers, int[] initial Positions, |
| 545 int[] initialLimits, boolean endOfStream) { | 545 int[] initialLimits, boolean endOfStream) { |
| 546 assert byteBuffers.length == initialPositions.length; | 546 assert byteBuffers.length == initialPositions.length; |
| 547 assert byteBuffers.length == initialLimits.length; | 547 assert byteBuffers.length == initialLimits.length; |
| 548 synchronized (mNativeStreamLock) { | 548 synchronized (mNativeStreamLock) { |
| 549 if (isDoneLocked()) return; | |
|
mef
2017/02/14 21:02:47
Just checking: Does this syntax conform to coding
xunjieli
2017/02/14 21:14:34
Yes, this is listed under "Use Standard Brace Styl
mef
2017/02/14 21:19:54
Cool, thanks for the reference!
| |
| 549 mWriteState = State.WAITING_FOR_FLUSH; | 550 mWriteState = State.WAITING_FOR_FLUSH; |
| 550 // Flush if there is anything in the flush queue mFlushData. | 551 // Flush if there is anything in the flush queue mFlushData. |
| 551 if (!mFlushData.isEmpty()) { | 552 if (!mFlushData.isEmpty()) { |
| 552 sendFlushDataLocked(); | 553 sendFlushDataLocked(); |
| 553 } | 554 } |
| 554 } | 555 } |
| 555 for (int i = 0; i < byteBuffers.length; i++) { | 556 for (int i = 0; i < byteBuffers.length; i++) { |
| 556 ByteBuffer buffer = byteBuffers[i]; | 557 ByteBuffer buffer = byteBuffers[i]; |
| 557 if (buffer.position() != initialPositions[i] || buffer.limit() != in itialLimits[i]) { | 558 if (buffer.position() != initialPositions[i] || buffer.limit() != in itialLimits[i]) { |
| 558 failWithException(new CronetExceptionImpl( | 559 failWithException(new CronetExceptionImpl( |
| 559 "ByteBuffer modified externally during write", null)); | 560 "ByteBuffer modified externally during write", null)); |
| 560 return; | 561 return; |
| 561 } | 562 } |
| 562 // Current implementation always writes the complete buffer. | 563 // Current implementation always writes the complete buffer. |
| 563 buffer.position(buffer.limit()); | 564 buffer.position(buffer.limit()); |
| 564 postTaskToExecutor(new OnWriteCompletedRunnable(buffer, | 565 postTaskToExecutor(new OnWriteCompletedRunnable(buffer, |
|
mef
2017/02/14 21:02:47
I think if you use direct executor and cancel stre
xunjieli
2017/02/14 21:14:34
Right, but how do we reliably trigger nativeWritev
mef
2017/02/14 21:19:54
Would the way you had it in the test (write / flus
| |
| 565 // Only set endOfStream flag if this buffer is the last in b yteBuffers. | 566 // Only set endOfStream flag if this buffer is the last in b yteBuffers. |
| 566 endOfStream && i == byteBuffers.length - 1)); | 567 endOfStream && i == byteBuffers.length - 1)); |
| 567 } | 568 } |
| 568 } | 569 } |
| 569 | 570 |
| 570 @SuppressWarnings("unused") | 571 @SuppressWarnings("unused") |
| 571 @CalledByNative | 572 @CalledByNative |
| 572 private void onResponseTrailersReceived(String[] trailers) { | 573 private void onResponseTrailersReceived(String[] trailers) { |
| 573 final UrlResponseInfo.HeaderBlock trailersBlock = | 574 final UrlResponseInfo.HeaderBlock trailersBlock = |
| 574 new UrlResponseInfoImpl.HeaderBlockImpl(headersListFromStrings(t railers)); | 575 new UrlResponseInfoImpl.HeaderBlockImpl(headersListFromStrings(t railers)); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 803 private native boolean nativeReadData( | 804 private native boolean nativeReadData( |
| 804 long nativePtr, ByteBuffer byteBuffer, int position, int limit); | 805 long nativePtr, ByteBuffer byteBuffer, int position, int limit); |
| 805 | 806 |
| 806 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") | 807 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") |
| 807 private native boolean nativeWritevData(long nativePtr, ByteBuffer[] buffers , int[] positions, | 808 private native boolean nativeWritevData(long nativePtr, ByteBuffer[] buffers , int[] positions, |
| 808 int[] limits, boolean endOfStream); | 809 int[] limits, boolean endOfStream); |
| 809 | 810 |
| 810 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") | 811 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") |
| 811 private native void nativeDestroy(long nativePtr, boolean sendOnCanceled); | 812 private native void nativeDestroy(long nativePtr, boolean sendOnCanceled); |
| 812 } | 813 } |
| OLD | NEW |