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

Side by Side Diff: components/cronet/ios/cronet_c_for_grpc.h

Issue 2050483002: [Cronet] Coalesce small buffers into single QUIC packet in GRPC on iOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove flushing_write_data_. Created 4 years, 6 months 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 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 void (*on_failed)(cronet_bidirectional_stream* stream, int net_error); 110 void (*on_failed)(cronet_bidirectional_stream* stream, int net_error);
111 111
112 /** 112 /**
113 * Invoked if the stream was canceled via 113 * Invoked if the stream was canceled via
114 * cronet_bidirectional_stream_cancel(). Once invoked, no further callback 114 * cronet_bidirectional_stream_cancel(). Once invoked, no further callback
115 * methods will be invoked. 115 * methods will be invoked.
116 */ 116 */
117 void (*on_canceled)(cronet_bidirectional_stream* stream); 117 void (*on_canceled)(cronet_bidirectional_stream* stream);
118 } cronet_bidirectional_stream_callback; 118 } cronet_bidirectional_stream_callback;
119 119
120 /* Create a new stream object that uses |engine| and |callback|. All stream 120 /* Creates a new stream object that uses |engine| and |callback|. All stream
121 * tasks are performed asynchronously on the |engine| network thread. |callback| 121 * tasks are performed asynchronously on the |engine| network thread. |callback|
122 * methods are invoked synchronously on the |engine| network thread, but must 122 * methods are invoked synchronously on the |engine| network thread, but must
123 * not run tasks on the current thread to prevent blocking networking operations 123 * not run tasks on the current thread to prevent blocking networking operations
124 * and causing exceptions during shutdown. The |annotation| is stored in 124 * and causing exceptions during shutdown. The |annotation| is stored in
125 * bidirectional stream for arbitrary use by application. 125 * bidirectional stream for arbitrary use by application.
126 * 126 *
127 * Returned |cronet_bidirectional_stream*| is owned by the caller, and must be 127 * Returned |cronet_bidirectional_stream*| is owned by the caller, and must be
128 * destroyed using |cronet_bidirectional_stream_destroy|. 128 * destroyed using |cronet_bidirectional_stream_destroy|.
129 * 129 *
130 * Both |calback| and |engine| must remain valid until stream is destroyed. 130 * Both |calback| and |engine| must remain valid until stream is destroyed.
131 */ 131 */
132 CRONET_EXPORT 132 CRONET_EXPORT
133 cronet_bidirectional_stream* cronet_bidirectional_stream_create( 133 cronet_bidirectional_stream* cronet_bidirectional_stream_create(
134 cronet_engine* engine, 134 cronet_engine* engine,
135 void* annotation, 135 void* annotation,
136 cronet_bidirectional_stream_callback* callback); 136 cronet_bidirectional_stream_callback* callback);
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 /* Destroys 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 /* Start the stream by sending request to |url| using |method| and |headers|. If 147 /**
148 * |end_of_stream| is true, then no data is expected to be written. The |method| 148 * Disables or enables auto flush. By default, data is flushed after
149 * is HTTP verb, with PUT having a special meaning to mark idempotent request, 149 * every cronet_bidirectional_stream_write(). If the auto flush is disabled,
150 * which could use QUIC 0-RTT. 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(
xunjieli 2016/06/14 14:29:35 Why do these two methods return an int? should we
mef 2016/06/14 19:54:30 Done.
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
168 /* Starts the stream by sending request to |url| using |method| and |headers|.
169 * If |end_of_stream| is true, then no data is expected to be written. The
170 * |method| is HTTP verb, with PUT having a special meaning to mark idempotent
171 * request, 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 /* Reads response data into |buffer| of |capacity| length. Must only be called
162 * most once in response to each invocation of the 183 * at 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 /* Writes request data from |buffer| of |buffer_length| length. If auto flush is
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 * Flushes pending writes. This method should not be called before invocation of
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 void 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 void 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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698