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; | 5 package org.chromium.net; |
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; |
11 import org.chromium.base.annotations.NativeClassQualifiedName; | 11 import org.chromium.base.annotations.NativeClassQualifiedName; |
12 | 12 |
13 import java.nio.ByteBuffer; | 13 import java.nio.ByteBuffer; |
14 import java.util.AbstractMap; | 14 import java.util.AbstractMap; |
15 import java.util.ArrayList; | 15 import java.util.ArrayList; |
16 import java.util.Arrays; | 16 import java.util.Arrays; |
17 import java.util.LinkedList; | |
17 import java.util.List; | 18 import java.util.List; |
18 import java.util.Map; | 19 import java.util.Map; |
19 import java.util.concurrent.Executor; | 20 import java.util.concurrent.Executor; |
20 import java.util.concurrent.RejectedExecutionException; | 21 import java.util.concurrent.RejectedExecutionException; |
21 | 22 |
22 import javax.annotation.concurrent.GuardedBy; | 23 import javax.annotation.concurrent.GuardedBy; |
23 | 24 |
24 /** | 25 /** |
25 * {@link BidirectionalStream} implementation using Chromium network stack. | 26 * {@link BidirectionalStream} implementation using Chromium network stack. |
26 * All @CalledByNative methods are called on the native network thread | 27 * All @CalledByNative methods are called on the native network thread |
(...skipping 22 matching lines...) Expand all Loading... | |
49 /* There is no more data to read and stream is half-closed by the remote side. */ | 50 /* There is no more data to read and stream is half-closed by the remote side. */ |
50 READING_DONE, | 51 READING_DONE, |
51 /* Stream is canceled. */ | 52 /* Stream is canceled. */ |
52 CANCELED, | 53 CANCELED, |
53 /* Error has occured, stream is closed. */ | 54 /* Error has occured, stream is closed. */ |
54 ERROR, | 55 ERROR, |
55 /* Reading and writing are done, and the stream is closed successfully. */ | 56 /* Reading and writing are done, and the stream is closed successfully. */ |
56 SUCCESS, | 57 SUCCESS, |
57 /* Waiting for {@code write()} to be called. */ | 58 /* Waiting for {@code write()} to be called. */ |
58 WAITING_FOR_WRITE, | 59 WAITING_FOR_WRITE, |
59 /* Writing to the remote, {@code onWriteCompleted()} callback will be ca lled when done. */ | 60 /* |
61 * Writing to the remote, {@code onWriteCompleted()} callback will be ca lled when done. | |
62 * This state is only applicable when {@code mDisableAutoFlush} is false . | |
63 */ | |
60 WRITING, | 64 WRITING, |
61 /* There is no more data to write and stream is half-closed by the local side. */ | 65 /* There is no more data to write and stream is half-closed by the local side. */ |
62 WRITING_DONE, | 66 WRITING_DONE, |
63 } | 67 } |
64 | 68 |
65 private final CronetUrlRequestContext mRequestContext; | 69 private final CronetUrlRequestContext mRequestContext; |
66 private final Executor mExecutor; | 70 private final Executor mExecutor; |
67 private final Callback mCallback; | 71 private final Callback mCallback; |
68 private final String mInitialUrl; | 72 private final String mInitialUrl; |
69 private final int mInitialPriority; | 73 private final int mInitialPriority; |
70 private final String mInitialMethod; | 74 private final String mInitialMethod; |
71 private final String mRequestHeaders[]; | 75 private final String mRequestHeaders[]; |
76 private final boolean mDisableAutoFlush; | |
72 | 77 |
73 /* | 78 /* |
74 * Synchronizes access to mNativeStream, mReadState and mWriteState. | 79 * Synchronizes access to mNativeStream, mReadState and mWriteState. |
75 */ | 80 */ |
76 private final Object mNativeStreamLock = new Object(); | 81 private final Object mNativeStreamLock = new Object(); |
77 | 82 |
83 @GuardedBy("mNativeStreamLock") | |
84 private final LinkedList<ByteBuffer> mPendingData; | |
85 | |
86 @GuardedBy("mNativeStreamLock") | |
87 // Whether an end-of-stream flag is passed in through write(). | |
88 private boolean mEndOfStreamWritten; | |
89 | |
78 /* Native BidirectionalStream object, owned by CronetBidirectionalStream. */ | 90 /* Native BidirectionalStream object, owned by CronetBidirectionalStream. */ |
79 @GuardedBy("mNativeStreamLock") | 91 @GuardedBy("mNativeStreamLock") |
80 private long mNativeStream; | 92 private long mNativeStream; |
81 | 93 |
82 /** | 94 /** |
83 * Read state is tracking reading flow. | 95 * Read state is tracking reading flow. |
84 * / <--- READING <--- \ | 96 * / <--- READING <--- \ |
85 * | | | 97 * | | |
86 * \ / | 98 * \ / |
87 * NOT_STARTED -> STARTED --> WAITING_FOR_READ -> READING_DONE -> SUCCESS | 99 * NOT_STARTED -> STARTED --> WAITING_FOR_READ -> READING_DONE -> SUCCESS |
88 */ | 100 */ |
89 @GuardedBy("mNativeStreamLock") | 101 @GuardedBy("mNativeStreamLock") |
90 private State mReadState = State.NOT_STARTED; | 102 private State mReadState = State.NOT_STARTED; |
91 | 103 |
92 /** | 104 /** |
93 * Write state is tracking writing flow. | 105 * Write state is tracking writing flow. |
94 * / <--- WRITING <--- \ | 106 * / <--- WRITING (if !mDisableAutoFlush)<--- \ |
95 * | | | 107 * | | |
96 * \ / | 108 * \ / |
97 * NOT_STARTED -> STARTED --> WAITING_FOR_WRITE -> WRITING_DONE -> SUCCESS | 109 * NOT_STARTED -> STARTED --> -------------WAITING_FOR_WRITE --------> WRITI NG_DONE -> SUCCESS |
98 */ | 110 */ |
99 @GuardedBy("mNativeStreamLock") | 111 @GuardedBy("mNativeStreamLock") |
100 private State mWriteState = State.NOT_STARTED; | 112 private State mWriteState = State.NOT_STARTED; |
101 | 113 |
102 private UrlResponseInfo mResponseInfo; | 114 private UrlResponseInfo mResponseInfo; |
103 | 115 |
104 /* | 116 /* |
105 * OnReadCompleted callback is repeatedly invoked when each read is complete d, so it | 117 * OnReadCompleted callback is repeatedly invoked when each read is complete d, so it |
106 * is cached as a member variable. | 118 * is cached as a member variable. |
107 */ | 119 */ |
108 private OnReadCompletedRunnable mOnReadCompletedTask; | 120 private OnReadCompletedRunnable mOnReadCompletedTask; |
109 | 121 |
110 /* | |
111 * OnWriteCompleted callback is repeatedly invoked when each write is comple ted, so it | |
112 * is cached as a member variable. | |
113 */ | |
114 private OnWriteCompletedRunnable mOnWriteCompletedTask; | |
115 | |
116 private Runnable mOnDestroyedCallbackForTesting; | 122 private Runnable mOnDestroyedCallbackForTesting; |
117 | 123 |
118 private final class OnReadCompletedRunnable implements Runnable { | 124 private final class OnReadCompletedRunnable implements Runnable { |
119 // Buffer passed back from current invocation of onReadCompleted. | 125 // Buffer passed back from current invocation of onReadCompleted. |
120 ByteBuffer mByteBuffer; | 126 ByteBuffer mByteBuffer; |
121 // End of stream flag from current invocation of onReadCompleted. | 127 // End of stream flag from current invocation of onReadCompleted. |
122 boolean mEndOfStream; | 128 boolean mEndOfStream; |
123 | 129 |
124 @Override | 130 @Override |
125 public void run() { | 131 public void run() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
158 try { | 164 try { |
159 // Null out mByteBuffer, to pass buffer ownership to callback or release if done. | 165 // Null out mByteBuffer, to pass buffer ownership to callback or release if done. |
160 ByteBuffer buffer = mByteBuffer; | 166 ByteBuffer buffer = mByteBuffer; |
161 mByteBuffer = null; | 167 mByteBuffer = null; |
162 synchronized (mNativeStreamLock) { | 168 synchronized (mNativeStreamLock) { |
163 if (isDoneLocked()) { | 169 if (isDoneLocked()) { |
164 return; | 170 return; |
165 } | 171 } |
166 if (mEndOfStream) { | 172 if (mEndOfStream) { |
167 mWriteState = State.WRITING_DONE; | 173 mWriteState = State.WRITING_DONE; |
168 if (maybeSucceedLocked()) { | 174 // Maybe post an onSucceeded callback to be executed aft er run() completes. |
169 return; | 175 maybeSucceedLocked(); |
170 } | |
171 } else { | 176 } else { |
172 mWriteState = State.WAITING_FOR_WRITE; | 177 mWriteState = State.WAITING_FOR_WRITE; |
173 } | 178 } |
174 } | 179 } |
175 mCallback.onWriteCompleted(CronetBidirectionalStream.this, mResp onseInfo, buffer); | 180 mCallback.onWriteCompleted(CronetBidirectionalStream.this, mResp onseInfo, buffer); |
176 } catch (Exception e) { | 181 } catch (Exception e) { |
177 onCallbackException(e); | 182 onCallbackException(e); |
178 } | 183 } |
179 } | 184 } |
180 } | 185 } |
181 | 186 |
182 CronetBidirectionalStream(CronetUrlRequestContext requestContext, String url , | 187 CronetBidirectionalStream(CronetUrlRequestContext requestContext, String url , |
183 @BidirectionalStream.Builder.StreamPriority int priority, Callback c allback, | 188 @BidirectionalStream.Builder.StreamPriority int priority, Callback c allback, |
184 Executor executor, String httpMethod, List<Map.Entry<String, String> > requestHeaders) { | 189 Executor executor, String httpMethod, List<Map.Entry<String, String> > requestHeaders, |
190 boolean disableAutoFlush) { | |
185 mRequestContext = requestContext; | 191 mRequestContext = requestContext; |
186 mInitialUrl = url; | 192 mInitialUrl = url; |
187 mInitialPriority = convertStreamPriority(priority); | 193 mInitialPriority = convertStreamPriority(priority); |
188 mCallback = callback; | 194 mCallback = callback; |
189 mExecutor = executor; | 195 mExecutor = executor; |
190 mInitialMethod = httpMethod; | 196 mInitialMethod = httpMethod; |
191 mRequestHeaders = stringsFromHeaderList(requestHeaders); | 197 mRequestHeaders = stringsFromHeaderList(requestHeaders); |
198 mDisableAutoFlush = disableAutoFlush; | |
199 mPendingData = new LinkedList<ByteBuffer>(); | |
192 } | 200 } |
193 | 201 |
194 @Override | 202 @Override |
195 public void start() { | 203 public void start() { |
196 synchronized (mNativeStreamLock) { | 204 synchronized (mNativeStreamLock) { |
197 if (mReadState != State.NOT_STARTED) { | 205 if (mReadState != State.NOT_STARTED) { |
198 throw new IllegalStateException("Stream is already started."); | 206 throw new IllegalStateException("Stream is already started."); |
199 } | 207 } |
200 try { | 208 try { |
201 mNativeStream = nativeCreateBidirectionalStream( | 209 mNativeStream = nativeCreateBidirectionalStream( |
202 mRequestContext.getUrlRequestContextAdapter()); | 210 mRequestContext.getUrlRequestContextAdapter(), mDisableA utoFlush); |
203 mRequestContext.onRequestStarted(); | 211 mRequestContext.onRequestStarted(); |
204 // Non-zero startResult means an argument error. | 212 // Non-zero startResult means an argument error. |
205 int startResult = nativeStart(mNativeStream, mInitialUrl, mIniti alPriority, | 213 int startResult = nativeStart(mNativeStream, mInitialUrl, mIniti alPriority, |
206 mInitialMethod, mRequestHeaders, !doesMethodAllowWriteDa ta(mInitialMethod)); | 214 mInitialMethod, mRequestHeaders, !doesMethodAllowWriteDa ta(mInitialMethod)); |
207 if (startResult == -1) { | 215 if (startResult == -1) { |
208 throw new IllegalArgumentException("Invalid http method " + mInitialMethod); | 216 throw new IllegalArgumentException("Invalid http method " + mInitialMethod); |
209 } | 217 } |
210 if (startResult > 0) { | 218 if (startResult > 0) { |
211 int headerPos = startResult - 1; | 219 int headerPos = startResult - 1; |
212 throw new IllegalArgumentException("Invalid header " | 220 throw new IllegalArgumentException("Invalid header " |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
246 } | 254 } |
247 } | 255 } |
248 | 256 |
249 @Override | 257 @Override |
250 public void write(ByteBuffer buffer, boolean endOfStream) { | 258 public void write(ByteBuffer buffer, boolean endOfStream) { |
251 synchronized (mNativeStreamLock) { | 259 synchronized (mNativeStreamLock) { |
252 Preconditions.checkDirect(buffer); | 260 Preconditions.checkDirect(buffer); |
253 if (!buffer.hasRemaining() && !endOfStream) { | 261 if (!buffer.hasRemaining() && !endOfStream) { |
254 throw new IllegalArgumentException("Empty buffer before end of s tream."); | 262 throw new IllegalArgumentException("Empty buffer before end of s tream."); |
255 } | 263 } |
264 if (isDoneLocked()) { | |
265 return; | |
266 } | |
267 if (mEndOfStreamWritten) { | |
kapishnikov
2016/04/12 19:27:39
We should move it ahead of
if (isDoneLocked()) {
xunjieli
2016/04/12 19:59:03
Done.
| |
268 throw new IllegalArgumentException("Write after writing end of s tream."); | |
269 } | |
256 if (mWriteState != State.WAITING_FOR_WRITE) { | 270 if (mWriteState != State.WAITING_FOR_WRITE) { |
257 throw new IllegalStateException("Unexpected write attempt."); | 271 throw new IllegalStateException("Unexpected write attempt."); |
258 } | 272 } |
259 if (isDoneLocked()) { | 273 mPendingData.add(buffer); |
274 if (endOfStream) { | |
275 mEndOfStreamWritten = true; | |
276 } | |
277 if (mDisableAutoFlush) { | |
260 return; | 278 return; |
261 } | 279 } |
262 if (mOnWriteCompletedTask == null) { | |
263 mOnWriteCompletedTask = new OnWriteCompletedRunnable(); | |
264 } | |
265 mOnWriteCompletedTask.mEndOfStream = endOfStream; | |
266 mWriteState = State.WRITING; | 280 mWriteState = State.WRITING; |
267 if (!nativeWriteData( | 281 flushLocked(); |
268 mNativeStream, buffer, buffer.position(), buffer.limit() , endOfStream)) { | |
269 // Still waiting on write. This is just to have consistent | |
270 // behavior with the other error cases. | |
271 mWriteState = State.WAITING_FOR_WRITE; | |
272 throw new IllegalArgumentException("Unable to call native write" ); | |
273 } | |
274 } | 282 } |
275 } | 283 } |
276 | 284 |
285 @Override | |
286 public void flush() { | |
287 synchronized (mNativeStreamLock) { | |
288 if (!mDisableAutoFlush) { | |
289 throw new IllegalStateException("flush is called when auto flush is not disabled."); | |
kapishnikov
2016/04/12 19:27:39
Should we allow calling flush even when disableAut
xunjieli
2016/04/12 19:59:03
Removing the check makes me a bit uneasy, but I th
| |
290 } | |
291 flushLocked(); | |
292 } | |
293 } | |
294 | |
295 @SuppressWarnings("GuardedByChecker") | |
296 private void flushLocked() { | |
297 int size = mPendingData.size(); | |
298 ByteBuffer[] buffers = new ByteBuffer[size]; | |
299 int[] positions = new int[size]; | |
300 int[] limits = new int[size]; | |
301 for (int i = 0; i < size; i++) { | |
302 ByteBuffer buffer = mPendingData.poll(); | |
303 buffers[i] = buffer; | |
304 positions[i] = buffer.position(); | |
305 limits[i] = buffer.limit(); | |
306 } | |
307 assert mPendingData.isEmpty(); | |
308 if (!nativeWritevData(mNativeStream, buffers, positions, limits, mEndOfS treamWritten)) { | |
309 throw new IllegalArgumentException("Unable to call native write"); | |
310 } | |
311 } | |
312 | |
277 @Override | 313 @Override |
278 public void ping(PingCallback callback, Executor executor) { | 314 public void ping(PingCallback callback, Executor executor) { |
279 // TODO(mef): May be last thing to be implemented on Android. | 315 // TODO(mef): May be last thing to be implemented on Android. |
280 throw new UnsupportedOperationException("ping is not supported yet."); | 316 throw new UnsupportedOperationException("ping is not supported yet."); |
281 } | 317 } |
282 | 318 |
283 @Override | 319 @Override |
284 public void windowUpdate(int windowSizeIncrement) { | 320 public void windowUpdate(int windowSizeIncrement) { |
285 // TODO(mef): Understand the needs and semantics of this method. | 321 // TODO(mef): Understand the needs and semantics of this method. |
286 throw new UnsupportedOperationException("windowUpdate is not supported y et."); | 322 throw new UnsupportedOperationException("windowUpdate is not supported y et."); |
(...skipping 17 matching lines...) Expand all Loading... | |
304 } | 340 } |
305 } | 341 } |
306 | 342 |
307 @GuardedBy("mNativeStreamLock") | 343 @GuardedBy("mNativeStreamLock") |
308 private boolean isDoneLocked() { | 344 private boolean isDoneLocked() { |
309 return mReadState != State.NOT_STARTED && mNativeStream == 0; | 345 return mReadState != State.NOT_STARTED && mNativeStream == 0; |
310 } | 346 } |
311 | 347 |
312 @SuppressWarnings("unused") | 348 @SuppressWarnings("unused") |
313 @CalledByNative | 349 @CalledByNative |
314 private void onRequestHeadersSent() { | 350 private void onStreamReady() { |
315 postTaskToExecutor(new Runnable() { | 351 postTaskToExecutor(new Runnable() { |
316 public void run() { | 352 public void run() { |
317 synchronized (mNativeStreamLock) { | 353 synchronized (mNativeStreamLock) { |
318 if (isDoneLocked()) { | 354 if (isDoneLocked()) { |
319 return; | 355 return; |
320 } | 356 } |
321 if (doesMethodAllowWriteData(mInitialMethod)) { | 357 if (doesMethodAllowWriteData(mInitialMethod)) { |
322 mWriteState = State.WAITING_FOR_WRITE; | 358 mWriteState = State.WAITING_FOR_WRITE; |
323 } else { | 359 } else { |
324 mWriteState = State.WRITING_DONE; | 360 mWriteState = State.WRITING_DONE; |
325 } | 361 } |
326 } | 362 } |
327 | 363 |
328 try { | 364 try { |
329 mCallback.onRequestHeadersSent(CronetBidirectionalStream.thi s); | 365 mCallback.onStreamReady(CronetBidirectionalStream.this); |
330 } catch (Exception e) { | 366 } catch (Exception e) { |
331 onCallbackException(e); | 367 onCallbackException(e); |
332 } | 368 } |
333 } | 369 } |
334 }); | 370 }); |
335 } | 371 } |
336 | 372 |
337 /** | 373 /** |
338 * Called when the final set of headers, after all redirects, | 374 * Called when the final set of headers, after all redirects, |
339 * is received. Can only be called once for each stream. | 375 * is received. Can only be called once for each stream. |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
384 } | 420 } |
385 byteBuffer.position(initialPosition + bytesRead); | 421 byteBuffer.position(initialPosition + bytesRead); |
386 assert mOnReadCompletedTask.mByteBuffer == null; | 422 assert mOnReadCompletedTask.mByteBuffer == null; |
387 mOnReadCompletedTask.mByteBuffer = byteBuffer; | 423 mOnReadCompletedTask.mByteBuffer = byteBuffer; |
388 mOnReadCompletedTask.mEndOfStream = (bytesRead == 0); | 424 mOnReadCompletedTask.mEndOfStream = (bytesRead == 0); |
389 postTaskToExecutor(mOnReadCompletedTask); | 425 postTaskToExecutor(mOnReadCompletedTask); |
390 } | 426 } |
391 | 427 |
392 @SuppressWarnings("unused") | 428 @SuppressWarnings("unused") |
393 @CalledByNative | 429 @CalledByNative |
394 private void onWriteCompleted( | 430 private void onWritevCompleted(final ByteBuffer[] byteBuffers, int[] initial Positions, |
395 final ByteBuffer byteBuffer, int initialPosition, int initialLimit) { | 431 int[] initialLimits, boolean endOfStream) { |
396 if (byteBuffer.position() != initialPosition || byteBuffer.limit() != in itialLimit) { | 432 assert byteBuffers.length == initialPositions.length; |
397 failWithException( | 433 assert byteBuffers.length == initialLimits.length; |
398 new CronetException("ByteBuffer modified externally during w rite", null)); | 434 assert initialPositions.length == initialLimits.length; |
399 return; | 435 for (int i = 0; i < byteBuffers.length; i++) { |
436 ByteBuffer buffer = byteBuffers[i]; | |
437 if (buffer.position() != initialPositions[i] || buffer.limit() != in itialLimits[i]) { | |
438 failWithException( | |
439 new CronetException("ByteBuffer modified externally duri ng write", null)); | |
440 return; | |
441 } | |
442 // Current implementation always writes the complete buffer. | |
443 buffer.position(buffer.limit()); | |
444 OnWriteCompletedRunnable runnable = new OnWriteCompletedRunnable(); | |
445 runnable.mByteBuffer = buffer; | |
446 runnable.mEndOfStream = endOfStream; | |
447 postTaskToExecutor(runnable); | |
400 } | 448 } |
401 // Current implementation always writes the complete buffer. | |
402 byteBuffer.position(byteBuffer.limit()); | |
403 assert mOnWriteCompletedTask.mByteBuffer == null; | |
404 mOnWriteCompletedTask.mByteBuffer = byteBuffer; | |
405 postTaskToExecutor(mOnWriteCompletedTask); | |
406 } | 449 } |
407 | 450 |
408 @SuppressWarnings("unused") | 451 @SuppressWarnings("unused") |
409 @CalledByNative | 452 @CalledByNative |
410 private void onResponseTrailersReceived(String[] trailers) { | 453 private void onResponseTrailersReceived(String[] trailers) { |
411 final UrlResponseInfo.HeaderBlock trailersBlock = | 454 final UrlResponseInfo.HeaderBlock trailersBlock = |
412 new UrlResponseInfo.HeaderBlock(headersListFromStrings(trailers) ); | 455 new UrlResponseInfo.HeaderBlock(headersListFromStrings(trailers) ); |
413 postTaskToExecutor(new Runnable() { | 456 postTaskToExecutor(new Runnable() { |
414 public void run() { | 457 public void run() { |
415 synchronized (mNativeStreamLock) { | 458 synchronized (mNativeStreamLock) { |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 */ | 654 */ |
612 private void failWithException(final CronetException exception) { | 655 private void failWithException(final CronetException exception) { |
613 postTaskToExecutor(new Runnable() { | 656 postTaskToExecutor(new Runnable() { |
614 public void run() { | 657 public void run() { |
615 failWithExceptionOnExecutor(exception); | 658 failWithExceptionOnExecutor(exception); |
616 } | 659 } |
617 }); | 660 }); |
618 } | 661 } |
619 | 662 |
620 // Native methods are implemented in cronet_bidirectional_stream_adapter.cc. | 663 // Native methods are implemented in cronet_bidirectional_stream_adapter.cc. |
621 private native long nativeCreateBidirectionalStream(long urlRequestContextAd apter); | 664 private native long nativeCreateBidirectionalStream( |
665 long urlRequestContextAdapter, boolean disableAutoFlush); | |
622 | 666 |
623 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") | 667 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") |
624 private native int nativeStart(long nativePtr, String url, int priority, Str ing method, | 668 private native int nativeStart(long nativePtr, String url, int priority, Str ing method, |
625 String[] headers, boolean endOfStream); | 669 String[] headers, boolean endOfStream); |
626 | 670 |
627 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") | 671 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") |
628 private native boolean nativeReadData( | 672 private native boolean nativeReadData( |
629 long nativePtr, ByteBuffer byteBuffer, int position, int limit); | 673 long nativePtr, ByteBuffer byteBuffer, int position, int limit); |
630 | 674 |
631 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") | 675 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") |
632 private native boolean nativeWriteData( | 676 private native boolean nativeWritevData(long nativePtr, ByteBuffer[] buffers , int[] positions, |
633 long nativePtr, ByteBuffer byteBuffer, int position, int limit, bool ean endOfStream); | 677 int[] limits, boolean endOfStream); |
634 | 678 |
635 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") | 679 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") |
636 private native void nativeDestroy(long nativePtr, boolean sendOnCanceled); | 680 private native void nativeDestroy(long nativePtr, boolean sendOnCanceled); |
637 } | 681 } |
OLD | NEW |