| 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 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_ |
| 6 #define COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_ | 6 #define COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 jboolean jend_of_stream); | 87 jboolean jend_of_stream); |
| 88 | 88 |
| 89 // Releases all resources for the request and deletes the object itself. | 89 // Releases all resources for the request and deletes the object itself. |
| 90 // |jsend_on_canceled| indicates if Java onCanceled callback should be | 90 // |jsend_on_canceled| indicates if Java onCanceled callback should be |
| 91 // issued to indicate that no more callbacks will be issued. | 91 // issued to indicate that no more callbacks will be issued. |
| 92 void Destroy(JNIEnv* env, | 92 void Destroy(JNIEnv* env, |
| 93 const base::android::JavaParamRef<jobject>& jcaller, | 93 const base::android::JavaParamRef<jobject>& jcaller, |
| 94 jboolean jsend_on_canceled); | 94 jboolean jsend_on_canceled); |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 typedef std::vector<scoped_refptr<IOBufferWithByteBuffer>> IOByteBufferList; | 97 typedef std::vector<scoped_refptr<IOBufferWithByteBuffer>> |
| 98 IOBufferWithByteBufferList; |
| 98 // net::BidirectionalStream::Delegate implementations: | 99 // net::BidirectionalStream::Delegate implementations: |
| 99 void OnStreamReady() override; | 100 void OnStreamReady() override; |
| 100 void OnHeadersReceived(const net::SpdyHeaderBlock& response_headers) override; | 101 void OnHeadersReceived(const net::SpdyHeaderBlock& response_headers) override; |
| 101 void OnDataRead(int bytes_read) override; | 102 void OnDataRead(int bytes_read) override; |
| 102 void OnDataSent() override; | 103 void OnDataSent() override; |
| 103 void OnTrailersReceived(const net::SpdyHeaderBlock& trailers) override; | 104 void OnTrailersReceived(const net::SpdyHeaderBlock& trailers) override; |
| 104 void OnFailed(int error) override; | 105 void OnFailed(int error) override; |
| 105 | 106 |
| 106 void StartOnNetworkThread( | 107 void StartOnNetworkThread( |
| 107 std::unique_ptr<net::BidirectionalStreamRequestInfo> request_info); | 108 std::unique_ptr<net::BidirectionalStreamRequestInfo> request_info); |
| 108 void ReadDataOnNetworkThread( | 109 void ReadDataOnNetworkThread( |
| 109 scoped_refptr<IOBufferWithByteBuffer> read_buffer, | 110 scoped_refptr<IOBufferWithByteBuffer> read_buffer, |
| 110 int buffer_size); | 111 int buffer_size); |
| 111 void WritevDataOnNetworkThread(const IOByteBufferList& buffers, | 112 void WritevDataOnNetworkThread(const IOBufferWithByteBufferList& buffers, |
| 112 bool end_of_stream); | 113 bool end_of_stream); |
| 113 void DestroyOnNetworkThread(bool send_on_canceled); | 114 void DestroyOnNetworkThread(bool send_on_canceled); |
| 114 // Gets headers as a Java array. | 115 // Gets headers as a Java array. |
| 115 base::android::ScopedJavaLocalRef<jobjectArray> GetHeadersArray( | 116 base::android::ScopedJavaLocalRef<jobjectArray> GetHeadersArray( |
| 116 JNIEnv* env, | 117 JNIEnv* env, |
| 117 const net::SpdyHeaderBlock& header_block); | 118 const net::SpdyHeaderBlock& header_block); |
| 118 | 119 |
| 119 CronetURLRequestContextAdapter* const context_; | 120 CronetURLRequestContextAdapter* const context_; |
| 120 | 121 |
| 121 // Java object that owns this CronetBidirectionalStreamAdapter. | 122 // Java object that owns this CronetBidirectionalStreamAdapter. |
| 122 base::android::ScopedJavaGlobalRef<jobject> owner_; | 123 base::android::ScopedJavaGlobalRef<jobject> owner_; |
| 123 const bool disable_auto_flush_; | 124 const bool disable_auto_flush_; |
| 124 // Whether an end of stream flag is passed in through a write call. | 125 // Whether an end of stream flag is passed in through a write call. |
| 125 // Not applicable to HTTP methods that do not send data. | 126 // Not applicable to HTTP methods that do not send data. |
| 126 bool write_end_of_stream_; | 127 bool write_end_of_stream_; |
| 127 | 128 |
| 128 scoped_refptr<IOBufferWithByteBuffer> read_buffer_; | 129 scoped_refptr<IOBufferWithByteBuffer> read_buffer_; |
| 129 IOByteBufferList write_buffer_list_; | 130 IOBufferWithByteBufferList write_buffer_list_; |
| 130 std::unique_ptr<net::BidirectionalStream> bidi_stream_; | 131 std::unique_ptr<net::BidirectionalStream> bidi_stream_; |
| 131 | 132 |
| 132 // Whether BidirectionalStream::Delegate::OnFailed callback is invoked. | 133 // Whether BidirectionalStream::Delegate::OnFailed callback is invoked. |
| 133 bool stream_failed_; | 134 bool stream_failed_; |
| 134 | 135 |
| 135 DISALLOW_COPY_AND_ASSIGN(CronetBidirectionalStreamAdapter); | 136 DISALLOW_COPY_AND_ASSIGN(CronetBidirectionalStreamAdapter); |
| 136 }; | 137 }; |
| 137 | 138 |
| 138 } // namespace cronet | 139 } // namespace cronet |
| 139 | 140 |
| 140 #endif // COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_ | 141 #endif // COMPONENTS_CRONET_ANDROID_CRONET_BIDIRECTIONAL_STREAM_ADAPTER_H_ |
| OLD | NEW |