| 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 #ifdef __cplusplus | 8 #ifdef __cplusplus |
| 9 extern "C" { | 9 extern "C" { |
| 10 #endif | 10 #endif |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 | 36 |
| 37 /* Array of request or response headers or trailers. */ | 37 /* Array of request or response headers or trailers. */ |
| 38 typedef struct cronet_bidirectional_stream_header_array { | 38 typedef struct cronet_bidirectional_stream_header_array { |
| 39 size_t count; | 39 size_t count; |
| 40 size_t capacity; | 40 size_t capacity; |
| 41 cronet_bidirectional_stream_header* headers; | 41 cronet_bidirectional_stream_header* headers; |
| 42 } cronet_bidirectional_stream_header_array; | 42 } cronet_bidirectional_stream_header_array; |
| 43 | 43 |
| 44 /* Set of callbacks used to receive callbacks from bidirectional stream. */ | 44 /* Set of callbacks used to receive callbacks from bidirectional stream. */ |
| 45 typedef struct cronet_bidirectional_stream_callback { | 45 typedef struct cronet_bidirectional_stream_callback { |
| 46 /* Invoked when request headers are sent. Indicates that stream has initiated | 46 /* Invoked when the stream is ready for reading and writing. |
| 47 * the request. Consumer may call cronet_bidirectional_stream_write() to start | 47 * Consumer may call cronet_bidirectional_stream_read() to start reading data. |
| 48 * writing data. | 48 * Consumer may call cronet_bidirectional_stream_write() to start writing |
| 49 * data. |
| 49 */ | 50 */ |
| 50 void (*on_request_headers_sent)(cronet_bidirectional_stream* stream); | 51 void (*on_stream_ready)(cronet_bidirectional_stream* stream); |
| 51 | 52 |
| 52 /* Invoked when initial response headers are received. | 53 /* Invoked when initial response headers are received. |
| 53 * Consumer must call cronet_bidirectional_stream_read() to start reading. | 54 * Consumer must call cronet_bidirectional_stream_read() to start reading. |
| 54 * Consumer may call cronet_bidirectional_stream_write() to start writing or | 55 * Consumer may call cronet_bidirectional_stream_write() to start writing or |
| 55 * close the stream. Contents of |headers| is valid for duration of the call. | 56 * close the stream. Contents of |headers| is valid for duration of the call. |
| 56 */ | 57 */ |
| 57 void (*on_response_headers_received)( | 58 void (*on_response_headers_received)( |
| 58 cronet_bidirectional_stream* stream, | 59 cronet_bidirectional_stream* stream, |
| 59 const cronet_bidirectional_stream_header_array* headers, | 60 const cronet_bidirectional_stream_header_array* headers, |
| 60 const char* negotiated_protocol); | 61 const char* negotiated_protocol); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 int cronet_bidirectional_stream_start( | 148 int cronet_bidirectional_stream_start( |
| 148 cronet_bidirectional_stream* stream, | 149 cronet_bidirectional_stream* stream, |
| 149 const char* url, | 150 const char* url, |
| 150 int priority, | 151 int priority, |
| 151 const char* method, | 152 const char* method, |
| 152 const cronet_bidirectional_stream_header_array* headers, | 153 const cronet_bidirectional_stream_header_array* headers, |
| 153 bool end_of_stream); | 154 bool end_of_stream); |
| 154 | 155 |
| 155 /* Read response data into |buffer| of |capacity| length. Must only be called at | 156 /* Read response data into |buffer| of |capacity| length. Must only be called at |
| 156 * most once in response to each invocation of the | 157 * most once in response to each invocation of the |
| 157 * on_response_headers_received() and on_read_completed() methods of the | 158 * on_stream_ready()/on_response_headers_received() and on_read_completed() |
| 158 * cronet_bidirectional_stream_callback. | 159 * methods of the cronet_bidirectional_stream_callback. |
| 159 * Each call will result in an invocation of the callback's | 160 * Each call will result in an invocation of the callback's |
| 160 * on_read_completed() method if data is read, or its on_failed() method if | 161 * on_read_completed() method if data is read, or its on_failed() method if |
| 161 * there's an error. The callback's on_succeeded() method is also invoked if | 162 * there's an error. The callback's on_succeeded() method is also invoked if |
| 162 * there is no more data to read and |end_of_stream| was previously sent. | 163 * there is no more data to read and |end_of_stream| was previously sent. |
| 163 */ | 164 */ |
| 164 int cronet_bidirectional_stream_read(cronet_bidirectional_stream* stream, | 165 int cronet_bidirectional_stream_read(cronet_bidirectional_stream* stream, |
| 165 char* buffer, | 166 char* buffer, |
| 166 int capacity); | 167 int capacity); |
| 167 | 168 |
| 168 /* Write request data from |buffer| of |buffer_length| length. Must only be | 169 /* Write request data from |buffer| of |buffer_length| length. Must only be |
| 169 * called at most once in response to each invocation of the | 170 * called at most once in response to each invocation of the |
| 170 * on_request_headers_sent() and on_write_completed() methods of the | 171 * on_stream_ready() and on_write_completed() methods of the |
| 171 * cronet_bidirectional_stream_callback. | 172 * cronet_bidirectional_stream_callback. |
| 172 * Each call will result in an invocation the callback's on_write_completed() | 173 * Each call will result in an invocation the callback's on_write_completed() |
| 173 * method if data is sent, or its on_failed() method if there's an error. | 174 * method if data is sent, or its on_failed() method if there's an error. |
| 174 * The callback's on_succeeded() method is also invoked if |end_of_stream| is | 175 * The callback's on_succeeded() method is also invoked if |end_of_stream| is |
| 175 * set and all response data has been read. | 176 * set and all response data has been read. |
| 176 */ | 177 */ |
| 177 int cronet_bidirectional_stream_write(cronet_bidirectional_stream* stream, | 178 int cronet_bidirectional_stream_write(cronet_bidirectional_stream* stream, |
| 178 const char* buffer, | 179 const char* buffer, |
| 179 int buffer_length, | 180 int buffer_length, |
| 180 bool end_of_stream); | 181 bool end_of_stream); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 194 * (succeeded, canceled, or failed). | 195 * (succeeded, canceled, or failed). |
| 195 * Returns false if the |stream| stream is not yet started or is in progress. | 196 * Returns false if the |stream| stream is not yet started or is in progress. |
| 196 */ | 197 */ |
| 197 bool cronet_bidirectional_stream_is_done(cronet_bidirectional_stream* stream); | 198 bool cronet_bidirectional_stream_is_done(cronet_bidirectional_stream* stream); |
| 198 | 199 |
| 199 #ifdef __cplusplus | 200 #ifdef __cplusplus |
| 200 } | 201 } |
| 201 #endif | 202 #endif |
| 202 | 203 |
| 203 #endif // COMPONENTS_CRONET_IOS_CRONET_C_FOR_GRPC_H_ | 204 #endif // COMPONENTS_CRONET_IOS_CRONET_C_FOR_GRPC_H_ |
| OLD | NEW |