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

Side by Side Diff: components/cronet/android/java/src/org/chromium/net/impl/CronetBidirectionalStream.java

Issue 2514783002: [Cronet] Add callback wrapper classes to enforce API version checking. (Closed)
Patch Set: fix JNIAdditionalImport Created 4 years 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
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 called. */ 72 called. */
73 WAITING_FOR_FLUSH, 73 WAITING_FOR_FLUSH,
74 /* Writing to the remote, {@code onWritevCompleted()} callback will be c alled when done. */ 74 /* Writing to the remote, {@code onWritevCompleted()} callback will be c alled when done. */
75 WRITING, 75 WRITING,
76 /* There is no more data to write and stream is half-closed by the local side. */ 76 /* There is no more data to write and stream is half-closed by the local side. */
77 WRITING_DONE, 77 WRITING_DONE,
78 } 78 }
79 79
80 private final CronetUrlRequestContext mRequestContext; 80 private final CronetUrlRequestContext mRequestContext;
81 private final Executor mExecutor; 81 private final Executor mExecutor;
82 private final Callback mCallback; 82 private final VersionSafeCallbacks.BidirectionalStreamCallback mCallback;
83 private final String mInitialUrl; 83 private final String mInitialUrl;
84 private final int mInitialPriority; 84 private final int mInitialPriority;
85 private final String mInitialMethod; 85 private final String mInitialMethod;
86 private final String mRequestHeaders[]; 86 private final String mRequestHeaders[];
87 private final boolean mDelayRequestHeadersUntilFirstFlush; 87 private final boolean mDelayRequestHeadersUntilFirstFlush;
88 private final Collection<Object> mRequestAnnotations; 88 private final Collection<Object> mRequestAnnotations;
89 private UrlRequestException mException; 89 private UrlRequestException mException;
90 90
91 /* 91 /*
92 * Synchronizes access to mNativeStream, mReadState and mWriteState. 92 * Synchronizes access to mNativeStream, mReadState and mWriteState.
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 } 224 }
225 225
226 CronetBidirectionalStream(CronetUrlRequestContext requestContext, String url , 226 CronetBidirectionalStream(CronetUrlRequestContext requestContext, String url ,
227 @CronetEngineBase.StreamPriority int priority, Callback callback, Ex ecutor executor, 227 @CronetEngineBase.StreamPriority int priority, Callback callback, Ex ecutor executor,
228 String httpMethod, List<Map.Entry<String, String>> requestHeaders, 228 String httpMethod, List<Map.Entry<String, String>> requestHeaders,
229 boolean delayRequestHeadersUntilNextFlush, Collection<Object> reques tAnnotations) { 229 boolean delayRequestHeadersUntilNextFlush, Collection<Object> reques tAnnotations) {
230 mRequestContext = requestContext; 230 mRequestContext = requestContext;
231 mInitialUrl = url; 231 mInitialUrl = url;
232 mInitialPriority = convertStreamPriority(priority); 232 mInitialPriority = convertStreamPriority(priority);
233 mCallback = callback; 233 mCallback = new VersionSafeCallbacks.BidirectionalStreamCallback(callbac k);
234 mExecutor = executor; 234 mExecutor = executor;
235 mInitialMethod = httpMethod; 235 mInitialMethod = httpMethod;
236 mRequestHeaders = stringsFromHeaderList(requestHeaders); 236 mRequestHeaders = stringsFromHeaderList(requestHeaders);
237 mDelayRequestHeadersUntilFirstFlush = delayRequestHeadersUntilNextFlush; 237 mDelayRequestHeadersUntilFirstFlush = delayRequestHeadersUntilNextFlush;
238 mPendingData = new LinkedList<>(); 238 mPendingData = new LinkedList<>();
239 mFlushData = new LinkedList<>(); 239 mFlushData = new LinkedList<>();
240 mRequestAnnotations = requestAnnotations; 240 mRequestAnnotations = requestAnnotations;
241 } 241 }
242 242
243 @Override 243 @Override
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 private native boolean nativeReadData( 802 private native boolean nativeReadData(
803 long nativePtr, ByteBuffer byteBuffer, int position, int limit); 803 long nativePtr, ByteBuffer byteBuffer, int position, int limit);
804 804
805 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") 805 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter")
806 private native boolean nativeWritevData(long nativePtr, ByteBuffer[] buffers , int[] positions, 806 private native boolean nativeWritevData(long nativePtr, ByteBuffer[] buffers , int[] positions,
807 int[] limits, boolean endOfStream); 807 int[] limits, boolean endOfStream);
808 808
809 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter") 809 @NativeClassQualifiedName("CronetBidirectionalStreamAdapter")
810 private native void nativeDestroy(long nativePtr, boolean sendOnCanceled); 810 private native void nativeDestroy(long nativePtr, boolean sendOnCanceled);
811 } 811 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698