Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_IOS_CRONET_C_FOR_GRPC_H_ | 5 #ifndef COMPONENTS_CRONET_IOS_CRONET_C_FOR_GRPC_H_ |
| 6 #define COMPONENTS_CRONET_IOS_CRONET_C_FOR_GRPC_H_ | 6 #define COMPONENTS_CRONET_IOS_CRONET_C_FOR_GRPC_H_ |
| 7 | 7 |
| 8 #define CRONET_EXPORT __attribute__((visibility("default"))) | 8 #define CRONET_EXPORT __attribute__((visibility("default"))) |
| 9 | 9 |
| 10 #ifdef __cplusplus | 10 #ifdef __cplusplus |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 | 137 |
| 138 /* TBD: The following methods return int. Should it be a custom type? */ | 138 /* TBD: The following methods return int. Should it be a custom type? */ |
| 139 | 139 |
| 140 /* Destroy stream object. Destroy could be called from any thread, including | 140 /* Destroy stream object. Destroy could be called from any thread, including |
| 141 * network thread, but is posted, so |stream| is valid until calling task is | 141 * network thread, but is posted, so |stream| is valid until calling task is |
| 142 * complete. | 142 * complete. |
| 143 */ | 143 */ |
| 144 CRONET_EXPORT | 144 CRONET_EXPORT |
| 145 int cronet_bidirectional_stream_destroy(cronet_bidirectional_stream* stream); | 145 int cronet_bidirectional_stream_destroy(cronet_bidirectional_stream* stream); |
| 146 | 146 |
| 147 /** | |
| 148 * Disables or enables auto flush. By default, data is flushed after | |
| 149 * every cronet_bidirectional_stream_write(). If the auto flush is disabled, | |
| 150 * the client should explicitly call cronet_bidirectional_stream_flush to flush | |
| 151 * the data. | |
| 152 */ | |
| 153 CRONET_EXPORT int cronet_bidirectional_stream_disable_auto_flush( | |
| 154 cronet_bidirectional_stream* stream, | |
| 155 bool disable_auto_flush); | |
| 156 | |
| 157 /** | |
| 158 * Delays sending request headers until cronet_bidirectional_stream_flush() | |
| 159 * is called. This flag is currently only respected when QUIC is negotiated. | |
| 160 * When true, QUIC will send request header frame along with data frame(s) | |
| 161 * as a single packet when possible. | |
| 162 */ | |
| 163 CRONET_EXPORT | |
| 164 int cronet_bidirectional_stream_delay_request_headers_until_flush( | |
| 165 cronet_bidirectional_stream* stream, | |
| 166 bool delay_headers_until_flush); | |
| 167 | |
| 147 /* Start the stream by sending request to |url| using |method| and |headers|. If | 168 /* Start the stream by sending request to |url| using |method| and |headers|. If |
| 148 * |end_of_stream| is true, then no data is expected to be written. The |method| | 169 * |end_of_stream| is true, then no data is expected to be written. The |method| |
| 149 * is HTTP verb, with PUT having a special meaning to mark idempotent request, | 170 * is HTTP verb, with PUT having a special meaning to mark idempotent request, |
| 150 * which could use QUIC 0-RTT. | 171 * which could use QUIC 0-RTT. |
| 151 */ | 172 */ |
| 152 CRONET_EXPORT | 173 CRONET_EXPORT |
| 153 int cronet_bidirectional_stream_start( | 174 int cronet_bidirectional_stream_start( |
| 154 cronet_bidirectional_stream* stream, | 175 cronet_bidirectional_stream* stream, |
| 155 const char* url, | 176 const char* url, |
| 156 int priority, | 177 int priority, |
| 157 const char* method, | 178 const char* method, |
| 158 const cronet_bidirectional_stream_header_array* headers, | 179 const cronet_bidirectional_stream_header_array* headers, |
| 159 bool end_of_stream); | 180 bool end_of_stream); |
| 160 | 181 |
| 161 /* Read response data into |buffer| of |capacity| length. Must only be called at | 182 /* Read response data into |buffer| of |capacity| length. Must only be called at |
| 162 * most once in response to each invocation of the | 183 * most once in response to each invocation of the |
| 163 * on_stream_ready()/on_response_headers_received() and on_read_completed() | 184 * on_stream_ready()/on_response_headers_received() and on_read_completed() |
| 164 * methods of the cronet_bidirectional_stream_callback. | 185 * methods of the cronet_bidirectional_stream_callback. |
| 165 * Each call will result in an invocation of the callback's | 186 * Each call will result in an invocation of the callback's |
| 166 * on_read_completed() method if data is read, or its on_failed() method if | 187 * on_read_completed() method if data is read, or its on_failed() method if |
| 167 * there's an error. The callback's on_succeeded() method is also invoked if | 188 * there's an error. The callback's on_succeeded() method is also invoked if |
| 168 * there is no more data to read and |end_of_stream| was previously sent. | 189 * there is no more data to read and |end_of_stream| was previously sent. |
| 169 */ | 190 */ |
| 170 CRONET_EXPORT | 191 CRONET_EXPORT |
| 171 int cronet_bidirectional_stream_read(cronet_bidirectional_stream* stream, | 192 int cronet_bidirectional_stream_read(cronet_bidirectional_stream* stream, |
| 172 char* buffer, | 193 char* buffer, |
| 173 int capacity); | 194 int capacity); |
| 174 | 195 |
| 175 /* Write request data from |buffer| of |buffer_length| length. Must only be | 196 /* Write request data from |buffer| of |buffer_length| length. If auto flush is |
|
xunjieli
2016/06/10 16:30:50
nit: Writes?
mef
2016/06/10 18:36:37
Done.
| |
| 176 * called at most once in response to each invocation of the | 197 * disabled, data will be sent only after cronet_bidirectional_stream_flush() is |
| 177 * on_stream_ready() and on_write_completed() methods of the | 198 * called. |
| 178 * cronet_bidirectional_stream_callback. | |
| 179 * Each call will result in an invocation the callback's on_write_completed() | 199 * Each call will result in an invocation the callback's on_write_completed() |
| 180 * method if data is sent, or its on_failed() method if there's an error. | 200 * method if data is sent, or its on_failed() method if there's an error. |
| 181 * The callback's on_succeeded() method is also invoked if |end_of_stream| is | 201 * The callback's on_succeeded() method is also invoked if |end_of_stream| is |
| 182 * set and all response data has been read. | 202 * set and all response data has been read. |
| 183 */ | 203 */ |
| 184 CRONET_EXPORT | 204 CRONET_EXPORT |
| 185 int cronet_bidirectional_stream_write(cronet_bidirectional_stream* stream, | 205 int cronet_bidirectional_stream_write(cronet_bidirectional_stream* stream, |
| 186 const char* buffer, | 206 const char* buffer, |
| 187 int buffer_length, | 207 int buffer_length, |
| 188 bool end_of_stream); | 208 bool end_of_stream); |
| 189 | 209 |
| 210 /** | |
| 211 * Flush pending writes. This method should not be called before invocation of | |
|
xunjieli
2016/06/10 16:30:50
nit: Flushes?
mef
2016/06/10 18:36:37
Done.
| |
| 212 * on_stream_ready() method of the cronet_bidirectional_stream_callback. | |
| 213 * For each previously called cronet_bidirectional_stream_write() | |
| 214 * a corresponding on_write_completed() callback will be invoked when the buffer | |
| 215 * is sent. | |
| 216 */ | |
| 217 CRONET_EXPORT | |
| 218 int cronet_bidirectional_stream_flush(cronet_bidirectional_stream* stream); | |
| 219 | |
| 190 /* Cancels the stream. Can be called at any time after | 220 /* Cancels the stream. Can be called at any time after |
| 191 * cronet_bidirectional_stream_start(). The on_canceled() method of | 221 * cronet_bidirectional_stream_start(). The on_canceled() method of |
| 192 * cronet_bidirectional_stream_callback will be invoked when cancelation | 222 * cronet_bidirectional_stream_callback will be invoked when cancelation |
| 193 * is complete and no further callback methods will be invoked. If the | 223 * is complete and no further callback methods will be invoked. If the |
| 194 * stream has completed or has not started, calling | 224 * stream has completed or has not started, calling |
| 195 * cronet_bidirectional_stream_cancel() has no effect and on_canceled() will not | 225 * cronet_bidirectional_stream_cancel() has no effect and on_canceled() will not |
| 196 * be invoked. At most one callback method may be invoked after | 226 * be invoked. At most one callback method may be invoked after |
| 197 * cronet_bidirectional_stream_cancel() has completed. | 227 * cronet_bidirectional_stream_cancel() has completed. |
| 198 */ | 228 */ |
| 199 CRONET_EXPORT | 229 CRONET_EXPORT |
| 200 int cronet_bidirectional_stream_cancel(cronet_bidirectional_stream* stream); | 230 int cronet_bidirectional_stream_cancel(cronet_bidirectional_stream* stream); |
| 201 | 231 |
| 202 /* Returns true if the |stream| was successfully started and is now done | 232 /* Returns true if the |stream| was successfully started and is now done |
| 203 * (succeeded, canceled, or failed). | 233 * (succeeded, canceled, or failed). |
| 204 * Returns false if the |stream| stream is not yet started or is in progress. | 234 * Returns false if the |stream| stream is not yet started or is in progress. |
| 205 */ | 235 */ |
| 206 CRONET_EXPORT | 236 CRONET_EXPORT |
| 207 bool cronet_bidirectional_stream_is_done(cronet_bidirectional_stream* stream); | 237 bool cronet_bidirectional_stream_is_done(cronet_bidirectional_stream* stream); |
| 208 | 238 |
| 209 #ifdef __cplusplus | 239 #ifdef __cplusplus |
| 210 } | 240 } |
| 211 #endif | 241 #endif |
| 212 | 242 |
| 213 #endif // COMPONENTS_CRONET_IOS_CRONET_C_FOR_GRPC_H_ | 243 #endif // COMPONENTS_CRONET_IOS_CRONET_C_FOR_GRPC_H_ |
| OLD | NEW |